babylon.module.d.ts 2.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * 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".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * 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"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * 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"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * 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)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * 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
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. 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;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. 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;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * 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"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * 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".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * 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"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * 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".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. */
  3824. constructor(radians: number);
  3825. /**
  3826. * Get value in degrees
  3827. * @returns the Angle value in degrees (float)
  3828. */
  3829. degrees(): number;
  3830. /**
  3831. * Get value in radians
  3832. * @returns the Angle value in radians (float)
  3833. */
  3834. radians(): number;
  3835. /**
  3836. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3837. * @param a defines first vector
  3838. * @param b defines second vector
  3839. * @returns a new Angle
  3840. */
  3841. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3842. /**
  3843. * Gets a new Angle object from the given float in radians
  3844. * @param radians defines the angle value in radians
  3845. * @returns a new Angle
  3846. */
  3847. static FromRadians(radians: number): Angle;
  3848. /**
  3849. * Gets a new Angle object from the given float in degrees
  3850. * @param degrees defines the angle value in degrees
  3851. * @returns a new Angle
  3852. */
  3853. static FromDegrees(degrees: number): Angle;
  3854. }
  3855. /**
  3856. * This represents an arc in a 2d space.
  3857. */
  3858. export class Arc2 {
  3859. /** Defines the start point of the arc */
  3860. startPoint: Vector2;
  3861. /** Defines the mid point of the arc */
  3862. midPoint: Vector2;
  3863. /** Defines the end point of the arc */
  3864. endPoint: Vector2;
  3865. /**
  3866. * Defines the center point of the arc.
  3867. */
  3868. centerPoint: Vector2;
  3869. /**
  3870. * Defines the radius of the arc.
  3871. */
  3872. radius: number;
  3873. /**
  3874. * Defines the angle of the arc (from mid point to end point).
  3875. */
  3876. angle: Angle;
  3877. /**
  3878. * Defines the start angle of the arc (from start point to middle point).
  3879. */
  3880. startAngle: Angle;
  3881. /**
  3882. * Defines the orientation of the arc (clock wise/counter clock wise).
  3883. */
  3884. orientation: Orientation;
  3885. /**
  3886. * Creates an Arc object from the three given points : start, middle and end.
  3887. * @param startPoint Defines the start point of the arc
  3888. * @param midPoint Defines the midlle point of the arc
  3889. * @param endPoint Defines the end point of the arc
  3890. */
  3891. constructor(
  3892. /** Defines the start point of the arc */
  3893. startPoint: Vector2,
  3894. /** Defines the mid point of the arc */
  3895. midPoint: Vector2,
  3896. /** Defines the end point of the arc */
  3897. endPoint: Vector2);
  3898. }
  3899. /**
  3900. * Represents a 2D path made up of multiple 2D points
  3901. */
  3902. export class Path2 {
  3903. private _points;
  3904. private _length;
  3905. /**
  3906. * If the path start and end point are the same
  3907. */
  3908. closed: boolean;
  3909. /**
  3910. * Creates a Path2 object from the starting 2D coordinates x and y.
  3911. * @param x the starting points x value
  3912. * @param y the starting points y value
  3913. */
  3914. constructor(x: number, y: number);
  3915. /**
  3916. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3917. * @param x the added points x value
  3918. * @param y the added points y value
  3919. * @returns the updated Path2.
  3920. */
  3921. addLineTo(x: number, y: number): Path2;
  3922. /**
  3923. * 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.
  3924. * @param midX middle point x value
  3925. * @param midY middle point y value
  3926. * @param endX end point x value
  3927. * @param endY end point y value
  3928. * @param numberOfSegments (default: 36)
  3929. * @returns the updated Path2.
  3930. */
  3931. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3932. /**
  3933. * Closes the Path2.
  3934. * @returns the Path2.
  3935. */
  3936. close(): Path2;
  3937. /**
  3938. * Gets the sum of the distance between each sequential point in the path
  3939. * @returns the Path2 total length (float).
  3940. */
  3941. length(): number;
  3942. /**
  3943. * Gets the points which construct the path
  3944. * @returns the Path2 internal array of points.
  3945. */
  3946. getPoints(): Vector2[];
  3947. /**
  3948. * Retreives the point at the distance aways from the starting point
  3949. * @param normalizedLengthPosition the length along the path to retreive the point from
  3950. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3951. */
  3952. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3953. /**
  3954. * Creates a new path starting from an x and y position
  3955. * @param x starting x value
  3956. * @param y starting y value
  3957. * @returns a new Path2 starting at the coordinates (x, y).
  3958. */
  3959. static StartingAt(x: number, y: number): Path2;
  3960. }
  3961. /**
  3962. * Represents a 3D path made up of multiple 3D points
  3963. */
  3964. export class Path3D {
  3965. /**
  3966. * an array of Vector3, the curve axis of the Path3D
  3967. */
  3968. path: Vector3[];
  3969. private _curve;
  3970. private _distances;
  3971. private _tangents;
  3972. private _normals;
  3973. private _binormals;
  3974. private _raw;
  3975. /**
  3976. * new Path3D(path, normal, raw)
  3977. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3978. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3979. * @param path an array of Vector3, the curve axis of the Path3D
  3980. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3981. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3982. */
  3983. constructor(
  3984. /**
  3985. * an array of Vector3, the curve axis of the Path3D
  3986. */
  3987. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3988. /**
  3989. * Returns the Path3D array of successive Vector3 designing its curve.
  3990. * @returns the Path3D array of successive Vector3 designing its curve.
  3991. */
  3992. getCurve(): Vector3[];
  3993. /**
  3994. * Returns an array populated with tangent vectors on each Path3D curve point.
  3995. * @returns an array populated with tangent vectors on each Path3D curve point.
  3996. */
  3997. getTangents(): Vector3[];
  3998. /**
  3999. * Returns an array populated with normal vectors on each Path3D curve point.
  4000. * @returns an array populated with normal vectors on each Path3D curve point.
  4001. */
  4002. getNormals(): Vector3[];
  4003. /**
  4004. * Returns an array populated with binormal vectors on each Path3D curve point.
  4005. * @returns an array populated with binormal vectors on each Path3D curve point.
  4006. */
  4007. getBinormals(): Vector3[];
  4008. /**
  4009. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4010. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. */
  4012. getDistances(): number[];
  4013. /**
  4014. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4015. * @param path path which all values are copied into the curves points
  4016. * @param firstNormal which should be projected onto the curve
  4017. * @returns the same object updated.
  4018. */
  4019. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4020. private _compute;
  4021. private _getFirstNonNullVector;
  4022. private _getLastNonNullVector;
  4023. private _normalVector;
  4024. }
  4025. /**
  4026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4027. * A Curve3 is designed from a series of successive Vector3.
  4028. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4029. */
  4030. export class Curve3 {
  4031. private _points;
  4032. private _length;
  4033. /**
  4034. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4035. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4036. * @param v1 (Vector3) the control point
  4037. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4038. * @param nbPoints (integer) the wanted number of points in the curve
  4039. * @returns the created Curve3
  4040. */
  4041. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4042. /**
  4043. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4044. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4045. * @param v1 (Vector3) the first control point
  4046. * @param v2 (Vector3) the second control point
  4047. * @param v3 (Vector3) the end point of the Cubic Bezier
  4048. * @param nbPoints (integer) the wanted number of points in the curve
  4049. * @returns the created Curve3
  4050. */
  4051. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4052. /**
  4053. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4054. * @param p1 (Vector3) the origin point of the Hermite Spline
  4055. * @param t1 (Vector3) the tangent vector at the origin point
  4056. * @param p2 (Vector3) the end point of the Hermite Spline
  4057. * @param t2 (Vector3) the tangent vector at the end point
  4058. * @param nbPoints (integer) the wanted number of points in the curve
  4059. * @returns the created Curve3
  4060. */
  4061. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4062. /**
  4063. * Returns a Curve3 object along a CatmullRom Spline curve :
  4064. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4065. * @param nbPoints (integer) the wanted number of points between each curve control points
  4066. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4070. /**
  4071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4072. * A Curve3 is designed from a series of successive Vector3.
  4073. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4074. * @param points points which make up the curve
  4075. */
  4076. constructor(points: Vector3[]);
  4077. /**
  4078. * @returns the Curve3 stored array of successive Vector3
  4079. */
  4080. getPoints(): Vector3[];
  4081. /**
  4082. * @returns the computed length (float) of the curve.
  4083. */
  4084. length(): number;
  4085. /**
  4086. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4087. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4088. * curveA and curveB keep unchanged.
  4089. * @param curve the curve to continue from this curve
  4090. * @returns the newly constructed curve
  4091. */
  4092. continue(curve: DeepImmutable<Curve3>): Curve3;
  4093. private _computeLength;
  4094. }
  4095. /**
  4096. * Contains position and normal vectors for a vertex
  4097. */
  4098. export class PositionNormalVertex {
  4099. /** the position of the vertex (defaut: 0,0,0) */
  4100. position: Vector3;
  4101. /** the normal of the vertex (defaut: 0,1,0) */
  4102. normal: Vector3;
  4103. /**
  4104. * Creates a PositionNormalVertex
  4105. * @param position the position of the vertex (defaut: 0,0,0)
  4106. * @param normal the normal of the vertex (defaut: 0,1,0)
  4107. */
  4108. constructor(
  4109. /** the position of the vertex (defaut: 0,0,0) */
  4110. position?: Vector3,
  4111. /** the normal of the vertex (defaut: 0,1,0) */
  4112. normal?: Vector3);
  4113. /**
  4114. * Clones the PositionNormalVertex
  4115. * @returns the cloned PositionNormalVertex
  4116. */
  4117. clone(): PositionNormalVertex;
  4118. }
  4119. /**
  4120. * Contains position, normal and uv vectors for a vertex
  4121. */
  4122. export class PositionNormalTextureVertex {
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position: Vector3;
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal: Vector3;
  4127. /** the uv of the vertex (default: 0,0) */
  4128. uv: Vector2;
  4129. /**
  4130. * Creates a PositionNormalTextureVertex
  4131. * @param position the position of the vertex (defaut: 0,0,0)
  4132. * @param normal the normal of the vertex (defaut: 0,1,0)
  4133. * @param uv the uv of the vertex (default: 0,0)
  4134. */
  4135. constructor(
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position?: Vector3,
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal?: Vector3,
  4140. /** the uv of the vertex (default: 0,0) */
  4141. uv?: Vector2);
  4142. /**
  4143. * Clones the PositionNormalTextureVertex
  4144. * @returns the cloned PositionNormalTextureVertex
  4145. */
  4146. clone(): PositionNormalTextureVertex;
  4147. }
  4148. /**
  4149. * @hidden
  4150. */
  4151. export class Tmp {
  4152. static Color3: Color3[];
  4153. static Color4: Color4[];
  4154. static Vector2: Vector2[];
  4155. static Vector3: Vector3[];
  4156. static Vector4: Vector4[];
  4157. static Quaternion: Quaternion[];
  4158. static Matrix: Matrix[];
  4159. }
  4160. }
  4161. declare module "babylonjs/Offline/IOfflineProvider" {
  4162. /**
  4163. * Class used to enable access to offline support
  4164. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4165. */
  4166. export interface IOfflineProvider {
  4167. /**
  4168. * Gets a boolean indicating if scene must be saved in the database
  4169. */
  4170. enableSceneOffline: boolean;
  4171. /**
  4172. * Gets a boolean indicating if textures must be saved in the database
  4173. */
  4174. enableTexturesOffline: boolean;
  4175. /**
  4176. * Open the offline support and make it available
  4177. * @param successCallback defines the callback to call on success
  4178. * @param errorCallback defines the callback to call on error
  4179. */
  4180. open(successCallback: () => void, errorCallback: () => void): void;
  4181. /**
  4182. * Loads an image from the offline support
  4183. * @param url defines the url to load from
  4184. * @param image defines the target DOM image
  4185. */
  4186. loadImage(url: string, image: HTMLImageElement): void;
  4187. /**
  4188. * Loads a file from offline support
  4189. * @param url defines the URL to load from
  4190. * @param sceneLoaded defines a callback to call on success
  4191. * @param progressCallBack defines a callback to call when progress changed
  4192. * @param errorCallback defines a callback to call on error
  4193. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4194. */
  4195. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4196. }
  4197. }
  4198. declare module "babylonjs/Misc/observable" {
  4199. import { Nullable } from "babylonjs/types";
  4200. /**
  4201. * A class serves as a medium between the observable and its observers
  4202. */
  4203. export class EventState {
  4204. /**
  4205. * Create a new EventState
  4206. * @param mask defines the mask associated with this state
  4207. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4208. * @param target defines the original target of the state
  4209. * @param currentTarget defines the current target of the state
  4210. */
  4211. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4212. /**
  4213. * Initialize the current event state
  4214. * @param mask defines the mask associated with this state
  4215. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4216. * @param target defines the original target of the state
  4217. * @param currentTarget defines the current target of the state
  4218. * @returns the current event state
  4219. */
  4220. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4221. /**
  4222. * An Observer can set this property to true to prevent subsequent observers of being notified
  4223. */
  4224. skipNextObservers: boolean;
  4225. /**
  4226. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4227. */
  4228. mask: number;
  4229. /**
  4230. * The object that originally notified the event
  4231. */
  4232. target?: any;
  4233. /**
  4234. * The current object in the bubbling phase
  4235. */
  4236. currentTarget?: any;
  4237. /**
  4238. * This will be populated with the return value of the last function that was executed.
  4239. * If it is the first function in the callback chain it will be the event data.
  4240. */
  4241. lastReturnValue?: any;
  4242. }
  4243. /**
  4244. * Represent an Observer registered to a given Observable object.
  4245. */
  4246. export class Observer<T> {
  4247. /**
  4248. * Defines the callback to call when the observer is notified
  4249. */
  4250. callback: (eventData: T, eventState: EventState) => void;
  4251. /**
  4252. * Defines the mask of the observer (used to filter notifications)
  4253. */
  4254. mask: number;
  4255. /**
  4256. * Defines the current scope used to restore the JS context
  4257. */
  4258. scope: any;
  4259. /** @hidden */
  4260. _willBeUnregistered: boolean;
  4261. /**
  4262. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4263. */
  4264. unregisterOnNextCall: boolean;
  4265. /**
  4266. * Creates a new observer
  4267. * @param callback defines the callback to call when the observer is notified
  4268. * @param mask defines the mask of the observer (used to filter notifications)
  4269. * @param scope defines the current scope used to restore the JS context
  4270. */
  4271. constructor(
  4272. /**
  4273. * Defines the callback to call when the observer is notified
  4274. */
  4275. callback: (eventData: T, eventState: EventState) => void,
  4276. /**
  4277. * Defines the mask of the observer (used to filter notifications)
  4278. */
  4279. mask: number,
  4280. /**
  4281. * Defines the current scope used to restore the JS context
  4282. */
  4283. scope?: any);
  4284. }
  4285. /**
  4286. * Represent a list of observers registered to multiple Observables object.
  4287. */
  4288. export class MultiObserver<T> {
  4289. private _observers;
  4290. private _observables;
  4291. /**
  4292. * Release associated resources
  4293. */
  4294. dispose(): void;
  4295. /**
  4296. * Raise a callback when one of the observable will notify
  4297. * @param observables defines a list of observables to watch
  4298. * @param callback defines the callback to call on notification
  4299. * @param mask defines the mask used to filter notifications
  4300. * @param scope defines the current scope used to restore the JS context
  4301. * @returns the new MultiObserver
  4302. */
  4303. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4304. }
  4305. /**
  4306. * The Observable class is a simple implementation of the Observable pattern.
  4307. *
  4308. * 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.
  4309. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4310. * 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).
  4311. * 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.
  4312. */
  4313. export class Observable<T> {
  4314. private _observers;
  4315. private _eventState;
  4316. private _onObserverAdded;
  4317. /**
  4318. * Creates a new observable
  4319. * @param onObserverAdded defines a callback to call when a new observer is added
  4320. */
  4321. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4322. /**
  4323. * Create a new Observer with the specified callback
  4324. * @param callback the callback that will be executed for that Observer
  4325. * @param mask the mask used to filter observers
  4326. * @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.
  4327. * @param scope optional scope for the callback to be called from
  4328. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4329. * @returns the new observer created for the callback
  4330. */
  4331. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4332. /**
  4333. * Create a new Observer with the specified callback and unregisters after the next notification
  4334. * @param callback the callback that will be executed for that Observer
  4335. * @returns the new observer created for the callback
  4336. */
  4337. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4338. /**
  4339. * Remove an Observer from the Observable object
  4340. * @param observer the instance of the Observer to remove
  4341. * @returns false if it doesn't belong to this Observable
  4342. */
  4343. remove(observer: Nullable<Observer<T>>): boolean;
  4344. /**
  4345. * Remove a callback from the Observable object
  4346. * @param callback the callback to remove
  4347. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4348. * @returns false if it doesn't belong to this Observable
  4349. */
  4350. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4351. private _deferUnregister;
  4352. private _remove;
  4353. /**
  4354. * Notify all Observers by calling their respective callback with the given data
  4355. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4356. * @param eventData defines the data to send to all observers
  4357. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4358. * @param target defines the original target of the state
  4359. * @param currentTarget defines the current target of the state
  4360. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4361. */
  4362. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4363. /**
  4364. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4365. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4366. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4367. * and it is crucial that all callbacks will be executed.
  4368. * The order of the callbacks is kept, callbacks are not executed parallel.
  4369. *
  4370. * @param eventData The data to be sent to each callback
  4371. * @param mask is used to filter observers defaults to -1
  4372. * @param target defines the callback target (see EventState)
  4373. * @param currentTarget defines he current object in the bubbling phase
  4374. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4375. */
  4376. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4377. /**
  4378. * Notify a specific observer
  4379. * @param observer defines the observer to notify
  4380. * @param eventData defines the data to be sent to each callback
  4381. * @param mask is used to filter observers defaults to -1
  4382. */
  4383. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4384. /**
  4385. * Gets a boolean indicating if the observable has at least one observer
  4386. * @returns true is the Observable has at least one Observer registered
  4387. */
  4388. hasObservers(): boolean;
  4389. /**
  4390. * Clear the list of observers
  4391. */
  4392. clear(): void;
  4393. /**
  4394. * Clone the current observable
  4395. * @returns a new observable
  4396. */
  4397. clone(): Observable<T>;
  4398. /**
  4399. * Does this observable handles observer registered with a given mask
  4400. * @param mask defines the mask to be tested
  4401. * @return whether or not one observer registered with the given mask is handeled
  4402. **/
  4403. hasSpecificMask(mask?: number): boolean;
  4404. }
  4405. }
  4406. declare module "babylonjs/Misc/filesInputStore" {
  4407. /**
  4408. * Class used to help managing file picking and drag'n'drop
  4409. * File Storage
  4410. */
  4411. export class FilesInputStore {
  4412. /**
  4413. * List of files ready to be loaded
  4414. */
  4415. static FilesToLoad: {
  4416. [key: string]: File;
  4417. };
  4418. }
  4419. }
  4420. declare module "babylonjs/Engines/constants" {
  4421. /** Defines the cross module used constants to avoid circular dependncies */
  4422. export class Constants {
  4423. /** Defines that alpha blending is disabled */
  4424. static readonly ALPHA_DISABLE: number;
  4425. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4426. static readonly ALPHA_ADD: number;
  4427. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4428. static readonly ALPHA_COMBINE: number;
  4429. /** Defines that alpha blending to DEST - SRC * DEST */
  4430. static readonly ALPHA_SUBTRACT: number;
  4431. /** Defines that alpha blending to SRC * DEST */
  4432. static readonly ALPHA_MULTIPLY: number;
  4433. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4434. static readonly ALPHA_MAXIMIZED: number;
  4435. /** Defines that alpha blending to SRC + DEST */
  4436. static readonly ALPHA_ONEONE: number;
  4437. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4438. static readonly ALPHA_PREMULTIPLIED: number;
  4439. /**
  4440. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4441. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4442. */
  4443. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4444. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4445. static readonly ALPHA_INTERPOLATE: number;
  4446. /**
  4447. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4448. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4449. */
  4450. static readonly ALPHA_SCREENMODE: number;
  4451. /** Defines that the ressource is not delayed*/
  4452. static readonly DELAYLOADSTATE_NONE: number;
  4453. /** Defines that the ressource was successfully delay loaded */
  4454. static readonly DELAYLOADSTATE_LOADED: number;
  4455. /** Defines that the ressource is currently delay loading */
  4456. static readonly DELAYLOADSTATE_LOADING: number;
  4457. /** Defines that the ressource is delayed and has not started loading */
  4458. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4460. static readonly NEVER: number;
  4461. /** 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 */
  4462. static readonly ALWAYS: number;
  4463. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4464. static readonly LESS: number;
  4465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4466. static readonly EQUAL: number;
  4467. /** 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 */
  4468. static readonly LEQUAL: number;
  4469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4470. static readonly GREATER: number;
  4471. /** 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 */
  4472. static readonly GEQUAL: number;
  4473. /** 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 */
  4474. static readonly NOTEQUAL: number;
  4475. /** Passed to stencilOperation to specify that stencil value must be kept */
  4476. static readonly KEEP: number;
  4477. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4478. static readonly REPLACE: number;
  4479. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4480. static readonly INCR: number;
  4481. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4482. static readonly DECR: number;
  4483. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4484. static readonly INVERT: number;
  4485. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4486. static readonly INCR_WRAP: number;
  4487. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4488. static readonly DECR_WRAP: number;
  4489. /** Texture is not repeating outside of 0..1 UVs */
  4490. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4491. /** Texture is repeating outside of 0..1 UVs */
  4492. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4493. /** Texture is repeating and mirrored */
  4494. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4495. /** ALPHA */
  4496. static readonly TEXTUREFORMAT_ALPHA: number;
  4497. /** LUMINANCE */
  4498. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4499. /** LUMINANCE_ALPHA */
  4500. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4501. /** RGB */
  4502. static readonly TEXTUREFORMAT_RGB: number;
  4503. /** RGBA */
  4504. static readonly TEXTUREFORMAT_RGBA: number;
  4505. /** RED */
  4506. static readonly TEXTUREFORMAT_RED: number;
  4507. /** RED (2nd reference) */
  4508. static readonly TEXTUREFORMAT_R: number;
  4509. /** RG */
  4510. static readonly TEXTUREFORMAT_RG: number;
  4511. /** RED_INTEGER */
  4512. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4513. /** RED_INTEGER (2nd reference) */
  4514. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4515. /** RG_INTEGER */
  4516. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4517. /** RGB_INTEGER */
  4518. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4519. /** RGBA_INTEGER */
  4520. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4521. /** UNSIGNED_BYTE */
  4522. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4523. /** UNSIGNED_BYTE (2nd reference) */
  4524. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4525. /** FLOAT */
  4526. static readonly TEXTURETYPE_FLOAT: number;
  4527. /** HALF_FLOAT */
  4528. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4529. /** BYTE */
  4530. static readonly TEXTURETYPE_BYTE: number;
  4531. /** SHORT */
  4532. static readonly TEXTURETYPE_SHORT: number;
  4533. /** UNSIGNED_SHORT */
  4534. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4535. /** INT */
  4536. static readonly TEXTURETYPE_INT: number;
  4537. /** UNSIGNED_INT */
  4538. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4539. /** UNSIGNED_SHORT_4_4_4_4 */
  4540. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4541. /** UNSIGNED_SHORT_5_5_5_1 */
  4542. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4543. /** UNSIGNED_SHORT_5_6_5 */
  4544. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4545. /** UNSIGNED_INT_2_10_10_10_REV */
  4546. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4547. /** UNSIGNED_INT_24_8 */
  4548. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4549. /** UNSIGNED_INT_10F_11F_11F_REV */
  4550. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4551. /** UNSIGNED_INT_5_9_9_9_REV */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4553. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4554. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4555. /** nearest is mag = nearest and min = nearest and mip = linear */
  4556. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4557. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4558. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4559. /** Trilinear is mag = linear and min = linear and mip = linear */
  4560. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4561. /** nearest is mag = nearest and min = nearest and mip = linear */
  4562. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4564. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4565. /** Trilinear is mag = linear and min = linear and mip = linear */
  4566. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4567. /** mag = nearest and min = nearest and mip = nearest */
  4568. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4569. /** mag = nearest and min = linear and mip = nearest */
  4570. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4571. /** mag = nearest and min = linear and mip = linear */
  4572. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4573. /** mag = nearest and min = linear and mip = none */
  4574. static readonly TEXTURE_NEAREST_LINEAR: number;
  4575. /** mag = nearest and min = nearest and mip = none */
  4576. static readonly TEXTURE_NEAREST_NEAREST: number;
  4577. /** mag = linear and min = nearest and mip = nearest */
  4578. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4579. /** mag = linear and min = nearest and mip = linear */
  4580. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4581. /** mag = linear and min = linear and mip = none */
  4582. static readonly TEXTURE_LINEAR_LINEAR: number;
  4583. /** mag = linear and min = nearest and mip = none */
  4584. static readonly TEXTURE_LINEAR_NEAREST: number;
  4585. /** Explicit coordinates mode */
  4586. static readonly TEXTURE_EXPLICIT_MODE: number;
  4587. /** Spherical coordinates mode */
  4588. static readonly TEXTURE_SPHERICAL_MODE: number;
  4589. /** Planar coordinates mode */
  4590. static readonly TEXTURE_PLANAR_MODE: number;
  4591. /** Cubic coordinates mode */
  4592. static readonly TEXTURE_CUBIC_MODE: number;
  4593. /** Projection coordinates mode */
  4594. static readonly TEXTURE_PROJECTION_MODE: number;
  4595. /** Skybox coordinates mode */
  4596. static readonly TEXTURE_SKYBOX_MODE: number;
  4597. /** Inverse Cubic coordinates mode */
  4598. static readonly TEXTURE_INVCUBIC_MODE: number;
  4599. /** Equirectangular coordinates mode */
  4600. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4601. /** Equirectangular Fixed coordinates mode */
  4602. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4603. /** Equirectangular Fixed Mirrored coordinates mode */
  4604. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4605. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4606. static readonly SCALEMODE_FLOOR: number;
  4607. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4608. static readonly SCALEMODE_NEAREST: number;
  4609. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4610. static readonly SCALEMODE_CEILING: number;
  4611. /**
  4612. * The dirty texture flag value
  4613. */
  4614. static readonly MATERIAL_TextureDirtyFlag: number;
  4615. /**
  4616. * The dirty light flag value
  4617. */
  4618. static readonly MATERIAL_LightDirtyFlag: number;
  4619. /**
  4620. * The dirty fresnel flag value
  4621. */
  4622. static readonly MATERIAL_FresnelDirtyFlag: number;
  4623. /**
  4624. * The dirty attribute flag value
  4625. */
  4626. static readonly MATERIAL_AttributesDirtyFlag: number;
  4627. /**
  4628. * The dirty misc flag value
  4629. */
  4630. static readonly MATERIAL_MiscDirtyFlag: number;
  4631. /**
  4632. * The all dirty flag value
  4633. */
  4634. static readonly MATERIAL_AllDirtyFlag: number;
  4635. /**
  4636. * Returns the triangle fill mode
  4637. */
  4638. static readonly MATERIAL_TriangleFillMode: number;
  4639. /**
  4640. * Returns the wireframe mode
  4641. */
  4642. static readonly MATERIAL_WireFrameFillMode: number;
  4643. /**
  4644. * Returns the point fill mode
  4645. */
  4646. static readonly MATERIAL_PointFillMode: number;
  4647. /**
  4648. * Returns the point list draw mode
  4649. */
  4650. static readonly MATERIAL_PointListDrawMode: number;
  4651. /**
  4652. * Returns the line list draw mode
  4653. */
  4654. static readonly MATERIAL_LineListDrawMode: number;
  4655. /**
  4656. * Returns the line loop draw mode
  4657. */
  4658. static readonly MATERIAL_LineLoopDrawMode: number;
  4659. /**
  4660. * Returns the line strip draw mode
  4661. */
  4662. static readonly MATERIAL_LineStripDrawMode: number;
  4663. /**
  4664. * Returns the triangle strip draw mode
  4665. */
  4666. static readonly MATERIAL_TriangleStripDrawMode: number;
  4667. /**
  4668. * Returns the triangle fan draw mode
  4669. */
  4670. static readonly MATERIAL_TriangleFanDrawMode: number;
  4671. /**
  4672. * Stores the clock-wise side orientation
  4673. */
  4674. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4675. /**
  4676. * Stores the counter clock-wise side orientation
  4677. */
  4678. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4679. /**
  4680. * Nothing
  4681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4682. */
  4683. static readonly ACTION_NothingTrigger: number;
  4684. /**
  4685. * On pick
  4686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4687. */
  4688. static readonly ACTION_OnPickTrigger: number;
  4689. /**
  4690. * On left pick
  4691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4692. */
  4693. static readonly ACTION_OnLeftPickTrigger: number;
  4694. /**
  4695. * On right pick
  4696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4697. */
  4698. static readonly ACTION_OnRightPickTrigger: number;
  4699. /**
  4700. * On center pick
  4701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4702. */
  4703. static readonly ACTION_OnCenterPickTrigger: number;
  4704. /**
  4705. * On pick down
  4706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4707. */
  4708. static readonly ACTION_OnPickDownTrigger: number;
  4709. /**
  4710. * On double pick
  4711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4712. */
  4713. static readonly ACTION_OnDoublePickTrigger: number;
  4714. /**
  4715. * On pick up
  4716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4717. */
  4718. static readonly ACTION_OnPickUpTrigger: number;
  4719. /**
  4720. * On pick out.
  4721. * This trigger will only be raised if you also declared a OnPickDown
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnPickOutTrigger: number;
  4725. /**
  4726. * On long press
  4727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4728. */
  4729. static readonly ACTION_OnLongPressTrigger: number;
  4730. /**
  4731. * On pointer over
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_OnPointerOverTrigger: number;
  4735. /**
  4736. * On pointer out
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPointerOutTrigger: number;
  4740. /**
  4741. * On every frame
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnEveryFrameTrigger: number;
  4745. /**
  4746. * On intersection enter
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4750. /**
  4751. * On intersection exit
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnIntersectionExitTrigger: number;
  4755. /**
  4756. * On key down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnKeyDownTrigger: number;
  4760. /**
  4761. * On key up
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnKeyUpTrigger: number;
  4765. /**
  4766. * Billboard mode will only apply to Y axis
  4767. */
  4768. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4769. /**
  4770. * Billboard mode will apply to all axes
  4771. */
  4772. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4773. /**
  4774. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4775. */
  4776. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4777. /**
  4778. * Gets or sets base Assets URL
  4779. */
  4780. static readonly PARTICLES_BaseAssetsUrl: string;
  4781. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4782. * Test order :
  4783. * Is the bounding sphere outside the frustum ?
  4784. * If not, are the bounding box vertices outside the frustum ?
  4785. * It not, then the cullable object is in the frustum.
  4786. */
  4787. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4788. /** Culling strategy : Bounding Sphere Only.
  4789. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4790. * It's also less accurate than the standard because some not visible objects can still be selected.
  4791. * Test : is the bounding sphere outside the frustum ?
  4792. * If not, then the cullable object is in the frustum.
  4793. */
  4794. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4795. /** Culling strategy : Optimistic Inclusion.
  4796. * This in an inclusion test first, then the standard exclusion test.
  4797. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4798. * 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.
  4799. * Anyway, it's as accurate as the standard strategy.
  4800. * Test :
  4801. * Is the cullable object bounding sphere center in the frustum ?
  4802. * If not, apply the default culling strategy.
  4803. */
  4804. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4805. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4806. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4807. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4808. * 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.
  4809. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4810. * Test :
  4811. * Is the cullable object bounding sphere center in the frustum ?
  4812. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4813. */
  4814. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4815. /**
  4816. * No logging while loading
  4817. */
  4818. static readonly SCENELOADER_NO_LOGGING: number;
  4819. /**
  4820. * Minimal logging while loading
  4821. */
  4822. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4823. /**
  4824. * Summary logging while loading
  4825. */
  4826. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4827. /**
  4828. * Detailled logging while loading
  4829. */
  4830. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4831. }
  4832. }
  4833. declare module "babylonjs/Misc/domManagement" {
  4834. /**
  4835. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4836. * Babylon.js
  4837. */
  4838. export class DomManagement {
  4839. /**
  4840. * Checks if the window object exists
  4841. * @returns true if the window object exists
  4842. */
  4843. static IsWindowObjectExist(): boolean;
  4844. /**
  4845. * Extracts text content from a DOM element hierarchy
  4846. * @param element defines the root element
  4847. * @returns a string
  4848. */
  4849. static GetDOMTextContent(element: HTMLElement): string;
  4850. }
  4851. }
  4852. declare module "babylonjs/Misc/logger" {
  4853. /**
  4854. * Logger used througouht the application to allow configuration of
  4855. * the log level required for the messages.
  4856. */
  4857. export class Logger {
  4858. /**
  4859. * No log
  4860. */
  4861. static readonly NoneLogLevel: number;
  4862. /**
  4863. * Only message logs
  4864. */
  4865. static readonly MessageLogLevel: number;
  4866. /**
  4867. * Only warning logs
  4868. */
  4869. static readonly WarningLogLevel: number;
  4870. /**
  4871. * Only error logs
  4872. */
  4873. static readonly ErrorLogLevel: number;
  4874. /**
  4875. * All logs
  4876. */
  4877. static readonly AllLogLevel: number;
  4878. private static _LogCache;
  4879. /**
  4880. * Gets a value indicating the number of loading errors
  4881. * @ignorenaming
  4882. */
  4883. static errorsCount: number;
  4884. /**
  4885. * Callback called when a new log is added
  4886. */
  4887. static OnNewCacheEntry: (entry: string) => void;
  4888. private static _AddLogEntry;
  4889. private static _FormatMessage;
  4890. private static _LogDisabled;
  4891. private static _LogEnabled;
  4892. private static _WarnDisabled;
  4893. private static _WarnEnabled;
  4894. private static _ErrorDisabled;
  4895. private static _ErrorEnabled;
  4896. /**
  4897. * Log a message to the console
  4898. */
  4899. static Log: (message: string) => void;
  4900. /**
  4901. * Write a warning message to the console
  4902. */
  4903. static Warn: (message: string) => void;
  4904. /**
  4905. * Write an error message to the console
  4906. */
  4907. static Error: (message: string) => void;
  4908. /**
  4909. * Gets current log cache (list of logs)
  4910. */
  4911. static readonly LogCache: string;
  4912. /**
  4913. * Clears the log cache
  4914. */
  4915. static ClearLogCache(): void;
  4916. /**
  4917. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4918. */
  4919. static LogLevels: number;
  4920. }
  4921. }
  4922. declare module "babylonjs/Misc/typeStore" {
  4923. /** @hidden */
  4924. export class _TypeStore {
  4925. /** @hidden */
  4926. static RegisteredTypes: {
  4927. [key: string]: Object;
  4928. };
  4929. /** @hidden */
  4930. static GetClass(fqdn: string): any;
  4931. }
  4932. }
  4933. declare module "babylonjs/Misc/deepCopier" {
  4934. /**
  4935. * Class containing a set of static utilities functions for deep copy.
  4936. */
  4937. export class DeepCopier {
  4938. /**
  4939. * Tries to copy an object by duplicating every property
  4940. * @param source defines the source object
  4941. * @param destination defines the target object
  4942. * @param doNotCopyList defines a list of properties to avoid
  4943. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4944. */
  4945. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4946. }
  4947. }
  4948. declare module "babylonjs/Misc/precisionDate" {
  4949. /**
  4950. * Class containing a set of static utilities functions for precision date
  4951. */
  4952. export class PrecisionDate {
  4953. /**
  4954. * Gets either window.performance.now() if supported or Date.now() else
  4955. */
  4956. static readonly Now: number;
  4957. }
  4958. }
  4959. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4960. /**
  4961. * Class used to evalaute queries containing `and` and `or` operators
  4962. */
  4963. export class AndOrNotEvaluator {
  4964. /**
  4965. * Evaluate a query
  4966. * @param query defines the query to evaluate
  4967. * @param evaluateCallback defines the callback used to filter result
  4968. * @returns true if the query matches
  4969. */
  4970. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4971. private static _HandleParenthesisContent;
  4972. private static _SimplifyNegation;
  4973. }
  4974. }
  4975. declare module "babylonjs/Misc/tags" {
  4976. /**
  4977. * Class used to store custom tags
  4978. */
  4979. export class Tags {
  4980. /**
  4981. * Adds support for tags on the given object
  4982. * @param obj defines the object to use
  4983. */
  4984. static EnableFor(obj: any): void;
  4985. /**
  4986. * Removes tags support
  4987. * @param obj defines the object to use
  4988. */
  4989. static DisableFor(obj: any): void;
  4990. /**
  4991. * Gets a boolean indicating if the given object has tags
  4992. * @param obj defines the object to use
  4993. * @returns a boolean
  4994. */
  4995. static HasTags(obj: any): boolean;
  4996. /**
  4997. * Gets the tags available on a given object
  4998. * @param obj defines the object to use
  4999. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5000. * @returns the tags
  5001. */
  5002. static GetTags(obj: any, asString?: boolean): any;
  5003. /**
  5004. * Adds tags to an object
  5005. * @param obj defines the object to use
  5006. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5007. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5008. */
  5009. static AddTagsTo(obj: any, tagsString: string): void;
  5010. /**
  5011. * @hidden
  5012. */
  5013. static _AddTagTo(obj: any, tag: string): void;
  5014. /**
  5015. * Removes specific tags from a specific object
  5016. * @param obj defines the object to use
  5017. * @param tagsString defines the tags to remove
  5018. */
  5019. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5020. /**
  5021. * @hidden
  5022. */
  5023. static _RemoveTagFrom(obj: any, tag: string): void;
  5024. /**
  5025. * Defines if tags hosted on an object match a given query
  5026. * @param obj defines the object to use
  5027. * @param tagsQuery defines the tag query
  5028. * @returns a boolean
  5029. */
  5030. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5031. }
  5032. }
  5033. declare module "babylonjs/Materials/materialDefines" {
  5034. /**
  5035. * Manages the defines for the Material
  5036. */
  5037. export class MaterialDefines {
  5038. private _keys;
  5039. private _isDirty;
  5040. /** @hidden */
  5041. _renderId: number;
  5042. /** @hidden */
  5043. _areLightsDirty: boolean;
  5044. /** @hidden */
  5045. _areAttributesDirty: boolean;
  5046. /** @hidden */
  5047. _areTexturesDirty: boolean;
  5048. /** @hidden */
  5049. _areFresnelDirty: boolean;
  5050. /** @hidden */
  5051. _areMiscDirty: boolean;
  5052. /** @hidden */
  5053. _areImageProcessingDirty: boolean;
  5054. /** @hidden */
  5055. _normals: boolean;
  5056. /** @hidden */
  5057. _uvs: boolean;
  5058. /** @hidden */
  5059. _needNormals: boolean;
  5060. /** @hidden */
  5061. _needUVs: boolean;
  5062. /**
  5063. * Specifies if the material needs to be re-calculated
  5064. */
  5065. readonly isDirty: boolean;
  5066. /**
  5067. * Marks the material to indicate that it has been re-calculated
  5068. */
  5069. markAsProcessed(): void;
  5070. /**
  5071. * Marks the material to indicate that it needs to be re-calculated
  5072. */
  5073. markAsUnprocessed(): void;
  5074. /**
  5075. * Marks the material to indicate all of its defines need to be re-calculated
  5076. */
  5077. markAllAsDirty(): void;
  5078. /**
  5079. * Marks the material to indicate that image processing needs to be re-calculated
  5080. */
  5081. markAsImageProcessingDirty(): void;
  5082. /**
  5083. * Marks the material to indicate the lights need to be re-calculated
  5084. */
  5085. markAsLightDirty(): void;
  5086. /**
  5087. * Marks the attribute state as changed
  5088. */
  5089. markAsAttributesDirty(): void;
  5090. /**
  5091. * Marks the texture state as changed
  5092. */
  5093. markAsTexturesDirty(): void;
  5094. /**
  5095. * Marks the fresnel state as changed
  5096. */
  5097. markAsFresnelDirty(): void;
  5098. /**
  5099. * Marks the misc state as changed
  5100. */
  5101. markAsMiscDirty(): void;
  5102. /**
  5103. * Rebuilds the material defines
  5104. */
  5105. rebuild(): void;
  5106. /**
  5107. * Specifies if two material defines are equal
  5108. * @param other - A material define instance to compare to
  5109. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5110. */
  5111. isEqual(other: MaterialDefines): boolean;
  5112. /**
  5113. * Clones this instance's defines to another instance
  5114. * @param other - material defines to clone values to
  5115. */
  5116. cloneTo(other: MaterialDefines): void;
  5117. /**
  5118. * Resets the material define values
  5119. */
  5120. reset(): void;
  5121. /**
  5122. * Converts the material define values to a string
  5123. * @returns - String of material define information
  5124. */
  5125. toString(): string;
  5126. }
  5127. }
  5128. declare module "babylonjs/Misc/performanceMonitor" {
  5129. /**
  5130. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5131. */
  5132. export class PerformanceMonitor {
  5133. private _enabled;
  5134. private _rollingFrameTime;
  5135. private _lastFrameTimeMs;
  5136. /**
  5137. * constructor
  5138. * @param frameSampleSize The number of samples required to saturate the sliding window
  5139. */
  5140. constructor(frameSampleSize?: number);
  5141. /**
  5142. * Samples current frame
  5143. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5144. */
  5145. sampleFrame(timeMs?: number): void;
  5146. /**
  5147. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5148. */
  5149. readonly averageFrameTime: number;
  5150. /**
  5151. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5152. */
  5153. readonly averageFrameTimeVariance: number;
  5154. /**
  5155. * Returns the frame time of the most recent frame
  5156. */
  5157. readonly instantaneousFrameTime: number;
  5158. /**
  5159. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5160. */
  5161. readonly averageFPS: number;
  5162. /**
  5163. * Returns the average framerate in frames per second using the most recent frame time
  5164. */
  5165. readonly instantaneousFPS: number;
  5166. /**
  5167. * Returns true if enough samples have been taken to completely fill the sliding window
  5168. */
  5169. readonly isSaturated: boolean;
  5170. /**
  5171. * Enables contributions to the sliding window sample set
  5172. */
  5173. enable(): void;
  5174. /**
  5175. * Disables contributions to the sliding window sample set
  5176. * Samples will not be interpolated over the disabled period
  5177. */
  5178. disable(): void;
  5179. /**
  5180. * Returns true if sampling is enabled
  5181. */
  5182. readonly isEnabled: boolean;
  5183. /**
  5184. * Resets performance monitor
  5185. */
  5186. reset(): void;
  5187. }
  5188. /**
  5189. * RollingAverage
  5190. *
  5191. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5192. */
  5193. export class RollingAverage {
  5194. /**
  5195. * Current average
  5196. */
  5197. average: number;
  5198. /**
  5199. * Current variance
  5200. */
  5201. variance: number;
  5202. protected _samples: Array<number>;
  5203. protected _sampleCount: number;
  5204. protected _pos: number;
  5205. protected _m2: number;
  5206. /**
  5207. * constructor
  5208. * @param length The number of samples required to saturate the sliding window
  5209. */
  5210. constructor(length: number);
  5211. /**
  5212. * Adds a sample to the sample set
  5213. * @param v The sample value
  5214. */
  5215. add(v: number): void;
  5216. /**
  5217. * Returns previously added values or null if outside of history or outside the sliding window domain
  5218. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5219. * @return Value previously recorded with add() or null if outside of range
  5220. */
  5221. history(i: number): number;
  5222. /**
  5223. * Returns true if enough samples have been taken to completely fill the sliding window
  5224. * @return true if sample-set saturated
  5225. */
  5226. isSaturated(): boolean;
  5227. /**
  5228. * Resets the rolling average (equivalent to 0 samples taken so far)
  5229. */
  5230. reset(): void;
  5231. /**
  5232. * Wraps a value around the sample range boundaries
  5233. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5234. * @return Wrapped position in sample range
  5235. */
  5236. protected _wrapPosition(i: number): number;
  5237. }
  5238. }
  5239. declare module "babylonjs/Misc/stringDictionary" {
  5240. import { Nullable } from "babylonjs/types";
  5241. /**
  5242. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5243. * The underlying implementation relies on an associative array to ensure the best performances.
  5244. * The value can be anything including 'null' but except 'undefined'
  5245. */
  5246. export class StringDictionary<T> {
  5247. /**
  5248. * This will clear this dictionary and copy the content from the 'source' one.
  5249. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5250. * @param source the dictionary to take the content from and copy to this dictionary
  5251. */
  5252. copyFrom(source: StringDictionary<T>): void;
  5253. /**
  5254. * Get a value based from its key
  5255. * @param key the given key to get the matching value from
  5256. * @return the value if found, otherwise undefined is returned
  5257. */
  5258. get(key: string): T | undefined;
  5259. /**
  5260. * Get a value from its key or add it if it doesn't exist.
  5261. * This method will ensure you that a given key/data will be present in the dictionary.
  5262. * @param key the given key to get the matching value from
  5263. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5264. * The factory will only be invoked if there's no data for the given key.
  5265. * @return the value corresponding to the key.
  5266. */
  5267. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5268. /**
  5269. * Get a value from its key if present in the dictionary otherwise add it
  5270. * @param key the key to get the value from
  5271. * @param val if there's no such key/value pair in the dictionary add it with this value
  5272. * @return the value corresponding to the key
  5273. */
  5274. getOrAdd(key: string, val: T): T;
  5275. /**
  5276. * Check if there's a given key in the dictionary
  5277. * @param key the key to check for
  5278. * @return true if the key is present, false otherwise
  5279. */
  5280. contains(key: string): boolean;
  5281. /**
  5282. * Add a new key and its corresponding value
  5283. * @param key the key to add
  5284. * @param value the value corresponding to the key
  5285. * @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
  5286. */
  5287. add(key: string, value: T): boolean;
  5288. /**
  5289. * Update a specific value associated to a key
  5290. * @param key defines the key to use
  5291. * @param value defines the value to store
  5292. * @returns true if the value was updated (or false if the key was not found)
  5293. */
  5294. set(key: string, value: T): boolean;
  5295. /**
  5296. * Get the element of the given key and remove it from the dictionary
  5297. * @param key defines the key to search
  5298. * @returns the value associated with the key or null if not found
  5299. */
  5300. getAndRemove(key: string): Nullable<T>;
  5301. /**
  5302. * Remove a key/value from the dictionary.
  5303. * @param key the key to remove
  5304. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5305. */
  5306. remove(key: string): boolean;
  5307. /**
  5308. * Clear the whole content of the dictionary
  5309. */
  5310. clear(): void;
  5311. /**
  5312. * Gets the current count
  5313. */
  5314. readonly count: number;
  5315. /**
  5316. * Execute a callback on each key/val of the dictionary.
  5317. * Note that you can remove any element in this dictionary in the callback implementation
  5318. * @param callback the callback to execute on a given key/value pair
  5319. */
  5320. forEach(callback: (key: string, val: T) => void): void;
  5321. /**
  5322. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5323. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5324. * Note that you can remove any element in this dictionary in the callback implementation
  5325. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5326. * @returns the first item
  5327. */
  5328. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5329. private _count;
  5330. private _data;
  5331. }
  5332. }
  5333. declare module "babylonjs/Misc/promise" {
  5334. /**
  5335. * Helper class that provides a small promise polyfill
  5336. */
  5337. export class PromisePolyfill {
  5338. /**
  5339. * Static function used to check if the polyfill is required
  5340. * If this is the case then the function will inject the polyfill to window.Promise
  5341. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5342. */
  5343. static Apply(force?: boolean): void;
  5344. }
  5345. }
  5346. declare module "babylonjs/Meshes/buffer" {
  5347. import { Nullable, DataArray } from "babylonjs/types";
  5348. /**
  5349. * Class used to store data that will be store in GPU memory
  5350. */
  5351. export class Buffer {
  5352. private _engine;
  5353. private _buffer;
  5354. /** @hidden */
  5355. _data: Nullable<DataArray>;
  5356. private _updatable;
  5357. private _instanced;
  5358. /**
  5359. * Gets the byte stride.
  5360. */
  5361. readonly byteStride: number;
  5362. /**
  5363. * Constructor
  5364. * @param engine the engine
  5365. * @param data the data to use for this buffer
  5366. * @param updatable whether the data is updatable
  5367. * @param stride the stride (optional)
  5368. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5369. * @param instanced whether the buffer is instanced (optional)
  5370. * @param useBytes set to true if the stride in in bytes (optional)
  5371. */
  5372. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5373. /**
  5374. * Create a new VertexBuffer based on the current buffer
  5375. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5376. * @param offset defines offset in the buffer (0 by default)
  5377. * @param size defines the size in floats of attributes (position is 3 for instance)
  5378. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5379. * @param instanced defines if the vertex buffer contains indexed data
  5380. * @param useBytes defines if the offset and stride are in bytes
  5381. * @returns the new vertex buffer
  5382. */
  5383. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5384. /**
  5385. * Gets a boolean indicating if the Buffer is updatable?
  5386. * @returns true if the buffer is updatable
  5387. */
  5388. isUpdatable(): boolean;
  5389. /**
  5390. * Gets current buffer's data
  5391. * @returns a DataArray or null
  5392. */
  5393. getData(): Nullable<DataArray>;
  5394. /**
  5395. * Gets underlying native buffer
  5396. * @returns underlying native buffer
  5397. */
  5398. getBuffer(): Nullable<WebGLBuffer>;
  5399. /**
  5400. * Gets the stride in float32 units (i.e. byte stride / 4).
  5401. * May not be an integer if the byte stride is not divisible by 4.
  5402. * DEPRECATED. Use byteStride instead.
  5403. * @returns the stride in float32 units
  5404. */
  5405. getStrideSize(): number;
  5406. /**
  5407. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5408. * @param data defines the data to store
  5409. */
  5410. create(data?: Nullable<DataArray>): void;
  5411. /** @hidden */
  5412. _rebuild(): void;
  5413. /**
  5414. * Update current buffer data
  5415. * @param data defines the data to store
  5416. */
  5417. update(data: DataArray): void;
  5418. /**
  5419. * Updates the data directly.
  5420. * @param data the new data
  5421. * @param offset the new offset
  5422. * @param vertexCount the vertex count (optional)
  5423. * @param useBytes set to true if the offset is in bytes
  5424. */
  5425. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5426. /**
  5427. * Release all resources
  5428. */
  5429. dispose(): void;
  5430. }
  5431. /**
  5432. * Specialized buffer used to store vertex data
  5433. */
  5434. export class VertexBuffer {
  5435. /** @hidden */
  5436. _buffer: Buffer;
  5437. private _kind;
  5438. private _size;
  5439. private _ownsBuffer;
  5440. private _instanced;
  5441. private _instanceDivisor;
  5442. /**
  5443. * The byte type.
  5444. */
  5445. static readonly BYTE: number;
  5446. /**
  5447. * The unsigned byte type.
  5448. */
  5449. static readonly UNSIGNED_BYTE: number;
  5450. /**
  5451. * The short type.
  5452. */
  5453. static readonly SHORT: number;
  5454. /**
  5455. * The unsigned short type.
  5456. */
  5457. static readonly UNSIGNED_SHORT: number;
  5458. /**
  5459. * The integer type.
  5460. */
  5461. static readonly INT: number;
  5462. /**
  5463. * The unsigned integer type.
  5464. */
  5465. static readonly UNSIGNED_INT: number;
  5466. /**
  5467. * The float type.
  5468. */
  5469. static readonly FLOAT: number;
  5470. /**
  5471. * Gets or sets the instance divisor when in instanced mode
  5472. */
  5473. instanceDivisor: number;
  5474. /**
  5475. * Gets the byte stride.
  5476. */
  5477. readonly byteStride: number;
  5478. /**
  5479. * Gets the byte offset.
  5480. */
  5481. readonly byteOffset: number;
  5482. /**
  5483. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5484. */
  5485. readonly normalized: boolean;
  5486. /**
  5487. * Gets the data type of each component in the array.
  5488. */
  5489. readonly type: number;
  5490. /**
  5491. * Constructor
  5492. * @param engine the engine
  5493. * @param data the data to use for this vertex buffer
  5494. * @param kind the vertex buffer kind
  5495. * @param updatable whether the data is updatable
  5496. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5497. * @param stride the stride (optional)
  5498. * @param instanced whether the buffer is instanced (optional)
  5499. * @param offset the offset of the data (optional)
  5500. * @param size the number of components (optional)
  5501. * @param type the type of the component (optional)
  5502. * @param normalized whether the data contains normalized data (optional)
  5503. * @param useBytes set to true if stride and offset are in bytes (optional)
  5504. */
  5505. 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);
  5506. /** @hidden */
  5507. _rebuild(): void;
  5508. /**
  5509. * Returns the kind of the VertexBuffer (string)
  5510. * @returns a string
  5511. */
  5512. getKind(): string;
  5513. /**
  5514. * Gets a boolean indicating if the VertexBuffer is updatable?
  5515. * @returns true if the buffer is updatable
  5516. */
  5517. isUpdatable(): boolean;
  5518. /**
  5519. * Gets current buffer's data
  5520. * @returns a DataArray or null
  5521. */
  5522. getData(): Nullable<DataArray>;
  5523. /**
  5524. * Gets underlying native buffer
  5525. * @returns underlying native buffer
  5526. */
  5527. getBuffer(): Nullable<WebGLBuffer>;
  5528. /**
  5529. * Gets the stride in float32 units (i.e. byte stride / 4).
  5530. * May not be an integer if the byte stride is not divisible by 4.
  5531. * DEPRECATED. Use byteStride instead.
  5532. * @returns the stride in float32 units
  5533. */
  5534. getStrideSize(): number;
  5535. /**
  5536. * Returns the offset as a multiple of the type byte length.
  5537. * DEPRECATED. Use byteOffset instead.
  5538. * @returns the offset in bytes
  5539. */
  5540. getOffset(): number;
  5541. /**
  5542. * Returns the number of components per vertex attribute (integer)
  5543. * @returns the size in float
  5544. */
  5545. getSize(): number;
  5546. /**
  5547. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5548. * @returns true if this buffer is instanced
  5549. */
  5550. getIsInstanced(): boolean;
  5551. /**
  5552. * Returns the instancing divisor, zero for non-instanced (integer).
  5553. * @returns a number
  5554. */
  5555. getInstanceDivisor(): number;
  5556. /**
  5557. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5558. * @param data defines the data to store
  5559. */
  5560. create(data?: DataArray): void;
  5561. /**
  5562. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5563. * This function will create a new buffer if the current one is not updatable
  5564. * @param data defines the data to store
  5565. */
  5566. update(data: DataArray): void;
  5567. /**
  5568. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5569. * Returns the directly updated WebGLBuffer.
  5570. * @param data the new data
  5571. * @param offset the new offset
  5572. * @param useBytes set to true if the offset is in bytes
  5573. */
  5574. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5575. /**
  5576. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5577. */
  5578. dispose(): void;
  5579. /**
  5580. * Enumerates each value of this vertex buffer as numbers.
  5581. * @param count the number of values to enumerate
  5582. * @param callback the callback function called for each value
  5583. */
  5584. forEach(count: number, callback: (value: number, index: number) => void): void;
  5585. /**
  5586. * Positions
  5587. */
  5588. static readonly PositionKind: string;
  5589. /**
  5590. * Normals
  5591. */
  5592. static readonly NormalKind: string;
  5593. /**
  5594. * Tangents
  5595. */
  5596. static readonly TangentKind: string;
  5597. /**
  5598. * Texture coordinates
  5599. */
  5600. static readonly UVKind: string;
  5601. /**
  5602. * Texture coordinates 2
  5603. */
  5604. static readonly UV2Kind: string;
  5605. /**
  5606. * Texture coordinates 3
  5607. */
  5608. static readonly UV3Kind: string;
  5609. /**
  5610. * Texture coordinates 4
  5611. */
  5612. static readonly UV4Kind: string;
  5613. /**
  5614. * Texture coordinates 5
  5615. */
  5616. static readonly UV5Kind: string;
  5617. /**
  5618. * Texture coordinates 6
  5619. */
  5620. static readonly UV6Kind: string;
  5621. /**
  5622. * Colors
  5623. */
  5624. static readonly ColorKind: string;
  5625. /**
  5626. * Matrix indices (for bones)
  5627. */
  5628. static readonly MatricesIndicesKind: string;
  5629. /**
  5630. * Matrix weights (for bones)
  5631. */
  5632. static readonly MatricesWeightsKind: string;
  5633. /**
  5634. * Additional matrix indices (for bones)
  5635. */
  5636. static readonly MatricesIndicesExtraKind: string;
  5637. /**
  5638. * Additional matrix weights (for bones)
  5639. */
  5640. static readonly MatricesWeightsExtraKind: string;
  5641. /**
  5642. * Deduces the stride given a kind.
  5643. * @param kind The kind string to deduce
  5644. * @returns The deduced stride
  5645. */
  5646. static DeduceStride(kind: string): number;
  5647. /**
  5648. * Gets the byte length of the given type.
  5649. * @param type the type
  5650. * @returns the number of bytes
  5651. */
  5652. static GetTypeByteLength(type: number): number;
  5653. /**
  5654. * Enumerates each value of the given parameters as numbers.
  5655. * @param data the data to enumerate
  5656. * @param byteOffset the byte offset of the data
  5657. * @param byteStride the byte stride of the data
  5658. * @param componentCount the number of components per element
  5659. * @param componentType the type of the component
  5660. * @param count the total number of components
  5661. * @param normalized whether the data is normalized
  5662. * @param callback the callback function called for each value
  5663. */
  5664. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5665. private static _GetFloatValue;
  5666. }
  5667. }
  5668. declare module "babylonjs/Maths/sphericalPolynomial" {
  5669. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5670. /**
  5671. * Class representing spherical polynomial coefficients to the 3rd degree
  5672. */
  5673. export class SphericalPolynomial {
  5674. /**
  5675. * The x coefficients of the spherical polynomial
  5676. */
  5677. x: Vector3;
  5678. /**
  5679. * The y coefficients of the spherical polynomial
  5680. */
  5681. y: Vector3;
  5682. /**
  5683. * The z coefficients of the spherical polynomial
  5684. */
  5685. z: Vector3;
  5686. /**
  5687. * The xx coefficients of the spherical polynomial
  5688. */
  5689. xx: Vector3;
  5690. /**
  5691. * The yy coefficients of the spherical polynomial
  5692. */
  5693. yy: Vector3;
  5694. /**
  5695. * The zz coefficients of the spherical polynomial
  5696. */
  5697. zz: Vector3;
  5698. /**
  5699. * The xy coefficients of the spherical polynomial
  5700. */
  5701. xy: Vector3;
  5702. /**
  5703. * The yz coefficients of the spherical polynomial
  5704. */
  5705. yz: Vector3;
  5706. /**
  5707. * The zx coefficients of the spherical polynomial
  5708. */
  5709. zx: Vector3;
  5710. /**
  5711. * Adds an ambient color to the spherical polynomial
  5712. * @param color the color to add
  5713. */
  5714. addAmbient(color: Color3): void;
  5715. /**
  5716. * Scales the spherical polynomial by the given amount
  5717. * @param scale the amount to scale
  5718. */
  5719. scale(scale: number): void;
  5720. /**
  5721. * Gets the spherical polynomial from harmonics
  5722. * @param harmonics the spherical harmonics
  5723. * @returns the spherical polynomial
  5724. */
  5725. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5726. /**
  5727. * Constructs a spherical polynomial from an array.
  5728. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5729. * @returns the spherical polynomial
  5730. */
  5731. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5732. }
  5733. /**
  5734. * Class representing spherical harmonics coefficients to the 3rd degree
  5735. */
  5736. export class SphericalHarmonics {
  5737. /**
  5738. * The l0,0 coefficients of the spherical harmonics
  5739. */
  5740. l00: Vector3;
  5741. /**
  5742. * The l1,-1 coefficients of the spherical harmonics
  5743. */
  5744. l1_1: Vector3;
  5745. /**
  5746. * The l1,0 coefficients of the spherical harmonics
  5747. */
  5748. l10: Vector3;
  5749. /**
  5750. * The l1,1 coefficients of the spherical harmonics
  5751. */
  5752. l11: Vector3;
  5753. /**
  5754. * The l2,-2 coefficients of the spherical harmonics
  5755. */
  5756. l2_2: Vector3;
  5757. /**
  5758. * The l2,-1 coefficients of the spherical harmonics
  5759. */
  5760. l2_1: Vector3;
  5761. /**
  5762. * The l2,0 coefficients of the spherical harmonics
  5763. */
  5764. l20: Vector3;
  5765. /**
  5766. * The l2,1 coefficients of the spherical harmonics
  5767. */
  5768. l21: Vector3;
  5769. /**
  5770. * The l2,2 coefficients of the spherical harmonics
  5771. */
  5772. lL22: Vector3;
  5773. /**
  5774. * Adds a light to the spherical harmonics
  5775. * @param direction the direction of the light
  5776. * @param color the color of the light
  5777. * @param deltaSolidAngle the delta solid angle of the light
  5778. */
  5779. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5780. /**
  5781. * Scales the spherical harmonics by the given amount
  5782. * @param scale the amount to scale
  5783. */
  5784. scale(scale: number): void;
  5785. /**
  5786. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5787. *
  5788. * ```
  5789. * E_lm = A_l * L_lm
  5790. * ```
  5791. *
  5792. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5793. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5794. * the scaling factors are given in equation 9.
  5795. */
  5796. convertIncidentRadianceToIrradiance(): void;
  5797. /**
  5798. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5799. *
  5800. * ```
  5801. * L = (1/pi) * E * rho
  5802. * ```
  5803. *
  5804. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5805. */
  5806. convertIrradianceToLambertianRadiance(): void;
  5807. /**
  5808. * Gets the spherical harmonics from polynomial
  5809. * @param polynomial the spherical polynomial
  5810. * @returns the spherical harmonics
  5811. */
  5812. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5813. /**
  5814. * Constructs a spherical harmonics from an array.
  5815. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5816. * @returns the spherical harmonics
  5817. */
  5818. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5819. }
  5820. }
  5821. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5822. import { Nullable } from "babylonjs/types";
  5823. /**
  5824. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5825. */
  5826. export interface CubeMapInfo {
  5827. /**
  5828. * The pixel array for the front face.
  5829. * This is stored in format, left to right, up to down format.
  5830. */
  5831. front: Nullable<ArrayBufferView>;
  5832. /**
  5833. * The pixel array for the back face.
  5834. * This is stored in format, left to right, up to down format.
  5835. */
  5836. back: Nullable<ArrayBufferView>;
  5837. /**
  5838. * The pixel array for the left face.
  5839. * This is stored in format, left to right, up to down format.
  5840. */
  5841. left: Nullable<ArrayBufferView>;
  5842. /**
  5843. * The pixel array for the right face.
  5844. * This is stored in format, left to right, up to down format.
  5845. */
  5846. right: Nullable<ArrayBufferView>;
  5847. /**
  5848. * The pixel array for the up face.
  5849. * This is stored in format, left to right, up to down format.
  5850. */
  5851. up: Nullable<ArrayBufferView>;
  5852. /**
  5853. * The pixel array for the down face.
  5854. * This is stored in format, left to right, up to down format.
  5855. */
  5856. down: Nullable<ArrayBufferView>;
  5857. /**
  5858. * The size of the cubemap stored.
  5859. *
  5860. * Each faces will be size * size pixels.
  5861. */
  5862. size: number;
  5863. /**
  5864. * The format of the texture.
  5865. *
  5866. * RGBA, RGB.
  5867. */
  5868. format: number;
  5869. /**
  5870. * The type of the texture data.
  5871. *
  5872. * UNSIGNED_INT, FLOAT.
  5873. */
  5874. type: number;
  5875. /**
  5876. * Specifies whether the texture is in gamma space.
  5877. */
  5878. gammaSpace: boolean;
  5879. }
  5880. /**
  5881. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5882. */
  5883. export class PanoramaToCubeMapTools {
  5884. private static FACE_FRONT;
  5885. private static FACE_BACK;
  5886. private static FACE_RIGHT;
  5887. private static FACE_LEFT;
  5888. private static FACE_DOWN;
  5889. private static FACE_UP;
  5890. /**
  5891. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5892. *
  5893. * @param float32Array The source data.
  5894. * @param inputWidth The width of the input panorama.
  5895. * @param inputHeight The height of the input panorama.
  5896. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5897. * @return The cubemap data
  5898. */
  5899. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5900. private static CreateCubemapTexture;
  5901. private static CalcProjectionSpherical;
  5902. }
  5903. }
  5904. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5905. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5907. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5908. /**
  5909. * Helper class dealing with the extraction of spherical polynomial dataArray
  5910. * from a cube map.
  5911. */
  5912. export class CubeMapToSphericalPolynomialTools {
  5913. private static FileFaces;
  5914. /**
  5915. * Converts a texture to the according Spherical Polynomial data.
  5916. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5917. *
  5918. * @param texture The texture to extract the information from.
  5919. * @return The Spherical Polynomial data.
  5920. */
  5921. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5922. /**
  5923. * Converts a cubemap to the according Spherical Polynomial data.
  5924. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5925. *
  5926. * @param cubeInfo The Cube map to extract the information from.
  5927. * @return The Spherical Polynomial data.
  5928. */
  5929. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5930. }
  5931. }
  5932. declare module "babylonjs/Engines/engineStore" {
  5933. import { Nullable } from "babylonjs/types";
  5934. import { Engine } from "babylonjs/Engines/engine";
  5935. import { Scene } from "babylonjs/scene";
  5936. /**
  5937. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5938. * during the life time of the application.
  5939. */
  5940. export class EngineStore {
  5941. /** Gets the list of created engines */
  5942. static Instances: import("babylonjs/Engines/engine").Engine[];
  5943. /**
  5944. * Gets the latest created engine
  5945. */
  5946. static readonly LastCreatedEngine: Nullable<Engine>;
  5947. /**
  5948. * Gets the latest created scene
  5949. */
  5950. static readonly LastCreatedScene: Nullable<Scene>;
  5951. }
  5952. }
  5953. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5954. /**
  5955. * Define options used to create a render target texture
  5956. */
  5957. export class RenderTargetCreationOptions {
  5958. /**
  5959. * Specifies is mipmaps must be generated
  5960. */
  5961. generateMipMaps?: boolean;
  5962. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5963. generateDepthBuffer?: boolean;
  5964. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5965. generateStencilBuffer?: boolean;
  5966. /** Defines texture type (int by default) */
  5967. type?: number;
  5968. /** Defines sampling mode (trilinear by default) */
  5969. samplingMode?: number;
  5970. /** Defines format (RGBA by default) */
  5971. format?: number;
  5972. }
  5973. }
  5974. declare module "babylonjs/States/alphaCullingState" {
  5975. /**
  5976. * @hidden
  5977. **/
  5978. export class _AlphaState {
  5979. private _isAlphaBlendDirty;
  5980. private _isBlendFunctionParametersDirty;
  5981. private _isBlendEquationParametersDirty;
  5982. private _isBlendConstantsDirty;
  5983. private _alphaBlend;
  5984. private _blendFunctionParameters;
  5985. private _blendEquationParameters;
  5986. private _blendConstants;
  5987. /**
  5988. * Initializes the state.
  5989. */
  5990. constructor();
  5991. readonly isDirty: boolean;
  5992. alphaBlend: boolean;
  5993. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5994. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5995. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5996. reset(): void;
  5997. apply(gl: WebGLRenderingContext): void;
  5998. }
  5999. }
  6000. declare module "babylonjs/States/depthCullingState" {
  6001. import { Nullable } from "babylonjs/types";
  6002. /**
  6003. * @hidden
  6004. **/
  6005. export class _DepthCullingState {
  6006. private _isDepthTestDirty;
  6007. private _isDepthMaskDirty;
  6008. private _isDepthFuncDirty;
  6009. private _isCullFaceDirty;
  6010. private _isCullDirty;
  6011. private _isZOffsetDirty;
  6012. private _isFrontFaceDirty;
  6013. private _depthTest;
  6014. private _depthMask;
  6015. private _depthFunc;
  6016. private _cull;
  6017. private _cullFace;
  6018. private _zOffset;
  6019. private _frontFace;
  6020. /**
  6021. * Initializes the state.
  6022. */
  6023. constructor();
  6024. readonly isDirty: boolean;
  6025. zOffset: number;
  6026. cullFace: Nullable<number>;
  6027. cull: Nullable<boolean>;
  6028. depthFunc: Nullable<number>;
  6029. depthMask: boolean;
  6030. depthTest: boolean;
  6031. frontFace: Nullable<number>;
  6032. reset(): void;
  6033. apply(gl: WebGLRenderingContext): void;
  6034. }
  6035. }
  6036. declare module "babylonjs/States/stencilState" {
  6037. /**
  6038. * @hidden
  6039. **/
  6040. export class _StencilState {
  6041. /** 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 */
  6042. static readonly ALWAYS: number;
  6043. /** Passed to stencilOperation to specify that stencil value must be kept */
  6044. static readonly KEEP: number;
  6045. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6046. static readonly REPLACE: number;
  6047. private _isStencilTestDirty;
  6048. private _isStencilMaskDirty;
  6049. private _isStencilFuncDirty;
  6050. private _isStencilOpDirty;
  6051. private _stencilTest;
  6052. private _stencilMask;
  6053. private _stencilFunc;
  6054. private _stencilFuncRef;
  6055. private _stencilFuncMask;
  6056. private _stencilOpStencilFail;
  6057. private _stencilOpDepthFail;
  6058. private _stencilOpStencilDepthPass;
  6059. readonly isDirty: boolean;
  6060. stencilFunc: number;
  6061. stencilFuncRef: number;
  6062. stencilFuncMask: number;
  6063. stencilOpStencilFail: number;
  6064. stencilOpDepthFail: number;
  6065. stencilOpStencilDepthPass: number;
  6066. stencilMask: number;
  6067. stencilTest: boolean;
  6068. constructor();
  6069. reset(): void;
  6070. apply(gl: WebGLRenderingContext): void;
  6071. }
  6072. }
  6073. declare module "babylonjs/States/index" {
  6074. export * from "babylonjs/States/alphaCullingState";
  6075. export * from "babylonjs/States/depthCullingState";
  6076. export * from "babylonjs/States/stencilState";
  6077. }
  6078. declare module "babylonjs/Instrumentation/timeToken" {
  6079. import { Nullable } from "babylonjs/types";
  6080. /**
  6081. * @hidden
  6082. **/
  6083. export class _TimeToken {
  6084. _startTimeQuery: Nullable<WebGLQuery>;
  6085. _endTimeQuery: Nullable<WebGLQuery>;
  6086. _timeElapsedQuery: Nullable<WebGLQuery>;
  6087. _timeElapsedQueryEnded: boolean;
  6088. }
  6089. }
  6090. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6091. import { Nullable } from "babylonjs/types";
  6092. /**
  6093. * Internal interface used to track InternalTexture already bound to the GL context
  6094. */
  6095. export interface IInternalTextureTracker {
  6096. /**
  6097. * Gets or set the previous tracker in the list
  6098. */
  6099. previous: Nullable<IInternalTextureTracker>;
  6100. /**
  6101. * Gets or set the next tracker in the list
  6102. */
  6103. next: Nullable<IInternalTextureTracker>;
  6104. }
  6105. /**
  6106. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6107. */
  6108. export class DummyInternalTextureTracker {
  6109. /**
  6110. * Gets or set the previous tracker in the list
  6111. */
  6112. previous: Nullable<IInternalTextureTracker>;
  6113. /**
  6114. * Gets or set the next tracker in the list
  6115. */
  6116. next: Nullable<IInternalTextureTracker>;
  6117. }
  6118. }
  6119. declare module "babylonjs/Materials/Textures/internalTexture" {
  6120. import { Observable } from "babylonjs/Misc/observable";
  6121. import { Nullable, int } from "babylonjs/types";
  6122. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6123. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6124. import { Engine } from "babylonjs/Engines/engine";
  6125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6126. /**
  6127. * Class used to store data associated with WebGL texture data for the engine
  6128. * This class should not be used directly
  6129. */
  6130. export class InternalTexture implements IInternalTextureTracker {
  6131. /** hidden */
  6132. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6133. /**
  6134. * The source of the texture data is unknown
  6135. */
  6136. static DATASOURCE_UNKNOWN: number;
  6137. /**
  6138. * Texture data comes from an URL
  6139. */
  6140. static DATASOURCE_URL: number;
  6141. /**
  6142. * Texture data is only used for temporary storage
  6143. */
  6144. static DATASOURCE_TEMP: number;
  6145. /**
  6146. * Texture data comes from raw data (ArrayBuffer)
  6147. */
  6148. static DATASOURCE_RAW: number;
  6149. /**
  6150. * Texture content is dynamic (video or dynamic texture)
  6151. */
  6152. static DATASOURCE_DYNAMIC: number;
  6153. /**
  6154. * Texture content is generated by rendering to it
  6155. */
  6156. static DATASOURCE_RENDERTARGET: number;
  6157. /**
  6158. * Texture content is part of a multi render target process
  6159. */
  6160. static DATASOURCE_MULTIRENDERTARGET: number;
  6161. /**
  6162. * Texture data comes from a cube data file
  6163. */
  6164. static DATASOURCE_CUBE: number;
  6165. /**
  6166. * Texture data comes from a raw cube data
  6167. */
  6168. static DATASOURCE_CUBERAW: number;
  6169. /**
  6170. * Texture data come from a prefiltered cube data file
  6171. */
  6172. static DATASOURCE_CUBEPREFILTERED: number;
  6173. /**
  6174. * Texture content is raw 3D data
  6175. */
  6176. static DATASOURCE_RAW3D: number;
  6177. /**
  6178. * Texture content is a depth texture
  6179. */
  6180. static DATASOURCE_DEPTHTEXTURE: number;
  6181. /**
  6182. * Texture data comes from a raw cube data encoded with RGBD
  6183. */
  6184. static DATASOURCE_CUBERAW_RGBD: number;
  6185. /**
  6186. * Defines if the texture is ready
  6187. */
  6188. isReady: boolean;
  6189. /**
  6190. * Defines if the texture is a cube texture
  6191. */
  6192. isCube: boolean;
  6193. /**
  6194. * Defines if the texture contains 3D data
  6195. */
  6196. is3D: boolean;
  6197. /**
  6198. * Gets the URL used to load this texture
  6199. */
  6200. url: string;
  6201. /**
  6202. * Gets the sampling mode of the texture
  6203. */
  6204. samplingMode: number;
  6205. /**
  6206. * Gets a boolean indicating if the texture needs mipmaps generation
  6207. */
  6208. generateMipMaps: boolean;
  6209. /**
  6210. * Gets the number of samples used by the texture (WebGL2+ only)
  6211. */
  6212. samples: number;
  6213. /**
  6214. * Gets the type of the texture (int, float...)
  6215. */
  6216. type: number;
  6217. /**
  6218. * Gets the format of the texture (RGB, RGBA...)
  6219. */
  6220. format: number;
  6221. /**
  6222. * Observable called when the texture is loaded
  6223. */
  6224. onLoadedObservable: Observable<InternalTexture>;
  6225. /**
  6226. * Gets the width of the texture
  6227. */
  6228. width: number;
  6229. /**
  6230. * Gets the height of the texture
  6231. */
  6232. height: number;
  6233. /**
  6234. * Gets the depth of the texture
  6235. */
  6236. depth: number;
  6237. /**
  6238. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6239. */
  6240. baseWidth: number;
  6241. /**
  6242. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6243. */
  6244. baseHeight: number;
  6245. /**
  6246. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6247. */
  6248. baseDepth: number;
  6249. /**
  6250. * Gets a boolean indicating if the texture is inverted on Y axis
  6251. */
  6252. invertY: boolean;
  6253. /**
  6254. * Gets or set the previous tracker in the list
  6255. */
  6256. previous: Nullable<IInternalTextureTracker>;
  6257. /**
  6258. * Gets or set the next tracker in the list
  6259. */
  6260. next: Nullable<IInternalTextureTracker>;
  6261. /** @hidden */
  6262. _invertVScale: boolean;
  6263. /** @hidden */
  6264. _initialSlot: number;
  6265. /** @hidden */
  6266. _designatedSlot: number;
  6267. /** @hidden */
  6268. _dataSource: number;
  6269. /** @hidden */
  6270. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6271. /** @hidden */
  6272. _bufferView: Nullable<ArrayBufferView>;
  6273. /** @hidden */
  6274. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6275. /** @hidden */
  6276. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6277. /** @hidden */
  6278. _size: number;
  6279. /** @hidden */
  6280. _extension: string;
  6281. /** @hidden */
  6282. _files: Nullable<string[]>;
  6283. /** @hidden */
  6284. _workingCanvas: HTMLCanvasElement;
  6285. /** @hidden */
  6286. _workingContext: CanvasRenderingContext2D;
  6287. /** @hidden */
  6288. _framebuffer: Nullable<WebGLFramebuffer>;
  6289. /** @hidden */
  6290. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6291. /** @hidden */
  6292. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6293. /** @hidden */
  6294. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6295. /** @hidden */
  6296. _attachments: Nullable<number[]>;
  6297. /** @hidden */
  6298. _cachedCoordinatesMode: Nullable<number>;
  6299. /** @hidden */
  6300. _cachedWrapU: Nullable<number>;
  6301. /** @hidden */
  6302. _cachedWrapV: Nullable<number>;
  6303. /** @hidden */
  6304. _cachedWrapR: Nullable<number>;
  6305. /** @hidden */
  6306. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6307. /** @hidden */
  6308. _isDisabled: boolean;
  6309. /** @hidden */
  6310. _compression: Nullable<string>;
  6311. /** @hidden */
  6312. _generateStencilBuffer: boolean;
  6313. /** @hidden */
  6314. _generateDepthBuffer: boolean;
  6315. /** @hidden */
  6316. _comparisonFunction: number;
  6317. /** @hidden */
  6318. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6319. /** @hidden */
  6320. _lodGenerationScale: number;
  6321. /** @hidden */
  6322. _lodGenerationOffset: number;
  6323. /** @hidden */
  6324. _lodTextureHigh: BaseTexture;
  6325. /** @hidden */
  6326. _lodTextureMid: BaseTexture;
  6327. /** @hidden */
  6328. _lodTextureLow: BaseTexture;
  6329. /** @hidden */
  6330. _isRGBD: boolean;
  6331. /** @hidden */
  6332. _webGLTexture: Nullable<WebGLTexture>;
  6333. /** @hidden */
  6334. _references: number;
  6335. private _engine;
  6336. /**
  6337. * Gets the Engine the texture belongs to.
  6338. * @returns The babylon engine
  6339. */
  6340. getEngine(): Engine;
  6341. /**
  6342. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6343. */
  6344. readonly dataSource: number;
  6345. /**
  6346. * Creates a new InternalTexture
  6347. * @param engine defines the engine to use
  6348. * @param dataSource defines the type of data that will be used
  6349. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6350. */
  6351. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6352. /**
  6353. * Increments the number of references (ie. the number of Texture that point to it)
  6354. */
  6355. incrementReferences(): void;
  6356. /**
  6357. * Change the size of the texture (not the size of the content)
  6358. * @param width defines the new width
  6359. * @param height defines the new height
  6360. * @param depth defines the new depth (1 by default)
  6361. */
  6362. updateSize(width: int, height: int, depth?: int): void;
  6363. /** @hidden */
  6364. _rebuild(): void;
  6365. /** @hidden */
  6366. _swapAndDie(target: InternalTexture): void;
  6367. /**
  6368. * Dispose the current allocated resources
  6369. */
  6370. dispose(): void;
  6371. }
  6372. }
  6373. declare module "babylonjs/Animations/easing" {
  6374. /**
  6375. * This represents the main contract an easing function should follow.
  6376. * Easing functions are used throughout the animation system.
  6377. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6378. */
  6379. export interface IEasingFunction {
  6380. /**
  6381. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6382. * of the easing function.
  6383. * The link below provides some of the most common examples of easing functions.
  6384. * @see https://easings.net/
  6385. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6386. * @returns the corresponding value on the curve defined by the easing function
  6387. */
  6388. ease(gradient: number): number;
  6389. }
  6390. /**
  6391. * Base class used for every default easing function.
  6392. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6393. */
  6394. export class EasingFunction implements IEasingFunction {
  6395. /**
  6396. * Interpolation follows the mathematical formula associated with the easing function.
  6397. */
  6398. static readonly EASINGMODE_EASEIN: number;
  6399. /**
  6400. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6401. */
  6402. static readonly EASINGMODE_EASEOUT: number;
  6403. /**
  6404. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6405. */
  6406. static readonly EASINGMODE_EASEINOUT: number;
  6407. private _easingMode;
  6408. /**
  6409. * Sets the easing mode of the current function.
  6410. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6411. */
  6412. setEasingMode(easingMode: number): void;
  6413. /**
  6414. * Gets the current easing mode.
  6415. * @returns the easing mode
  6416. */
  6417. getEasingMode(): number;
  6418. /**
  6419. * @hidden
  6420. */
  6421. easeInCore(gradient: number): number;
  6422. /**
  6423. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6424. * of the easing function.
  6425. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6426. * @returns the corresponding value on the curve defined by the easing function
  6427. */
  6428. ease(gradient: number): number;
  6429. }
  6430. /**
  6431. * Easing function with a circle shape (see link below).
  6432. * @see https://easings.net/#easeInCirc
  6433. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6434. */
  6435. export class CircleEase extends EasingFunction implements IEasingFunction {
  6436. /** @hidden */
  6437. easeInCore(gradient: number): number;
  6438. }
  6439. /**
  6440. * Easing function with a ease back shape (see link below).
  6441. * @see https://easings.net/#easeInBack
  6442. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6443. */
  6444. export class BackEase extends EasingFunction implements IEasingFunction {
  6445. /** Defines the amplitude of the function */
  6446. amplitude: number;
  6447. /**
  6448. * Instantiates a back ease easing
  6449. * @see https://easings.net/#easeInBack
  6450. * @param amplitude Defines the amplitude of the function
  6451. */
  6452. constructor(
  6453. /** Defines the amplitude of the function */
  6454. amplitude?: number);
  6455. /** @hidden */
  6456. easeInCore(gradient: number): number;
  6457. }
  6458. /**
  6459. * Easing function with a bouncing shape (see link below).
  6460. * @see https://easings.net/#easeInBounce
  6461. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6462. */
  6463. export class BounceEase extends EasingFunction implements IEasingFunction {
  6464. /** Defines the number of bounces */
  6465. bounces: number;
  6466. /** Defines the amplitude of the bounce */
  6467. bounciness: number;
  6468. /**
  6469. * Instantiates a bounce easing
  6470. * @see https://easings.net/#easeInBounce
  6471. * @param bounces Defines the number of bounces
  6472. * @param bounciness Defines the amplitude of the bounce
  6473. */
  6474. constructor(
  6475. /** Defines the number of bounces */
  6476. bounces?: number,
  6477. /** Defines the amplitude of the bounce */
  6478. bounciness?: number);
  6479. /** @hidden */
  6480. easeInCore(gradient: number): number;
  6481. }
  6482. /**
  6483. * Easing function with a power of 3 shape (see link below).
  6484. * @see https://easings.net/#easeInCubic
  6485. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6486. */
  6487. export class CubicEase extends EasingFunction implements IEasingFunction {
  6488. /** @hidden */
  6489. easeInCore(gradient: number): number;
  6490. }
  6491. /**
  6492. * Easing function with an elastic shape (see link below).
  6493. * @see https://easings.net/#easeInElastic
  6494. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6495. */
  6496. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6497. /** Defines the number of oscillations*/
  6498. oscillations: number;
  6499. /** Defines the amplitude of the oscillations*/
  6500. springiness: number;
  6501. /**
  6502. * Instantiates an elastic easing function
  6503. * @see https://easings.net/#easeInElastic
  6504. * @param oscillations Defines the number of oscillations
  6505. * @param springiness Defines the amplitude of the oscillations
  6506. */
  6507. constructor(
  6508. /** Defines the number of oscillations*/
  6509. oscillations?: number,
  6510. /** Defines the amplitude of the oscillations*/
  6511. springiness?: number);
  6512. /** @hidden */
  6513. easeInCore(gradient: number): number;
  6514. }
  6515. /**
  6516. * Easing function with an exponential shape (see link below).
  6517. * @see https://easings.net/#easeInExpo
  6518. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6519. */
  6520. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6521. /** Defines the exponent of the function */
  6522. exponent: number;
  6523. /**
  6524. * Instantiates an exponential easing function
  6525. * @see https://easings.net/#easeInExpo
  6526. * @param exponent Defines the exponent of the function
  6527. */
  6528. constructor(
  6529. /** Defines the exponent of the function */
  6530. exponent?: number);
  6531. /** @hidden */
  6532. easeInCore(gradient: number): number;
  6533. }
  6534. /**
  6535. * Easing function with a power shape (see link below).
  6536. * @see https://easings.net/#easeInQuad
  6537. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6538. */
  6539. export class PowerEase extends EasingFunction implements IEasingFunction {
  6540. /** Defines the power of the function */
  6541. power: number;
  6542. /**
  6543. * Instantiates an power base easing function
  6544. * @see https://easings.net/#easeInQuad
  6545. * @param power Defines the power of the function
  6546. */
  6547. constructor(
  6548. /** Defines the power of the function */
  6549. power?: number);
  6550. /** @hidden */
  6551. easeInCore(gradient: number): number;
  6552. }
  6553. /**
  6554. * Easing function with a power of 2 shape (see link below).
  6555. * @see https://easings.net/#easeInQuad
  6556. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6557. */
  6558. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6559. /** @hidden */
  6560. easeInCore(gradient: number): number;
  6561. }
  6562. /**
  6563. * Easing function with a power of 4 shape (see link below).
  6564. * @see https://easings.net/#easeInQuart
  6565. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6566. */
  6567. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6568. /** @hidden */
  6569. easeInCore(gradient: number): number;
  6570. }
  6571. /**
  6572. * Easing function with a power of 5 shape (see link below).
  6573. * @see https://easings.net/#easeInQuint
  6574. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6575. */
  6576. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6577. /** @hidden */
  6578. easeInCore(gradient: number): number;
  6579. }
  6580. /**
  6581. * Easing function with a sin shape (see link below).
  6582. * @see https://easings.net/#easeInSine
  6583. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6584. */
  6585. export class SineEase extends EasingFunction implements IEasingFunction {
  6586. /** @hidden */
  6587. easeInCore(gradient: number): number;
  6588. }
  6589. /**
  6590. * Easing function with a bezier shape (see link below).
  6591. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6592. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6593. */
  6594. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6595. /** Defines the x component of the start tangent in the bezier curve */
  6596. x1: number;
  6597. /** Defines the y component of the start tangent in the bezier curve */
  6598. y1: number;
  6599. /** Defines the x component of the end tangent in the bezier curve */
  6600. x2: number;
  6601. /** Defines the y component of the end tangent in the bezier curve */
  6602. y2: number;
  6603. /**
  6604. * Instantiates a bezier function
  6605. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6606. * @param x1 Defines the x component of the start tangent in the bezier curve
  6607. * @param y1 Defines the y component of the start tangent in the bezier curve
  6608. * @param x2 Defines the x component of the end tangent in the bezier curve
  6609. * @param y2 Defines the y component of the end tangent in the bezier curve
  6610. */
  6611. constructor(
  6612. /** Defines the x component of the start tangent in the bezier curve */
  6613. x1?: number,
  6614. /** Defines the y component of the start tangent in the bezier curve */
  6615. y1?: number,
  6616. /** Defines the x component of the end tangent in the bezier curve */
  6617. x2?: number,
  6618. /** Defines the y component of the end tangent in the bezier curve */
  6619. y2?: number);
  6620. /** @hidden */
  6621. easeInCore(gradient: number): number;
  6622. }
  6623. }
  6624. declare module "babylonjs/Behaviors/behavior" {
  6625. import { Nullable } from "babylonjs/types";
  6626. /**
  6627. * Interface used to define a behavior
  6628. */
  6629. export interface Behavior<T> {
  6630. /** gets or sets behavior's name */
  6631. name: string;
  6632. /**
  6633. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6634. */
  6635. init(): void;
  6636. /**
  6637. * Called when the behavior is attached to a target
  6638. * @param target defines the target where the behavior is attached to
  6639. */
  6640. attach(target: T): void;
  6641. /**
  6642. * Called when the behavior is detached from its target
  6643. */
  6644. detach(): void;
  6645. }
  6646. /**
  6647. * Interface implemented by classes supporting behaviors
  6648. */
  6649. export interface IBehaviorAware<T> {
  6650. /**
  6651. * Attach a behavior
  6652. * @param behavior defines the behavior to attach
  6653. * @returns the current host
  6654. */
  6655. addBehavior(behavior: Behavior<T>): T;
  6656. /**
  6657. * Remove a behavior from the current object
  6658. * @param behavior defines the behavior to detach
  6659. * @returns the current host
  6660. */
  6661. removeBehavior(behavior: Behavior<T>): T;
  6662. /**
  6663. * Gets a behavior using its name to search
  6664. * @param name defines the name to search
  6665. * @returns the behavior or null if not found
  6666. */
  6667. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6668. }
  6669. }
  6670. declare module "babylonjs/Animations/runtimeAnimation" {
  6671. import { Animation } from "babylonjs/Animations/animation";
  6672. import { Animatable } from "babylonjs/Animations/animatable";
  6673. import { Scene } from "babylonjs/scene";
  6674. /**
  6675. * Defines a runtime animation
  6676. */
  6677. export class RuntimeAnimation {
  6678. private _events;
  6679. /**
  6680. * The current frame of the runtime animation
  6681. */
  6682. private _currentFrame;
  6683. /**
  6684. * The animation used by the runtime animation
  6685. */
  6686. private _animation;
  6687. /**
  6688. * The target of the runtime animation
  6689. */
  6690. private _target;
  6691. /**
  6692. * The initiating animatable
  6693. */
  6694. private _host;
  6695. /**
  6696. * The original value of the runtime animation
  6697. */
  6698. private _originalValue;
  6699. /**
  6700. * The original blend value of the runtime animation
  6701. */
  6702. private _originalBlendValue;
  6703. /**
  6704. * The offsets cache of the runtime animation
  6705. */
  6706. private _offsetsCache;
  6707. /**
  6708. * The high limits cache of the runtime animation
  6709. */
  6710. private _highLimitsCache;
  6711. /**
  6712. * Specifies if the runtime animation has been stopped
  6713. */
  6714. private _stopped;
  6715. /**
  6716. * The blending factor of the runtime animation
  6717. */
  6718. private _blendingFactor;
  6719. /**
  6720. * The BabylonJS scene
  6721. */
  6722. private _scene;
  6723. /**
  6724. * The current value of the runtime animation
  6725. */
  6726. private _currentValue;
  6727. /** @hidden */
  6728. _workValue: any;
  6729. /**
  6730. * The active target of the runtime animation
  6731. */
  6732. private _activeTarget;
  6733. /**
  6734. * The target path of the runtime animation
  6735. */
  6736. private _targetPath;
  6737. /**
  6738. * The weight of the runtime animation
  6739. */
  6740. private _weight;
  6741. /**
  6742. * The ratio offset of the runtime animation
  6743. */
  6744. private _ratioOffset;
  6745. /**
  6746. * The previous delay of the runtime animation
  6747. */
  6748. private _previousDelay;
  6749. /**
  6750. * The previous ratio of the runtime animation
  6751. */
  6752. private _previousRatio;
  6753. /**
  6754. * Gets the current frame of the runtime animation
  6755. */
  6756. readonly currentFrame: number;
  6757. /**
  6758. * Gets the weight of the runtime animation
  6759. */
  6760. readonly weight: number;
  6761. /**
  6762. * Gets the current value of the runtime animation
  6763. */
  6764. readonly currentValue: any;
  6765. /**
  6766. * Gets the target path of the runtime animation
  6767. */
  6768. readonly targetPath: string;
  6769. /**
  6770. * Gets the actual target of the runtime animation
  6771. */
  6772. readonly target: any;
  6773. /**
  6774. * Create a new RuntimeAnimation object
  6775. * @param target defines the target of the animation
  6776. * @param animation defines the source animation object
  6777. * @param scene defines the hosting scene
  6778. * @param host defines the initiating Animatable
  6779. */
  6780. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6781. /**
  6782. * Gets the animation from the runtime animation
  6783. */
  6784. readonly animation: Animation;
  6785. /**
  6786. * Resets the runtime animation to the beginning
  6787. * @param restoreOriginal defines whether to restore the target property to the original value
  6788. */
  6789. reset(restoreOriginal?: boolean): void;
  6790. /**
  6791. * Specifies if the runtime animation is stopped
  6792. * @returns Boolean specifying if the runtime animation is stopped
  6793. */
  6794. isStopped(): boolean;
  6795. /**
  6796. * Disposes of the runtime animation
  6797. */
  6798. dispose(): void;
  6799. /**
  6800. * Interpolates the animation from the current frame
  6801. * @param currentFrame The frame to interpolate the animation to
  6802. * @param repeatCount The number of times that the animation should loop
  6803. * @param loopMode The type of looping mode to use
  6804. * @param offsetValue Animation offset value
  6805. * @param highLimitValue The high limit value
  6806. * @returns The interpolated value
  6807. */
  6808. private _interpolate;
  6809. /**
  6810. * Apply the interpolated value to the target
  6811. * @param currentValue defines the value computed by the animation
  6812. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6813. */
  6814. setValue(currentValue: any, weight?: number): void;
  6815. private _setValue;
  6816. /**
  6817. * Gets the loop pmode of the runtime animation
  6818. * @returns Loop Mode
  6819. */
  6820. private _getCorrectLoopMode;
  6821. /**
  6822. * Move the current animation to a given frame
  6823. * @param frame defines the frame to move to
  6824. */
  6825. goToFrame(frame: number): void;
  6826. /**
  6827. * @hidden Internal use only
  6828. */
  6829. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6830. /**
  6831. * Execute the current animation
  6832. * @param delay defines the delay to add to the current frame
  6833. * @param from defines the lower bound of the animation range
  6834. * @param to defines the upper bound of the animation range
  6835. * @param loop defines if the current animation must loop
  6836. * @param speedRatio defines the current speed ratio
  6837. * @param weight defines the weight of the animation (default is -1 so no weight)
  6838. * @param onLoop optional callback called when animation loops
  6839. * @returns a boolean indicating if the animation is running
  6840. */
  6841. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6842. }
  6843. }
  6844. declare module "babylonjs/Animations/animatable" {
  6845. import { Animation } from "babylonjs/Animations/animation";
  6846. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  6847. import { Nullable } from "babylonjs/types";
  6848. import { Observable } from "babylonjs/Misc/observable";
  6849. import { Scene } from "babylonjs/scene";
  6850. /**
  6851. * Class used to store an actual running animation
  6852. */
  6853. export class Animatable {
  6854. /** defines the target object */
  6855. target: any;
  6856. /** defines the starting frame number (default is 0) */
  6857. fromFrame: number;
  6858. /** defines the ending frame number (default is 100) */
  6859. toFrame: number;
  6860. /** defines if the animation must loop (default is false) */
  6861. loopAnimation: boolean;
  6862. /** defines a callback to call when animation ends if it is not looping */
  6863. onAnimationEnd?: (() => void) | null | undefined;
  6864. /** defines a callback to call when animation loops */
  6865. onAnimationLoop?: (() => void) | null | undefined;
  6866. private _localDelayOffset;
  6867. private _pausedDelay;
  6868. private _runtimeAnimations;
  6869. private _paused;
  6870. private _scene;
  6871. private _speedRatio;
  6872. private _weight;
  6873. private _syncRoot;
  6874. /**
  6875. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  6876. * This will only apply for non looping animation (default is true)
  6877. */
  6878. disposeOnEnd: boolean;
  6879. /**
  6880. * Gets a boolean indicating if the animation has started
  6881. */
  6882. animationStarted: boolean;
  6883. /**
  6884. * Observer raised when the animation ends
  6885. */
  6886. onAnimationEndObservable: Observable<Animatable>;
  6887. /**
  6888. * Observer raised when the animation loops
  6889. */
  6890. onAnimationLoopObservable: Observable<Animatable>;
  6891. /**
  6892. * Gets the root Animatable used to synchronize and normalize animations
  6893. */
  6894. readonly syncRoot: Animatable;
  6895. /**
  6896. * Gets the current frame of the first RuntimeAnimation
  6897. * Used to synchronize Animatables
  6898. */
  6899. readonly masterFrame: number;
  6900. /**
  6901. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  6902. */
  6903. weight: number;
  6904. /**
  6905. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  6906. */
  6907. speedRatio: number;
  6908. /**
  6909. * Creates a new Animatable
  6910. * @param scene defines the hosting scene
  6911. * @param target defines the target object
  6912. * @param fromFrame defines the starting frame number (default is 0)
  6913. * @param toFrame defines the ending frame number (default is 100)
  6914. * @param loopAnimation defines if the animation must loop (default is false)
  6915. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  6916. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  6917. * @param animations defines a group of animation to add to the new Animatable
  6918. * @param onAnimationLoop defines a callback to call when animation loops
  6919. */
  6920. constructor(scene: Scene,
  6921. /** defines the target object */
  6922. target: any,
  6923. /** defines the starting frame number (default is 0) */
  6924. fromFrame?: number,
  6925. /** defines the ending frame number (default is 100) */
  6926. toFrame?: number,
  6927. /** defines if the animation must loop (default is false) */
  6928. loopAnimation?: boolean, speedRatio?: number,
  6929. /** defines a callback to call when animation ends if it is not looping */
  6930. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  6931. /** defines a callback to call when animation loops */
  6932. onAnimationLoop?: (() => void) | null | undefined);
  6933. /**
  6934. * Synchronize and normalize current Animatable with a source Animatable
  6935. * This is useful when using animation weights and when animations are not of the same length
  6936. * @param root defines the root Animatable to synchronize with
  6937. * @returns the current Animatable
  6938. */
  6939. syncWith(root: Animatable): Animatable;
  6940. /**
  6941. * Gets the list of runtime animations
  6942. * @returns an array of RuntimeAnimation
  6943. */
  6944. getAnimations(): RuntimeAnimation[];
  6945. /**
  6946. * Adds more animations to the current animatable
  6947. * @param target defines the target of the animations
  6948. * @param animations defines the new animations to add
  6949. */
  6950. appendAnimations(target: any, animations: Animation[]): void;
  6951. /**
  6952. * Gets the source animation for a specific property
  6953. * @param property defines the propertyu to look for
  6954. * @returns null or the source animation for the given property
  6955. */
  6956. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  6957. /**
  6958. * Gets the runtime animation for a specific property
  6959. * @param property defines the propertyu to look for
  6960. * @returns null or the runtime animation for the given property
  6961. */
  6962. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  6963. /**
  6964. * Resets the animatable to its original state
  6965. */
  6966. reset(): void;
  6967. /**
  6968. * Allows the animatable to blend with current running animations
  6969. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6970. * @param blendingSpeed defines the blending speed to use
  6971. */
  6972. enableBlending(blendingSpeed: number): void;
  6973. /**
  6974. * Disable animation blending
  6975. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6976. */
  6977. disableBlending(): void;
  6978. /**
  6979. * Jump directly to a given frame
  6980. * @param frame defines the frame to jump to
  6981. */
  6982. goToFrame(frame: number): void;
  6983. /**
  6984. * Pause the animation
  6985. */
  6986. pause(): void;
  6987. /**
  6988. * Restart the animation
  6989. */
  6990. restart(): void;
  6991. private _raiseOnAnimationEnd;
  6992. /**
  6993. * Stop and delete the current animation
  6994. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  6995. * @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)
  6996. */
  6997. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  6998. /**
  6999. * Wait asynchronously for the animation to end
  7000. * @returns a promise which will be fullfilled when the animation ends
  7001. */
  7002. waitAsync(): Promise<Animatable>;
  7003. /** @hidden */
  7004. _animate(delay: number): boolean;
  7005. }
  7006. }
  7007. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7008. /**
  7009. * Class used to override all child animations of a given target
  7010. */
  7011. export class AnimationPropertiesOverride {
  7012. /**
  7013. * Gets or sets a value indicating if animation blending must be used
  7014. */
  7015. enableBlending: boolean;
  7016. /**
  7017. * Gets or sets the blending speed to use when enableBlending is true
  7018. */
  7019. blendingSpeed: number;
  7020. /**
  7021. * Gets or sets the default loop mode to use
  7022. */
  7023. loopMode: number;
  7024. }
  7025. }
  7026. declare module "babylonjs/Collisions/collider" {
  7027. import { Nullable, IndicesArray } from "babylonjs/types";
  7028. import { Vector3, Plane } from "babylonjs/Maths/math";
  7029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7030. /** @hidden */
  7031. export class Collider {
  7032. /** Define if a collision was found */
  7033. collisionFound: boolean;
  7034. /**
  7035. * Define last intersection point in local space
  7036. */
  7037. intersectionPoint: Vector3;
  7038. /**
  7039. * Define last collided mesh
  7040. */
  7041. collidedMesh: Nullable<AbstractMesh>;
  7042. private _collisionPoint;
  7043. private _planeIntersectionPoint;
  7044. private _tempVector;
  7045. private _tempVector2;
  7046. private _tempVector3;
  7047. private _tempVector4;
  7048. private _edge;
  7049. private _baseToVertex;
  7050. private _destinationPoint;
  7051. private _slidePlaneNormal;
  7052. private _displacementVector;
  7053. /** @hidden */
  7054. _radius: Vector3;
  7055. /** @hidden */
  7056. _retry: number;
  7057. private _velocity;
  7058. private _basePoint;
  7059. private _epsilon;
  7060. /** @hidden */
  7061. _velocityWorldLength: number;
  7062. /** @hidden */
  7063. _basePointWorld: Vector3;
  7064. private _velocityWorld;
  7065. private _normalizedVelocity;
  7066. /** @hidden */
  7067. _initialVelocity: Vector3;
  7068. /** @hidden */
  7069. _initialPosition: Vector3;
  7070. private _nearestDistance;
  7071. private _collisionMask;
  7072. collisionMask: number;
  7073. /**
  7074. * Gets the plane normal used to compute the sliding response (in local space)
  7075. */
  7076. readonly slidePlaneNormal: Vector3;
  7077. /** @hidden */
  7078. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7079. /** @hidden */
  7080. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7081. /** @hidden */
  7082. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7083. /** @hidden */
  7084. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7085. /** @hidden */
  7086. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7087. /** @hidden */
  7088. _getResponse(pos: Vector3, vel: Vector3): void;
  7089. }
  7090. }
  7091. declare module "babylonjs/Collisions/intersectionInfo" {
  7092. import { Nullable } from "babylonjs/types";
  7093. /**
  7094. * @hidden
  7095. */
  7096. export class IntersectionInfo {
  7097. bu: Nullable<number>;
  7098. bv: Nullable<number>;
  7099. distance: number;
  7100. faceId: number;
  7101. subMeshId: number;
  7102. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7103. }
  7104. }
  7105. declare module "babylonjs/Actions/actionEvent" {
  7106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7107. import { Nullable } from "babylonjs/types";
  7108. import { Sprite } from "babylonjs/Sprites/sprite";
  7109. import { Scene } from "babylonjs/scene";
  7110. import { Vector2 } from "babylonjs/Maths/math";
  7111. /**
  7112. * ActionEvent is the event being sent when an action is triggered.
  7113. */
  7114. export class ActionEvent {
  7115. /** The mesh or sprite that triggered the action */
  7116. source: any;
  7117. /** The X mouse cursor position at the time of the event */
  7118. pointerX: number;
  7119. /** The Y mouse cursor position at the time of the event */
  7120. pointerY: number;
  7121. /** The mesh that is currently pointed at (can be null) */
  7122. meshUnderPointer: Nullable<AbstractMesh>;
  7123. /** the original (browser) event that triggered the ActionEvent */
  7124. sourceEvent?: any;
  7125. /** additional data for the event */
  7126. additionalData?: any;
  7127. /**
  7128. * Creates a new ActionEvent
  7129. * @param source The mesh or sprite that triggered the action
  7130. * @param pointerX The X mouse cursor position at the time of the event
  7131. * @param pointerY The Y mouse cursor position at the time of the event
  7132. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  7133. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  7134. * @param additionalData additional data for the event
  7135. */
  7136. constructor(
  7137. /** The mesh or sprite that triggered the action */
  7138. source: any,
  7139. /** The X mouse cursor position at the time of the event */
  7140. pointerX: number,
  7141. /** The Y mouse cursor position at the time of the event */
  7142. pointerY: number,
  7143. /** The mesh that is currently pointed at (can be null) */
  7144. meshUnderPointer: Nullable<AbstractMesh>,
  7145. /** the original (browser) event that triggered the ActionEvent */
  7146. sourceEvent?: any,
  7147. /** additional data for the event */
  7148. additionalData?: any);
  7149. /**
  7150. * Helper function to auto-create an ActionEvent from a source mesh.
  7151. * @param source The source mesh that triggered the event
  7152. * @param evt The original (browser) event
  7153. * @param additionalData additional data for the event
  7154. * @returns the new ActionEvent
  7155. */
  7156. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  7157. /**
  7158. * Helper function to auto-create an ActionEvent from a source sprite
  7159. * @param source The source sprite that triggered the event
  7160. * @param scene Scene associated with the sprite
  7161. * @param evt The original (browser) event
  7162. * @param additionalData additional data for the event
  7163. * @returns the new ActionEvent
  7164. */
  7165. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  7166. /**
  7167. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  7168. * @param scene the scene where the event occurred
  7169. * @param evt The original (browser) event
  7170. * @returns the new ActionEvent
  7171. */
  7172. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  7173. /**
  7174. * Helper function to auto-create an ActionEvent from a primitive
  7175. * @param prim defines the target primitive
  7176. * @param pointerPos defines the pointer position
  7177. * @param evt The original (browser) event
  7178. * @param additionalData additional data for the event
  7179. * @returns the new ActionEvent
  7180. */
  7181. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  7182. }
  7183. }
  7184. declare module "babylonjs/Culling/boundingSphere" {
  7185. import { DeepImmutable } from "babylonjs/types";
  7186. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7187. /**
  7188. * Class used to store bounding sphere information
  7189. */
  7190. export class BoundingSphere {
  7191. /**
  7192. * Gets the center of the bounding sphere in local space
  7193. */
  7194. readonly center: Vector3;
  7195. /**
  7196. * Radius of the bounding sphere in local space
  7197. */
  7198. radius: number;
  7199. /**
  7200. * Gets the center of the bounding sphere in world space
  7201. */
  7202. readonly centerWorld: Vector3;
  7203. /**
  7204. * Radius of the bounding sphere in world space
  7205. */
  7206. radiusWorld: number;
  7207. /**
  7208. * Gets the minimum vector in local space
  7209. */
  7210. readonly minimum: Vector3;
  7211. /**
  7212. * Gets the maximum vector in local space
  7213. */
  7214. readonly maximum: Vector3;
  7215. private _worldMatrix;
  7216. private static readonly TmpVector3;
  7217. /**
  7218. * Creates a new bounding sphere
  7219. * @param min defines the minimum vector (in local space)
  7220. * @param max defines the maximum vector (in local space)
  7221. * @param worldMatrix defines the new world matrix
  7222. */
  7223. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7224. /**
  7225. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7226. * @param min defines the new minimum vector (in local space)
  7227. * @param max defines the new maximum vector (in local space)
  7228. * @param worldMatrix defines the new world matrix
  7229. */
  7230. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7231. /**
  7232. * Scale the current bounding sphere by applying a scale factor
  7233. * @param factor defines the scale factor to apply
  7234. * @returns the current bounding box
  7235. */
  7236. scale(factor: number): BoundingSphere;
  7237. /**
  7238. * Gets the world matrix of the bounding box
  7239. * @returns a matrix
  7240. */
  7241. getWorldMatrix(): DeepImmutable<Matrix>;
  7242. /** @hidden */
  7243. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7244. /**
  7245. * Tests if the bounding sphere is intersecting the frustum planes
  7246. * @param frustumPlanes defines the frustum planes to test
  7247. * @returns true if there is an intersection
  7248. */
  7249. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7250. /**
  7251. * Tests if the bounding sphere center is in between the frustum planes.
  7252. * Used for optimistic fast inclusion.
  7253. * @param frustumPlanes defines the frustum planes to test
  7254. * @returns true if the sphere center is in between the frustum planes
  7255. */
  7256. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7257. /**
  7258. * Tests if a point is inside the bounding sphere
  7259. * @param point defines the point to test
  7260. * @returns true if the point is inside the bounding sphere
  7261. */
  7262. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7263. /**
  7264. * Checks if two sphere intersct
  7265. * @param sphere0 sphere 0
  7266. * @param sphere1 sphere 1
  7267. * @returns true if the speres intersect
  7268. */
  7269. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7270. }
  7271. }
  7272. declare module "babylonjs/Culling/boundingBox" {
  7273. import { DeepImmutable } from "babylonjs/types";
  7274. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7275. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7276. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7277. /**
  7278. * Class used to store bounding box information
  7279. */
  7280. export class BoundingBox implements ICullable {
  7281. /**
  7282. * Gets the 8 vectors representing the bounding box in local space
  7283. */
  7284. readonly vectors: Vector3[];
  7285. /**
  7286. * Gets the center of the bounding box in local space
  7287. */
  7288. readonly center: Vector3;
  7289. /**
  7290. * Gets the center of the bounding box in world space
  7291. */
  7292. readonly centerWorld: Vector3;
  7293. /**
  7294. * Gets the extend size in local space
  7295. */
  7296. readonly extendSize: Vector3;
  7297. /**
  7298. * Gets the extend size in world space
  7299. */
  7300. readonly extendSizeWorld: Vector3;
  7301. /**
  7302. * Gets the OBB (object bounding box) directions
  7303. */
  7304. readonly directions: Vector3[];
  7305. /**
  7306. * Gets the 8 vectors representing the bounding box in world space
  7307. */
  7308. readonly vectorsWorld: Vector3[];
  7309. /**
  7310. * Gets the minimum vector in world space
  7311. */
  7312. readonly minimumWorld: Vector3;
  7313. /**
  7314. * Gets the maximum vector in world space
  7315. */
  7316. readonly maximumWorld: Vector3;
  7317. /**
  7318. * Gets the minimum vector in local space
  7319. */
  7320. readonly minimum: Vector3;
  7321. /**
  7322. * Gets the maximum vector in local space
  7323. */
  7324. readonly maximum: Vector3;
  7325. private _worldMatrix;
  7326. private static readonly TmpVector3;
  7327. /**
  7328. * @hidden
  7329. */
  7330. _tag: number;
  7331. /**
  7332. * Creates a new bounding box
  7333. * @param min defines the minimum vector (in local space)
  7334. * @param max defines the maximum vector (in local space)
  7335. * @param worldMatrix defines the new world matrix
  7336. */
  7337. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7338. /**
  7339. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7340. * @param min defines the new minimum vector (in local space)
  7341. * @param max defines the new maximum vector (in local space)
  7342. * @param worldMatrix defines the new world matrix
  7343. */
  7344. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7345. /**
  7346. * Scale the current bounding box by applying a scale factor
  7347. * @param factor defines the scale factor to apply
  7348. * @returns the current bounding box
  7349. */
  7350. scale(factor: number): BoundingBox;
  7351. /**
  7352. * Gets the world matrix of the bounding box
  7353. * @returns a matrix
  7354. */
  7355. getWorldMatrix(): DeepImmutable<Matrix>;
  7356. /** @hidden */
  7357. _update(world: DeepImmutable<Matrix>): void;
  7358. /**
  7359. * Tests if the bounding box is intersecting the frustum planes
  7360. * @param frustumPlanes defines the frustum planes to test
  7361. * @returns true if there is an intersection
  7362. */
  7363. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7364. /**
  7365. * Tests if the bounding box is entirely inside the frustum planes
  7366. * @param frustumPlanes defines the frustum planes to test
  7367. * @returns true if there is an inclusion
  7368. */
  7369. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7370. /**
  7371. * Tests if a point is inside the bounding box
  7372. * @param point defines the point to test
  7373. * @returns true if the point is inside the bounding box
  7374. */
  7375. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7376. /**
  7377. * Tests if the bounding box intersects with a bounding sphere
  7378. * @param sphere defines the sphere to test
  7379. * @returns true if there is an intersection
  7380. */
  7381. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7382. /**
  7383. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7384. * @param min defines the min vector to use
  7385. * @param max defines the max vector to use
  7386. * @returns true if there is an intersection
  7387. */
  7388. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7389. /**
  7390. * Tests if two bounding boxes are intersections
  7391. * @param box0 defines the first box to test
  7392. * @param box1 defines the second box to test
  7393. * @returns true if there is an intersection
  7394. */
  7395. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7396. /**
  7397. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7398. * @param minPoint defines the minimum vector of the bounding box
  7399. * @param maxPoint defines the maximum vector of the bounding box
  7400. * @param sphereCenter defines the sphere center
  7401. * @param sphereRadius defines the sphere radius
  7402. * @returns true if there is an intersection
  7403. */
  7404. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7405. /**
  7406. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7407. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7408. * @param frustumPlanes defines the frustum planes to test
  7409. * @return true if there is an inclusion
  7410. */
  7411. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7412. /**
  7413. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7414. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7415. * @param frustumPlanes defines the frustum planes to test
  7416. * @return true if there is an intersection
  7417. */
  7418. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7419. }
  7420. }
  7421. declare module "babylonjs/Culling/boundingInfo" {
  7422. import { DeepImmutable } from "babylonjs/types";
  7423. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7424. import { Collider } from "babylonjs/Collisions/collider";
  7425. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7426. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7427. /**
  7428. * Interface for cullable objects
  7429. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7430. */
  7431. export interface ICullable {
  7432. /**
  7433. * Checks if the object or part of the object is in the frustum
  7434. * @param frustumPlanes Camera near/planes
  7435. * @returns true if the object is in frustum otherwise false
  7436. */
  7437. isInFrustum(frustumPlanes: Plane[]): boolean;
  7438. /**
  7439. * Checks if a cullable object (mesh...) is in the camera frustum
  7440. * Unlike isInFrustum this cheks the full bounding box
  7441. * @param frustumPlanes Camera near/planes
  7442. * @returns true if the object is in frustum otherwise false
  7443. */
  7444. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7445. }
  7446. /**
  7447. * Info for a bounding data of a mesh
  7448. */
  7449. export class BoundingInfo implements ICullable {
  7450. /**
  7451. * Bounding box for the mesh
  7452. */
  7453. readonly boundingBox: BoundingBox;
  7454. /**
  7455. * Bounding sphere for the mesh
  7456. */
  7457. readonly boundingSphere: BoundingSphere;
  7458. private _isLocked;
  7459. private static readonly TmpVector3;
  7460. /**
  7461. * Constructs bounding info
  7462. * @param minimum min vector of the bounding box/sphere
  7463. * @param maximum max vector of the bounding box/sphere
  7464. * @param worldMatrix defines the new world matrix
  7465. */
  7466. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7467. /**
  7468. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7469. * @param min defines the new minimum vector (in local space)
  7470. * @param max defines the new maximum vector (in local space)
  7471. * @param worldMatrix defines the new world matrix
  7472. */
  7473. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7474. /**
  7475. * min vector of the bounding box/sphere
  7476. */
  7477. readonly minimum: Vector3;
  7478. /**
  7479. * max vector of the bounding box/sphere
  7480. */
  7481. readonly maximum: Vector3;
  7482. /**
  7483. * If the info is locked and won't be updated to avoid perf overhead
  7484. */
  7485. isLocked: boolean;
  7486. /**
  7487. * Updates the bounding sphere and box
  7488. * @param world world matrix to be used to update
  7489. */
  7490. update(world: DeepImmutable<Matrix>): void;
  7491. /**
  7492. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7493. * @param center New center of the bounding info
  7494. * @param extend New extend of the bounding info
  7495. * @returns the current bounding info
  7496. */
  7497. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7498. /**
  7499. * Scale the current bounding info by applying a scale factor
  7500. * @param factor defines the scale factor to apply
  7501. * @returns the current bounding info
  7502. */
  7503. scale(factor: number): BoundingInfo;
  7504. /**
  7505. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7506. * @param frustumPlanes defines the frustum to test
  7507. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7508. * @returns true if the bounding info is in the frustum planes
  7509. */
  7510. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7511. /**
  7512. * Gets the world distance between the min and max points of the bounding box
  7513. */
  7514. readonly diagonalLength: number;
  7515. /**
  7516. * Checks if a cullable object (mesh...) is in the camera frustum
  7517. * Unlike isInFrustum this cheks the full bounding box
  7518. * @param frustumPlanes Camera near/planes
  7519. * @returns true if the object is in frustum otherwise false
  7520. */
  7521. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7522. /** @hidden */
  7523. _checkCollision(collider: Collider): boolean;
  7524. /**
  7525. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7526. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7527. * @param point the point to check intersection with
  7528. * @returns if the point intersects
  7529. */
  7530. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7531. /**
  7532. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7533. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7534. * @param boundingInfo the bounding info to check intersection with
  7535. * @param precise if the intersection should be done using OBB
  7536. * @returns if the bounding info intersects
  7537. */
  7538. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7539. }
  7540. }
  7541. declare module "babylonjs/Misc/smartArray" {
  7542. /**
  7543. * Defines an array and its length.
  7544. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7545. */
  7546. export interface ISmartArrayLike<T> {
  7547. /**
  7548. * The data of the array.
  7549. */
  7550. data: Array<T>;
  7551. /**
  7552. * The active length of the array.
  7553. */
  7554. length: number;
  7555. }
  7556. /**
  7557. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7558. */
  7559. export class SmartArray<T> implements ISmartArrayLike<T> {
  7560. /**
  7561. * The full set of data from the array.
  7562. */
  7563. data: Array<T>;
  7564. /**
  7565. * The active length of the array.
  7566. */
  7567. length: number;
  7568. protected _id: number;
  7569. /**
  7570. * Instantiates a Smart Array.
  7571. * @param capacity defines the default capacity of the array.
  7572. */
  7573. constructor(capacity: number);
  7574. /**
  7575. * Pushes a value at the end of the active data.
  7576. * @param value defines the object to push in the array.
  7577. */
  7578. push(value: T): void;
  7579. /**
  7580. * Iterates over the active data and apply the lambda to them.
  7581. * @param func defines the action to apply on each value.
  7582. */
  7583. forEach(func: (content: T) => void): void;
  7584. /**
  7585. * Sorts the full sets of data.
  7586. * @param compareFn defines the comparison function to apply.
  7587. */
  7588. sort(compareFn: (a: T, b: T) => number): void;
  7589. /**
  7590. * Resets the active data to an empty array.
  7591. */
  7592. reset(): void;
  7593. /**
  7594. * Releases all the data from the array as well as the array.
  7595. */
  7596. dispose(): void;
  7597. /**
  7598. * Concats the active data with a given array.
  7599. * @param array defines the data to concatenate with.
  7600. */
  7601. concat(array: any): void;
  7602. /**
  7603. * Returns the position of a value in the active data.
  7604. * @param value defines the value to find the index for
  7605. * @returns the index if found in the active data otherwise -1
  7606. */
  7607. indexOf(value: T): number;
  7608. /**
  7609. * Returns whether an element is part of the active data.
  7610. * @param value defines the value to look for
  7611. * @returns true if found in the active data otherwise false
  7612. */
  7613. contains(value: T): boolean;
  7614. private static _GlobalId;
  7615. }
  7616. /**
  7617. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7618. * The data in this array can only be present once
  7619. */
  7620. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7621. private _duplicateId;
  7622. /**
  7623. * Pushes a value at the end of the active data.
  7624. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7625. * @param value defines the object to push in the array.
  7626. */
  7627. push(value: T): void;
  7628. /**
  7629. * Pushes a value at the end of the active data.
  7630. * If the data is already present, it won t be added again
  7631. * @param value defines the object to push in the array.
  7632. * @returns true if added false if it was already present
  7633. */
  7634. pushNoDuplicate(value: T): boolean;
  7635. /**
  7636. * Resets the active data to an empty array.
  7637. */
  7638. reset(): void;
  7639. /**
  7640. * Concats the active data with a given array.
  7641. * This ensures no dupplicate will be present in the result.
  7642. * @param array defines the data to concatenate with.
  7643. */
  7644. concatWithNoDuplicate(array: any): void;
  7645. }
  7646. }
  7647. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7648. import { Nullable } from "babylonjs/types";
  7649. import { Scene } from "babylonjs/scene";
  7650. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7651. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7652. /**
  7653. * Class for creating a cube texture
  7654. */
  7655. export class CubeTexture extends BaseTexture {
  7656. private _delayedOnLoad;
  7657. /**
  7658. * The url of the texture
  7659. */
  7660. url: string;
  7661. /**
  7662. * Gets or sets the center of the bounding box associated with the cube texture.
  7663. * It must define where the camera used to render the texture was set
  7664. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7665. */
  7666. boundingBoxPosition: Vector3;
  7667. private _boundingBoxSize;
  7668. /**
  7669. * Gets or sets the size of the bounding box associated with the cube texture
  7670. * When defined, the cubemap will switch to local mode
  7671. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7672. * @example https://www.babylonjs-playground.com/#RNASML
  7673. */
  7674. /**
  7675. * Returns the bounding box size
  7676. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7677. */
  7678. boundingBoxSize: Vector3;
  7679. protected _rotationY: number;
  7680. /**
  7681. * Sets texture matrix rotation angle around Y axis in radians.
  7682. */
  7683. /**
  7684. * Gets texture matrix rotation angle around Y axis radians.
  7685. */
  7686. rotationY: number;
  7687. /**
  7688. * Are mip maps generated for this texture or not.
  7689. */
  7690. readonly noMipmap: boolean;
  7691. private _noMipmap;
  7692. private _files;
  7693. private _extensions;
  7694. private _textureMatrix;
  7695. private _format;
  7696. private _createPolynomials;
  7697. /** @hidden */
  7698. _prefiltered: boolean;
  7699. /**
  7700. * Creates a cube texture from an array of image urls
  7701. * @param files defines an array of image urls
  7702. * @param scene defines the hosting scene
  7703. * @param noMipmap specifies if mip maps are not used
  7704. * @returns a cube texture
  7705. */
  7706. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7707. /**
  7708. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7709. * @param url defines the url of the prefiltered texture
  7710. * @param scene defines the scene the texture is attached to
  7711. * @param forcedExtension defines the extension of the file if different from the url
  7712. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7713. * @return the prefiltered texture
  7714. */
  7715. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7716. /**
  7717. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7718. * as prefiltered data.
  7719. * @param rootUrl defines the url of the texture or the root name of the six images
  7720. * @param scene defines the scene the texture is attached to
  7721. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7722. * @param noMipmap defines if mipmaps should be created or not
  7723. * @param files defines the six files to load for the different faces
  7724. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7725. * @param onError defines a callback triggered in case of error during load
  7726. * @param format defines the internal format to use for the texture once loaded
  7727. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7728. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7729. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7730. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7731. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7732. * @return the cube texture
  7733. */
  7734. constructor(rootUrl: string, scene: Scene, 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);
  7735. /**
  7736. * Get the current class name of the texture useful for serialization or dynamic coding.
  7737. * @returns "CubeTexture"
  7738. */
  7739. getClassName(): string;
  7740. /**
  7741. * Update the url (and optional buffer) of this texture if url was null during construction.
  7742. * @param url the url of the texture
  7743. * @param forcedExtension defines the extension to use
  7744. * @param onLoad callback called when the texture is loaded (defaults to null)
  7745. */
  7746. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7747. /**
  7748. * Delays loading of the cube texture
  7749. * @param forcedExtension defines the extension to use
  7750. */
  7751. delayLoad(forcedExtension?: string): void;
  7752. /**
  7753. * Returns the reflection texture matrix
  7754. * @returns the reflection texture matrix
  7755. */
  7756. getReflectionTextureMatrix(): Matrix;
  7757. /**
  7758. * Sets the reflection texture matrix
  7759. * @param value Reflection texture matrix
  7760. */
  7761. setReflectionTextureMatrix(value: Matrix): void;
  7762. /**
  7763. * Parses text to create a cube texture
  7764. * @param parsedTexture define the serialized text to read from
  7765. * @param scene defines the hosting scene
  7766. * @param rootUrl defines the root url of the cube texture
  7767. * @returns a cube texture
  7768. */
  7769. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7770. /**
  7771. * Makes a clone, or deep copy, of the cube texture
  7772. * @returns a new cube texture
  7773. */
  7774. clone(): CubeTexture;
  7775. }
  7776. }
  7777. declare module "babylonjs/Shaders/postprocess.vertex" {
  7778. /** @hidden */
  7779. export var postprocessVertexShader: {
  7780. name: string;
  7781. shader: string;
  7782. };
  7783. }
  7784. declare module "babylonjs/Cameras/targetCamera" {
  7785. import { Nullable } from "babylonjs/types";
  7786. import { Camera } from "babylonjs/Cameras/camera";
  7787. import { Scene } from "babylonjs/scene";
  7788. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7789. /**
  7790. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7791. * This is the base of the follow, arc rotate cameras and Free camera
  7792. * @see http://doc.babylonjs.com/features/cameras
  7793. */
  7794. export class TargetCamera extends Camera {
  7795. private static _RigCamTransformMatrix;
  7796. private static _TargetTransformMatrix;
  7797. private static _TargetFocalPoint;
  7798. /**
  7799. * Define the current direction the camera is moving to
  7800. */
  7801. cameraDirection: Vector3;
  7802. /**
  7803. * Define the current rotation the camera is rotating to
  7804. */
  7805. cameraRotation: Vector2;
  7806. /**
  7807. * When set, the up vector of the camera will be updated by the rotation of the camera
  7808. */
  7809. updateUpVectorFromRotation: boolean;
  7810. private _tmpQuaternion;
  7811. /**
  7812. * Define the current rotation of the camera
  7813. */
  7814. rotation: Vector3;
  7815. /**
  7816. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7817. */
  7818. rotationQuaternion: Quaternion;
  7819. /**
  7820. * Define the current speed of the camera
  7821. */
  7822. speed: number;
  7823. /**
  7824. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7825. * around all axis.
  7826. */
  7827. noRotationConstraint: boolean;
  7828. /**
  7829. * Define the current target of the camera as an object or a position.
  7830. */
  7831. lockedTarget: any;
  7832. /** @hidden */
  7833. _currentTarget: Vector3;
  7834. /** @hidden */
  7835. _initialFocalDistance: number;
  7836. /** @hidden */
  7837. _viewMatrix: Matrix;
  7838. /** @hidden */
  7839. _camMatrix: Matrix;
  7840. /** @hidden */
  7841. _cameraTransformMatrix: Matrix;
  7842. /** @hidden */
  7843. _cameraRotationMatrix: Matrix;
  7844. /** @hidden */
  7845. _referencePoint: Vector3;
  7846. /** @hidden */
  7847. _transformedReferencePoint: Vector3;
  7848. protected _globalCurrentTarget: Vector3;
  7849. protected _globalCurrentUpVector: Vector3;
  7850. /** @hidden */
  7851. _reset: () => void;
  7852. private _defaultUp;
  7853. /**
  7854. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7855. * This is the base of the follow, arc rotate cameras and Free camera
  7856. * @see http://doc.babylonjs.com/features/cameras
  7857. * @param name Defines the name of the camera in the scene
  7858. * @param position Defines the start position of the camera in the scene
  7859. * @param scene Defines the scene the camera belongs to
  7860. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7861. */
  7862. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7863. /**
  7864. * Gets the position in front of the camera at a given distance.
  7865. * @param distance The distance from the camera we want the position to be
  7866. * @returns the position
  7867. */
  7868. getFrontPosition(distance: number): Vector3;
  7869. /** @hidden */
  7870. _getLockedTargetPosition(): Nullable<Vector3>;
  7871. private _storedPosition;
  7872. private _storedRotation;
  7873. private _storedRotationQuaternion;
  7874. /**
  7875. * Store current camera state of the camera (fov, position, rotation, etc..)
  7876. * @returns the camera
  7877. */
  7878. storeState(): Camera;
  7879. /**
  7880. * Restored camera state. You must call storeState() first
  7881. * @returns whether it was successful or not
  7882. * @hidden
  7883. */
  7884. _restoreStateValues(): boolean;
  7885. /** @hidden */
  7886. _initCache(): void;
  7887. /** @hidden */
  7888. _updateCache(ignoreParentClass?: boolean): void;
  7889. /** @hidden */
  7890. _isSynchronizedViewMatrix(): boolean;
  7891. /** @hidden */
  7892. _computeLocalCameraSpeed(): number;
  7893. /** @hidden */
  7894. setTarget(target: Vector3): void;
  7895. /**
  7896. * Return the current target position of the camera. This value is expressed in local space.
  7897. * @returns the target position
  7898. */
  7899. getTarget(): Vector3;
  7900. /** @hidden */
  7901. _decideIfNeedsToMove(): boolean;
  7902. /** @hidden */
  7903. _updatePosition(): void;
  7904. /** @hidden */
  7905. _checkInputs(): void;
  7906. protected _updateCameraRotationMatrix(): void;
  7907. /**
  7908. * 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)
  7909. * @returns the current camera
  7910. */
  7911. private _rotateUpVectorWithCameraRotationMatrix;
  7912. private _cachedRotationZ;
  7913. private _cachedQuaternionRotationZ;
  7914. /** @hidden */
  7915. _getViewMatrix(): Matrix;
  7916. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7917. /**
  7918. * @hidden
  7919. */
  7920. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7921. /**
  7922. * @hidden
  7923. */
  7924. _updateRigCameras(): void;
  7925. private _getRigCamPositionAndTarget;
  7926. /**
  7927. * Gets the current object class name.
  7928. * @return the class name
  7929. */
  7930. getClassName(): string;
  7931. }
  7932. }
  7933. declare module "babylonjs/Cameras/cameraInputsManager" {
  7934. import { Nullable } from "babylonjs/types";
  7935. import { Camera } from "babylonjs/Cameras/camera";
  7936. /**
  7937. * @ignore
  7938. * This is a list of all the different input types that are available in the application.
  7939. * Fo instance: ArcRotateCameraGamepadInput...
  7940. */
  7941. export var CameraInputTypes: {};
  7942. /**
  7943. * This is the contract to implement in order to create a new input class.
  7944. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7945. */
  7946. export interface ICameraInput<TCamera extends Camera> {
  7947. /**
  7948. * Defines the camera the input is attached to.
  7949. */
  7950. camera: Nullable<TCamera>;
  7951. /**
  7952. * Gets the class name of the current intput.
  7953. * @returns the class name
  7954. */
  7955. getClassName(): string;
  7956. /**
  7957. * Get the friendly name associated with the input class.
  7958. * @returns the input friendly name
  7959. */
  7960. getSimpleName(): string;
  7961. /**
  7962. * Attach the input controls to a specific dom element to get the input from.
  7963. * @param element Defines the element the controls should be listened from
  7964. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7965. */
  7966. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7967. /**
  7968. * Detach the current controls from the specified dom element.
  7969. * @param element Defines the element to stop listening the inputs from
  7970. */
  7971. detachControl(element: Nullable<HTMLElement>): void;
  7972. /**
  7973. * Update the current camera state depending on the inputs that have been used this frame.
  7974. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7975. */
  7976. checkInputs?: () => void;
  7977. }
  7978. /**
  7979. * Represents a map of input types to input instance or input index to input instance.
  7980. */
  7981. export interface CameraInputsMap<TCamera extends Camera> {
  7982. /**
  7983. * Accessor to the input by input type.
  7984. */
  7985. [name: string]: ICameraInput<TCamera>;
  7986. /**
  7987. * Accessor to the input by input index.
  7988. */
  7989. [idx: number]: ICameraInput<TCamera>;
  7990. }
  7991. /**
  7992. * This represents the input manager used within a camera.
  7993. * It helps dealing with all the different kind of input attached to a camera.
  7994. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7995. */
  7996. export class CameraInputsManager<TCamera extends Camera> {
  7997. /**
  7998. * Defines the list of inputs attahed to the camera.
  7999. */
  8000. attached: CameraInputsMap<TCamera>;
  8001. /**
  8002. * Defines the dom element the camera is collecting inputs from.
  8003. * This is null if the controls have not been attached.
  8004. */
  8005. attachedElement: Nullable<HTMLElement>;
  8006. /**
  8007. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8008. */
  8009. noPreventDefault: boolean;
  8010. /**
  8011. * Defined the camera the input manager belongs to.
  8012. */
  8013. camera: TCamera;
  8014. /**
  8015. * Update the current camera state depending on the inputs that have been used this frame.
  8016. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8017. */
  8018. checkInputs: () => void;
  8019. /**
  8020. * Instantiate a new Camera Input Manager.
  8021. * @param camera Defines the camera the input manager blongs to
  8022. */
  8023. constructor(camera: TCamera);
  8024. /**
  8025. * Add an input method to a camera
  8026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8027. * @param input camera input method
  8028. */
  8029. add(input: ICameraInput<TCamera>): void;
  8030. /**
  8031. * Remove a specific input method from a camera
  8032. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8033. * @param inputToRemove camera input method
  8034. */
  8035. remove(inputToRemove: ICameraInput<TCamera>): void;
  8036. /**
  8037. * Remove a specific input type from a camera
  8038. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8039. * @param inputType the type of the input to remove
  8040. */
  8041. removeByType(inputType: string): void;
  8042. private _addCheckInputs;
  8043. /**
  8044. * Attach the input controls to the currently attached dom element to listen the events from.
  8045. * @param input Defines the input to attach
  8046. */
  8047. attachInput(input: ICameraInput<TCamera>): void;
  8048. /**
  8049. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8050. * @param element Defines the dom element to collect the events from
  8051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8052. */
  8053. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8054. /**
  8055. * Detach the current manager inputs controls from a specific dom element.
  8056. * @param element Defines the dom element to collect the events from
  8057. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8058. */
  8059. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8060. /**
  8061. * Rebuild the dynamic inputCheck function from the current list of
  8062. * defined inputs in the manager.
  8063. */
  8064. rebuildInputCheck(): void;
  8065. /**
  8066. * Remove all attached input methods from a camera
  8067. */
  8068. clear(): void;
  8069. /**
  8070. * Serialize the current input manager attached to a camera.
  8071. * This ensures than once parsed,
  8072. * the input associated to the camera will be identical to the current ones
  8073. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8074. */
  8075. serialize(serializedCamera: any): void;
  8076. /**
  8077. * Parses an input manager serialized JSON to restore the previous list of inputs
  8078. * and states associated to a camera.
  8079. * @param parsedCamera Defines the JSON to parse
  8080. */
  8081. parse(parsedCamera: any): void;
  8082. }
  8083. }
  8084. declare module "babylonjs/Events/keyboardEvents" {
  8085. /**
  8086. * Gather the list of keyboard event types as constants.
  8087. */
  8088. export class KeyboardEventTypes {
  8089. /**
  8090. * The keydown event is fired when a key becomes active (pressed).
  8091. */
  8092. static readonly KEYDOWN: number;
  8093. /**
  8094. * The keyup event is fired when a key has been released.
  8095. */
  8096. static readonly KEYUP: number;
  8097. }
  8098. /**
  8099. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8100. */
  8101. export class KeyboardInfo {
  8102. /**
  8103. * Defines the type of event (KeyboardEventTypes)
  8104. */
  8105. type: number;
  8106. /**
  8107. * Defines the related dom event
  8108. */
  8109. event: KeyboardEvent;
  8110. /**
  8111. * Instantiates a new keyboard info.
  8112. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8113. * @param type Defines the type of event (KeyboardEventTypes)
  8114. * @param event Defines the related dom event
  8115. */
  8116. constructor(
  8117. /**
  8118. * Defines the type of event (KeyboardEventTypes)
  8119. */
  8120. type: number,
  8121. /**
  8122. * Defines the related dom event
  8123. */
  8124. event: KeyboardEvent);
  8125. }
  8126. /**
  8127. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8128. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8129. */
  8130. export class KeyboardInfoPre extends KeyboardInfo {
  8131. /**
  8132. * Defines the type of event (KeyboardEventTypes)
  8133. */
  8134. type: number;
  8135. /**
  8136. * Defines the related dom event
  8137. */
  8138. event: KeyboardEvent;
  8139. /**
  8140. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8141. */
  8142. skipOnPointerObservable: boolean;
  8143. /**
  8144. * Instantiates a new keyboard pre info.
  8145. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8146. * @param type Defines the type of event (KeyboardEventTypes)
  8147. * @param event Defines the related dom event
  8148. */
  8149. constructor(
  8150. /**
  8151. * Defines the type of event (KeyboardEventTypes)
  8152. */
  8153. type: number,
  8154. /**
  8155. * Defines the related dom event
  8156. */
  8157. event: KeyboardEvent);
  8158. }
  8159. }
  8160. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8161. import { Nullable } from "babylonjs/types";
  8162. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8163. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8164. /**
  8165. * Manage the keyboard inputs to control the movement of a free camera.
  8166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8167. */
  8168. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8169. /**
  8170. * Defines the camera the input is attached to.
  8171. */
  8172. camera: FreeCamera;
  8173. /**
  8174. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8175. */
  8176. keysUp: number[];
  8177. /**
  8178. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8179. */
  8180. keysDown: number[];
  8181. /**
  8182. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8183. */
  8184. keysLeft: number[];
  8185. /**
  8186. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8187. */
  8188. keysRight: number[];
  8189. private _keys;
  8190. private _onCanvasBlurObserver;
  8191. private _onKeyboardObserver;
  8192. private _engine;
  8193. private _scene;
  8194. /**
  8195. * Attach the input controls to a specific dom element to get the input from.
  8196. * @param element Defines the element the controls should be listened from
  8197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8198. */
  8199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8200. /**
  8201. * Detach the current controls from the specified dom element.
  8202. * @param element Defines the element to stop listening the inputs from
  8203. */
  8204. detachControl(element: Nullable<HTMLElement>): void;
  8205. /**
  8206. * Update the current camera state depending on the inputs that have been used this frame.
  8207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8208. */
  8209. checkInputs(): void;
  8210. /**
  8211. * Gets the class name of the current intput.
  8212. * @returns the class name
  8213. */
  8214. getClassName(): string;
  8215. /** @hidden */
  8216. _onLostFocus(): void;
  8217. /**
  8218. * Get the friendly name associated with the input class.
  8219. * @returns the input friendly name
  8220. */
  8221. getSimpleName(): string;
  8222. }
  8223. }
  8224. declare module "babylonjs/Events/pointerEvents" {
  8225. import { Nullable } from "babylonjs/types";
  8226. import { Vector2 } from "babylonjs/Maths/math";
  8227. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  8228. import { Ray } from "babylonjs/Culling/ray";
  8229. /**
  8230. * Gather the list of pointer event types as constants.
  8231. */
  8232. export class PointerEventTypes {
  8233. /**
  8234. * 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.
  8235. */
  8236. static readonly POINTERDOWN: number;
  8237. /**
  8238. * The pointerup event is fired when a pointer is no longer active.
  8239. */
  8240. static readonly POINTERUP: number;
  8241. /**
  8242. * The pointermove event is fired when a pointer changes coordinates.
  8243. */
  8244. static readonly POINTERMOVE: number;
  8245. /**
  8246. * The pointerwheel event is fired when a mouse wheel has been rotated.
  8247. */
  8248. static readonly POINTERWHEEL: number;
  8249. /**
  8250. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  8251. */
  8252. static readonly POINTERPICK: number;
  8253. /**
  8254. * The pointertap event is fired when a the object has been touched and released without drag.
  8255. */
  8256. static readonly POINTERTAP: number;
  8257. /**
  8258. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  8259. */
  8260. static readonly POINTERDOUBLETAP: number;
  8261. }
  8262. /**
  8263. * Base class of pointer info types.
  8264. */
  8265. export class PointerInfoBase {
  8266. /**
  8267. * Defines the type of event (PointerEventTypes)
  8268. */
  8269. type: number;
  8270. /**
  8271. * Defines the related dom event
  8272. */
  8273. event: PointerEvent | MouseWheelEvent;
  8274. /**
  8275. * Instantiates the base class of pointers info.
  8276. * @param type Defines the type of event (PointerEventTypes)
  8277. * @param event Defines the related dom event
  8278. */
  8279. constructor(
  8280. /**
  8281. * Defines the type of event (PointerEventTypes)
  8282. */
  8283. type: number,
  8284. /**
  8285. * Defines the related dom event
  8286. */
  8287. event: PointerEvent | MouseWheelEvent);
  8288. }
  8289. /**
  8290. * This class is used to store pointer related info for the onPrePointerObservable event.
  8291. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8292. */
  8293. export class PointerInfoPre extends PointerInfoBase {
  8294. /**
  8295. * Ray from a pointer if availible (eg. 6dof controller)
  8296. */
  8297. ray: Nullable<Ray>;
  8298. /**
  8299. * Defines the local position of the pointer on the canvas.
  8300. */
  8301. localPosition: Vector2;
  8302. /**
  8303. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  8304. */
  8305. skipOnPointerObservable: boolean;
  8306. /**
  8307. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  8308. * @param type Defines the type of event (PointerEventTypes)
  8309. * @param event Defines the related dom event
  8310. * @param localX Defines the local x coordinates of the pointer when the event occured
  8311. * @param localY Defines the local y coordinates of the pointer when the event occured
  8312. */
  8313. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8314. }
  8315. /**
  8316. * This type contains all the data related to a pointer event in Babylon.js.
  8317. * 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.
  8318. */
  8319. export class PointerInfo extends PointerInfoBase {
  8320. /**
  8321. * Defines the picking info associated to the info (if any)\
  8322. */
  8323. pickInfo: Nullable<PickingInfo>;
  8324. /**
  8325. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  8326. * @param type Defines the type of event (PointerEventTypes)
  8327. * @param event Defines the related dom event
  8328. * @param pickInfo Defines the picking info associated to the info (if any)\
  8329. */
  8330. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  8331. /**
  8332. * Defines the picking info associated to the info (if any)\
  8333. */
  8334. pickInfo: Nullable<PickingInfo>);
  8335. }
  8336. }
  8337. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  8338. import { Nullable } from "babylonjs/types";
  8339. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8340. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8341. /**
  8342. * Manage the mouse inputs to control the movement of a free camera.
  8343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8344. */
  8345. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  8346. /**
  8347. * Define if touch is enabled in the mouse input
  8348. */
  8349. touchEnabled: boolean;
  8350. /**
  8351. * Defines the camera the input is attached to.
  8352. */
  8353. camera: FreeCamera;
  8354. /**
  8355. * Defines the buttons associated with the input to handle camera move.
  8356. */
  8357. buttons: number[];
  8358. /**
  8359. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  8360. */
  8361. angularSensibility: number;
  8362. private _pointerInput;
  8363. private _onMouseMove;
  8364. private _observer;
  8365. private previousPosition;
  8366. /**
  8367. * Manage the mouse inputs to control the movement of a free camera.
  8368. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8369. * @param touchEnabled Defines if touch is enabled or not
  8370. */
  8371. constructor(
  8372. /**
  8373. * Define if touch is enabled in the mouse input
  8374. */
  8375. touchEnabled?: boolean);
  8376. /**
  8377. * Attach the input controls to a specific dom element to get the input from.
  8378. * @param element Defines the element the controls should be listened from
  8379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8380. */
  8381. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8382. /**
  8383. * Detach the current controls from the specified dom element.
  8384. * @param element Defines the element to stop listening the inputs from
  8385. */
  8386. detachControl(element: Nullable<HTMLElement>): void;
  8387. /**
  8388. * Gets the class name of the current intput.
  8389. * @returns the class name
  8390. */
  8391. getClassName(): string;
  8392. /**
  8393. * Get the friendly name associated with the input class.
  8394. * @returns the input friendly name
  8395. */
  8396. getSimpleName(): string;
  8397. }
  8398. }
  8399. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  8400. import { Nullable } from "babylonjs/types";
  8401. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8402. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8403. /**
  8404. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  8405. * Screen rotation is taken into account.
  8406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8407. */
  8408. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  8409. private _camera;
  8410. private _screenOrientationAngle;
  8411. private _constantTranform;
  8412. private _screenQuaternion;
  8413. private _alpha;
  8414. private _beta;
  8415. private _gamma;
  8416. /**
  8417. * Instantiates a new input
  8418. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8419. */
  8420. constructor();
  8421. /**
  8422. * Define the camera controlled by the input.
  8423. */
  8424. camera: FreeCamera;
  8425. /**
  8426. * Attach the input controls to a specific dom element to get the input from.
  8427. * @param element Defines the element the controls should be listened from
  8428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8429. */
  8430. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8431. private _orientationChanged;
  8432. private _deviceOrientation;
  8433. /**
  8434. * Detach the current controls from the specified dom element.
  8435. * @param element Defines the element to stop listening the inputs from
  8436. */
  8437. detachControl(element: Nullable<HTMLElement>): void;
  8438. /**
  8439. * Update the current camera state depending on the inputs that have been used this frame.
  8440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8441. */
  8442. checkInputs(): void;
  8443. /**
  8444. * Gets the class name of the current intput.
  8445. * @returns the class name
  8446. */
  8447. getClassName(): string;
  8448. /**
  8449. * Get the friendly name associated with the input class.
  8450. * @returns the input friendly name
  8451. */
  8452. getSimpleName(): string;
  8453. }
  8454. }
  8455. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  8456. import { Nullable } from "babylonjs/types";
  8457. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8458. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8459. /**
  8460. * Manage the touch inputs to control the movement of a free camera.
  8461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8462. */
  8463. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  8464. /**
  8465. * Defines the camera the input is attached to.
  8466. */
  8467. camera: FreeCamera;
  8468. /**
  8469. * Defines the touch sensibility for rotation.
  8470. * The higher the faster.
  8471. */
  8472. touchAngularSensibility: number;
  8473. /**
  8474. * Defines the touch sensibility for move.
  8475. * The higher the faster.
  8476. */
  8477. touchMoveSensibility: number;
  8478. private _offsetX;
  8479. private _offsetY;
  8480. private _pointerPressed;
  8481. private _pointerInput;
  8482. private _observer;
  8483. private _onLostFocus;
  8484. /**
  8485. * Attach the input controls to a specific dom element to get the input from.
  8486. * @param element Defines the element the controls should be listened from
  8487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8488. */
  8489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8490. /**
  8491. * Detach the current controls from the specified dom element.
  8492. * @param element Defines the element to stop listening the inputs from
  8493. */
  8494. detachControl(element: Nullable<HTMLElement>): void;
  8495. /**
  8496. * Update the current camera state depending on the inputs that have been used this frame.
  8497. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8498. */
  8499. checkInputs(): void;
  8500. /**
  8501. * Gets the class name of the current intput.
  8502. * @returns the class name
  8503. */
  8504. getClassName(): string;
  8505. /**
  8506. * Get the friendly name associated with the input class.
  8507. * @returns the input friendly name
  8508. */
  8509. getSimpleName(): string;
  8510. }
  8511. }
  8512. declare module "babylonjs/Misc/virtualJoystick" {
  8513. import { Nullable } from "babylonjs/types";
  8514. import { Vector3 } from "babylonjs/Maths/math";
  8515. /**
  8516. * Defines the potential axis of a Joystick
  8517. */
  8518. export enum JoystickAxis {
  8519. /** X axis */
  8520. X = 0,
  8521. /** Y axis */
  8522. Y = 1,
  8523. /** Z axis */
  8524. Z = 2
  8525. }
  8526. /**
  8527. * Class used to define virtual joystick (used in touch mode)
  8528. */
  8529. export class VirtualJoystick {
  8530. /**
  8531. * Gets or sets a boolean indicating that left and right values must be inverted
  8532. */
  8533. reverseLeftRight: boolean;
  8534. /**
  8535. * Gets or sets a boolean indicating that up and down values must be inverted
  8536. */
  8537. reverseUpDown: boolean;
  8538. /**
  8539. * Gets the offset value for the position (ie. the change of the position value)
  8540. */
  8541. deltaPosition: Vector3;
  8542. /**
  8543. * Gets a boolean indicating if the virtual joystick was pressed
  8544. */
  8545. pressed: boolean;
  8546. /**
  8547. * Canvas the virtual joystick will render onto, default z-index of this is 5
  8548. */
  8549. static Canvas: Nullable<HTMLCanvasElement>;
  8550. private static _globalJoystickIndex;
  8551. private static vjCanvasContext;
  8552. private static vjCanvasWidth;
  8553. private static vjCanvasHeight;
  8554. private static halfWidth;
  8555. private _action;
  8556. private _axisTargetedByLeftAndRight;
  8557. private _axisTargetedByUpAndDown;
  8558. private _joystickSensibility;
  8559. private _inversedSensibility;
  8560. private _joystickPointerID;
  8561. private _joystickColor;
  8562. private _joystickPointerPos;
  8563. private _joystickPreviousPointerPos;
  8564. private _joystickPointerStartPos;
  8565. private _deltaJoystickVector;
  8566. private _leftJoystick;
  8567. private _touches;
  8568. private _onPointerDownHandlerRef;
  8569. private _onPointerMoveHandlerRef;
  8570. private _onPointerUpHandlerRef;
  8571. private _onResize;
  8572. /**
  8573. * Creates a new virtual joystick
  8574. * @param leftJoystick defines that the joystick is for left hand (false by default)
  8575. */
  8576. constructor(leftJoystick?: boolean);
  8577. /**
  8578. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  8579. * @param newJoystickSensibility defines the new sensibility
  8580. */
  8581. setJoystickSensibility(newJoystickSensibility: number): void;
  8582. private _onPointerDown;
  8583. private _onPointerMove;
  8584. private _onPointerUp;
  8585. /**
  8586. * Change the color of the virtual joystick
  8587. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  8588. */
  8589. setJoystickColor(newColor: string): void;
  8590. /**
  8591. * Defines a callback to call when the joystick is touched
  8592. * @param action defines the callback
  8593. */
  8594. setActionOnTouch(action: () => any): void;
  8595. /**
  8596. * Defines which axis you'd like to control for left & right
  8597. * @param axis defines the axis to use
  8598. */
  8599. setAxisForLeftRight(axis: JoystickAxis): void;
  8600. /**
  8601. * Defines which axis you'd like to control for up & down
  8602. * @param axis defines the axis to use
  8603. */
  8604. setAxisForUpDown(axis: JoystickAxis): void;
  8605. private _drawVirtualJoystick;
  8606. /**
  8607. * Release internal HTML canvas
  8608. */
  8609. releaseCanvas(): void;
  8610. }
  8611. }
  8612. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  8613. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  8614. import { Nullable } from "babylonjs/types";
  8615. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8616. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8617. /**
  8618. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  8619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8620. */
  8621. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  8622. /**
  8623. * Defines the camera the input is attached to.
  8624. */
  8625. camera: FreeCamera;
  8626. private _leftjoystick;
  8627. private _rightjoystick;
  8628. /**
  8629. * Gets the left stick of the virtual joystick.
  8630. * @returns The virtual Joystick
  8631. */
  8632. getLeftJoystick(): VirtualJoystick;
  8633. /**
  8634. * Gets the right stick of the virtual joystick.
  8635. * @returns The virtual Joystick
  8636. */
  8637. getRightJoystick(): VirtualJoystick;
  8638. /**
  8639. * Update the current camera state depending on the inputs that have been used this frame.
  8640. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8641. */
  8642. checkInputs(): void;
  8643. /**
  8644. * Attach the input controls to a specific dom element to get the input from.
  8645. * @param element Defines the element the controls should be listened from
  8646. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8647. */
  8648. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8649. /**
  8650. * Detach the current controls from the specified dom element.
  8651. * @param element Defines the element to stop listening the inputs from
  8652. */
  8653. detachControl(element: Nullable<HTMLElement>): void;
  8654. /**
  8655. * Gets the class name of the current intput.
  8656. * @returns the class name
  8657. */
  8658. getClassName(): string;
  8659. /**
  8660. * Get the friendly name associated with the input class.
  8661. * @returns the input friendly name
  8662. */
  8663. getSimpleName(): string;
  8664. }
  8665. }
  8666. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  8667. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8668. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  8669. /**
  8670. * Default Inputs manager for the FreeCamera.
  8671. * It groups all the default supported inputs for ease of use.
  8672. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8673. */
  8674. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8675. /**
  8676. * Instantiates a new FreeCameraInputsManager.
  8677. * @param camera Defines the camera the inputs belong to
  8678. */
  8679. constructor(camera: FreeCamera);
  8680. /**
  8681. * Add keyboard input support to the input manager.
  8682. * @returns the current input manager
  8683. */
  8684. addKeyboard(): FreeCameraInputsManager;
  8685. /**
  8686. * Add mouse input support to the input manager.
  8687. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8688. * @returns the current input manager
  8689. */
  8690. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8691. /**
  8692. * Add orientation input support to the input manager.
  8693. * @returns the current input manager
  8694. */
  8695. addDeviceOrientation(): FreeCameraInputsManager;
  8696. /**
  8697. * Add touch input support to the input manager.
  8698. * @returns the current input manager
  8699. */
  8700. addTouch(): FreeCameraInputsManager;
  8701. /**
  8702. * Add virtual joystick input support to the input manager.
  8703. * @returns the current input manager
  8704. */
  8705. addVirtualJoystick(): FreeCameraInputsManager;
  8706. }
  8707. }
  8708. declare module "babylonjs/Cameras/freeCamera" {
  8709. import { Vector3 } from "babylonjs/Maths/math";
  8710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8711. import { Scene } from "babylonjs/scene";
  8712. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  8713. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  8714. /**
  8715. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8716. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8717. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8718. */
  8719. export class FreeCamera extends TargetCamera {
  8720. /**
  8721. * Define the collision ellipsoid of the camera.
  8722. * This is helpful to simulate a camera body like the player body around the camera
  8723. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8724. */
  8725. ellipsoid: Vector3;
  8726. /**
  8727. * Define an offset for the position of the ellipsoid around the camera.
  8728. * This can be helpful to determine the center of the body near the gravity center of the body
  8729. * instead of its head.
  8730. */
  8731. ellipsoidOffset: Vector3;
  8732. /**
  8733. * Enable or disable collisions of the camera with the rest of the scene objects.
  8734. */
  8735. checkCollisions: boolean;
  8736. /**
  8737. * Enable or disable gravity on the camera.
  8738. */
  8739. applyGravity: boolean;
  8740. /**
  8741. * Define the input manager associated to the camera.
  8742. */
  8743. inputs: FreeCameraInputsManager;
  8744. /**
  8745. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8746. * Higher values reduce sensitivity.
  8747. */
  8748. /**
  8749. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8750. * Higher values reduce sensitivity.
  8751. */
  8752. angularSensibility: number;
  8753. /**
  8754. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8755. */
  8756. keysUp: number[];
  8757. /**
  8758. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8759. */
  8760. keysDown: number[];
  8761. /**
  8762. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8763. */
  8764. keysLeft: number[];
  8765. /**
  8766. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8767. */
  8768. keysRight: number[];
  8769. /**
  8770. * Event raised when the camera collide with a mesh in the scene.
  8771. */
  8772. onCollide: (collidedMesh: AbstractMesh) => void;
  8773. private _collider;
  8774. private _needMoveForGravity;
  8775. private _oldPosition;
  8776. private _diffPosition;
  8777. private _newPosition;
  8778. /** @hidden */
  8779. _localDirection: Vector3;
  8780. /** @hidden */
  8781. _transformedDirection: Vector3;
  8782. /**
  8783. * Instantiates a Free Camera.
  8784. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8785. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8786. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8787. * @param name Define the name of the camera in the scene
  8788. * @param position Define the start position of the camera in the scene
  8789. * @param scene Define the scene the camera belongs to
  8790. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8791. */
  8792. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8793. /**
  8794. * Attached controls to the current camera.
  8795. * @param element Defines the element the controls should be listened from
  8796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8797. */
  8798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8799. /**
  8800. * Detach the current controls from the camera.
  8801. * The camera will stop reacting to inputs.
  8802. * @param element Defines the element to stop listening the inputs from
  8803. */
  8804. detachControl(element: HTMLElement): void;
  8805. private _collisionMask;
  8806. /**
  8807. * Define a collision mask to limit the list of object the camera can collide with
  8808. */
  8809. collisionMask: number;
  8810. /** @hidden */
  8811. _collideWithWorld(displacement: Vector3): void;
  8812. private _onCollisionPositionChange;
  8813. /** @hidden */
  8814. _checkInputs(): void;
  8815. /** @hidden */
  8816. _decideIfNeedsToMove(): boolean;
  8817. /** @hidden */
  8818. _updatePosition(): void;
  8819. /**
  8820. * Destroy the camera and release the current resources hold by it.
  8821. */
  8822. dispose(): void;
  8823. /**
  8824. * Gets the current object class name.
  8825. * @return the class name
  8826. */
  8827. getClassName(): string;
  8828. }
  8829. }
  8830. declare module "babylonjs/Gamepads/gamepad" {
  8831. import { Observable } from "babylonjs/Misc/observable";
  8832. /**
  8833. * Represents a gamepad control stick position
  8834. */
  8835. export class StickValues {
  8836. /**
  8837. * The x component of the control stick
  8838. */
  8839. x: number;
  8840. /**
  8841. * The y component of the control stick
  8842. */
  8843. y: number;
  8844. /**
  8845. * Initializes the gamepad x and y control stick values
  8846. * @param x The x component of the gamepad control stick value
  8847. * @param y The y component of the gamepad control stick value
  8848. */
  8849. constructor(
  8850. /**
  8851. * The x component of the control stick
  8852. */
  8853. x: number,
  8854. /**
  8855. * The y component of the control stick
  8856. */
  8857. y: number);
  8858. }
  8859. /**
  8860. * An interface which manages callbacks for gamepad button changes
  8861. */
  8862. export interface GamepadButtonChanges {
  8863. /**
  8864. * Called when a gamepad has been changed
  8865. */
  8866. changed: boolean;
  8867. /**
  8868. * Called when a gamepad press event has been triggered
  8869. */
  8870. pressChanged: boolean;
  8871. /**
  8872. * Called when a touch event has been triggered
  8873. */
  8874. touchChanged: boolean;
  8875. /**
  8876. * Called when a value has changed
  8877. */
  8878. valueChanged: boolean;
  8879. }
  8880. /**
  8881. * Represents a gamepad
  8882. */
  8883. export class Gamepad {
  8884. /**
  8885. * The id of the gamepad
  8886. */
  8887. id: string;
  8888. /**
  8889. * The index of the gamepad
  8890. */
  8891. index: number;
  8892. /**
  8893. * The browser gamepad
  8894. */
  8895. browserGamepad: any;
  8896. /**
  8897. * Specifies what type of gamepad this represents
  8898. */
  8899. type: number;
  8900. private _leftStick;
  8901. private _rightStick;
  8902. /** @hidden */
  8903. _isConnected: boolean;
  8904. private _leftStickAxisX;
  8905. private _leftStickAxisY;
  8906. private _rightStickAxisX;
  8907. private _rightStickAxisY;
  8908. /**
  8909. * Triggered when the left control stick has been changed
  8910. */
  8911. private _onleftstickchanged;
  8912. /**
  8913. * Triggered when the right control stick has been changed
  8914. */
  8915. private _onrightstickchanged;
  8916. /**
  8917. * Represents a gamepad controller
  8918. */
  8919. static GAMEPAD: number;
  8920. /**
  8921. * Represents a generic controller
  8922. */
  8923. static GENERIC: number;
  8924. /**
  8925. * Represents an XBox controller
  8926. */
  8927. static XBOX: number;
  8928. /**
  8929. * Represents a pose-enabled controller
  8930. */
  8931. static POSE_ENABLED: number;
  8932. /**
  8933. * Specifies whether the left control stick should be Y-inverted
  8934. */
  8935. protected _invertLeftStickY: boolean;
  8936. /**
  8937. * Specifies if the gamepad has been connected
  8938. */
  8939. readonly isConnected: boolean;
  8940. /**
  8941. * Initializes the gamepad
  8942. * @param id The id of the gamepad
  8943. * @param index The index of the gamepad
  8944. * @param browserGamepad The browser gamepad
  8945. * @param leftStickX The x component of the left joystick
  8946. * @param leftStickY The y component of the left joystick
  8947. * @param rightStickX The x component of the right joystick
  8948. * @param rightStickY The y component of the right joystick
  8949. */
  8950. constructor(
  8951. /**
  8952. * The id of the gamepad
  8953. */
  8954. id: string,
  8955. /**
  8956. * The index of the gamepad
  8957. */
  8958. index: number,
  8959. /**
  8960. * The browser gamepad
  8961. */
  8962. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  8963. /**
  8964. * Callback triggered when the left joystick has changed
  8965. * @param callback
  8966. */
  8967. onleftstickchanged(callback: (values: StickValues) => void): void;
  8968. /**
  8969. * Callback triggered when the right joystick has changed
  8970. * @param callback
  8971. */
  8972. onrightstickchanged(callback: (values: StickValues) => void): void;
  8973. /**
  8974. * Gets the left joystick
  8975. */
  8976. /**
  8977. * Sets the left joystick values
  8978. */
  8979. leftStick: StickValues;
  8980. /**
  8981. * Gets the right joystick
  8982. */
  8983. /**
  8984. * Sets the right joystick value
  8985. */
  8986. rightStick: StickValues;
  8987. /**
  8988. * Updates the gamepad joystick positions
  8989. */
  8990. update(): void;
  8991. /**
  8992. * Disposes the gamepad
  8993. */
  8994. dispose(): void;
  8995. }
  8996. /**
  8997. * Represents a generic gamepad
  8998. */
  8999. export class GenericPad extends Gamepad {
  9000. private _buttons;
  9001. private _onbuttondown;
  9002. private _onbuttonup;
  9003. /**
  9004. * Observable triggered when a button has been pressed
  9005. */
  9006. onButtonDownObservable: Observable<number>;
  9007. /**
  9008. * Observable triggered when a button has been released
  9009. */
  9010. onButtonUpObservable: Observable<number>;
  9011. /**
  9012. * Callback triggered when a button has been pressed
  9013. * @param callback Called when a button has been pressed
  9014. */
  9015. onbuttondown(callback: (buttonPressed: number) => void): void;
  9016. /**
  9017. * Callback triggered when a button has been released
  9018. * @param callback Called when a button has been released
  9019. */
  9020. onbuttonup(callback: (buttonReleased: number) => void): void;
  9021. /**
  9022. * Initializes the generic gamepad
  9023. * @param id The id of the generic gamepad
  9024. * @param index The index of the generic gamepad
  9025. * @param browserGamepad The browser gamepad
  9026. */
  9027. constructor(id: string, index: number, browserGamepad: any);
  9028. private _setButtonValue;
  9029. /**
  9030. * Updates the generic gamepad
  9031. */
  9032. update(): void;
  9033. /**
  9034. * Disposes the generic gamepad
  9035. */
  9036. dispose(): void;
  9037. }
  9038. }
  9039. declare module "babylonjs/Materials/Textures/rawTexture" {
  9040. import { Scene } from "babylonjs/scene";
  9041. import { Texture } from "babylonjs/Materials/Textures/texture";
  9042. /**
  9043. * Raw texture can help creating a texture directly from an array of data.
  9044. * This can be super useful if you either get the data from an uncompressed source or
  9045. * if you wish to create your texture pixel by pixel.
  9046. */
  9047. export class RawTexture extends Texture {
  9048. /**
  9049. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9050. */
  9051. format: number;
  9052. private _engine;
  9053. /**
  9054. * Instantiates a new RawTexture.
  9055. * Raw texture can help creating a texture directly from an array of data.
  9056. * This can be super useful if you either get the data from an uncompressed source or
  9057. * if you wish to create your texture pixel by pixel.
  9058. * @param data define the array of data to use to create the texture
  9059. * @param width define the width of the texture
  9060. * @param height define the height of the texture
  9061. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9062. * @param scene define the scene the texture belongs to
  9063. * @param generateMipMaps define whether mip maps should be generated or not
  9064. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9065. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9066. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9067. */
  9068. constructor(data: ArrayBufferView, width: number, height: number,
  9069. /**
  9070. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9071. */
  9072. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9073. /**
  9074. * Updates the texture underlying data.
  9075. * @param data Define the new data of the texture
  9076. */
  9077. update(data: ArrayBufferView): void;
  9078. /**
  9079. * Creates a luminance texture from some data.
  9080. * @param data Define the texture data
  9081. * @param width Define the width of the texture
  9082. * @param height Define the height of the texture
  9083. * @param scene Define the scene the texture belongs to
  9084. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9085. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9086. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9087. * @returns the luminance texture
  9088. */
  9089. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9090. /**
  9091. * Creates a luminance alpha texture from some data.
  9092. * @param data Define the texture data
  9093. * @param width Define the width of the texture
  9094. * @param height Define the height of the texture
  9095. * @param scene Define the scene the texture belongs to
  9096. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9097. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9098. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9099. * @returns the luminance alpha texture
  9100. */
  9101. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9102. /**
  9103. * Creates an alpha texture from some data.
  9104. * @param data Define the texture data
  9105. * @param width Define the width of the texture
  9106. * @param height Define the height of the texture
  9107. * @param scene Define the scene the texture belongs to
  9108. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9109. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9110. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9111. * @returns the alpha texture
  9112. */
  9113. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9114. /**
  9115. * Creates a RGB texture from some data.
  9116. * @param data Define the texture data
  9117. * @param width Define the width of the texture
  9118. * @param height Define the height of the texture
  9119. * @param scene Define the scene the texture belongs to
  9120. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9121. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9122. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9123. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9124. * @returns the RGB alpha texture
  9125. */
  9126. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9127. /**
  9128. * Creates a RGBA texture from some data.
  9129. * @param data Define the texture data
  9130. * @param width Define the width of the texture
  9131. * @param height Define the height of the texture
  9132. * @param scene Define the scene the texture belongs to
  9133. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9134. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9135. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9136. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9137. * @returns the RGBA texture
  9138. */
  9139. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9140. /**
  9141. * Creates a R texture from some data.
  9142. * @param data Define the texture data
  9143. * @param width Define the width of the texture
  9144. * @param height Define the height of the texture
  9145. * @param scene Define the scene the texture belongs to
  9146. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9147. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9148. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9149. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9150. * @returns the R texture
  9151. */
  9152. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9153. }
  9154. }
  9155. declare module "babylonjs/Bones/skeleton" {
  9156. import { Bone } from "babylonjs/Bones/bone";
  9157. import { IAnimatable } from "babylonjs/Misc/tools";
  9158. import { Observable } from "babylonjs/Misc/observable";
  9159. import { Vector3, Matrix } from "babylonjs/Maths/math";
  9160. import { Scene } from "babylonjs/scene";
  9161. import { Nullable } from "babylonjs/types";
  9162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9163. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  9164. import { Animatable } from "babylonjs/Animations/animatable";
  9165. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  9166. import { AnimationRange, Animation } from "babylonjs/Animations/animation";
  9167. /**
  9168. * Class used to handle skinning animations
  9169. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9170. */
  9171. export class Skeleton implements IAnimatable {
  9172. /** defines the skeleton name */
  9173. name: string;
  9174. /** defines the skeleton Id */
  9175. id: string;
  9176. /**
  9177. * Defines the list of child bones
  9178. */
  9179. bones: Bone[];
  9180. /**
  9181. * Defines an estimate of the dimension of the skeleton at rest
  9182. */
  9183. dimensionsAtRest: Vector3;
  9184. /**
  9185. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  9186. */
  9187. needInitialSkinMatrix: boolean;
  9188. /**
  9189. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  9190. */
  9191. overrideMesh: Nullable<AbstractMesh>;
  9192. /**
  9193. * Gets the list of animations attached to this skeleton
  9194. */
  9195. animations: Array<Animation>;
  9196. private _scene;
  9197. private _isDirty;
  9198. private _transformMatrices;
  9199. private _transformMatrixTexture;
  9200. private _meshesWithPoseMatrix;
  9201. private _animatables;
  9202. private _identity;
  9203. private _synchronizedWithMesh;
  9204. private _ranges;
  9205. private _lastAbsoluteTransformsUpdateId;
  9206. private _canUseTextureForBones;
  9207. /** @hidden */
  9208. _numBonesWithLinkedTransformNode: number;
  9209. /**
  9210. * Specifies if the skeleton should be serialized
  9211. */
  9212. doNotSerialize: boolean;
  9213. /**
  9214. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  9215. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  9216. */
  9217. useTextureToStoreBoneMatrices: boolean;
  9218. private _animationPropertiesOverride;
  9219. /**
  9220. * Gets or sets the animation properties override
  9221. */
  9222. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9223. /**
  9224. * An observable triggered before computing the skeleton's matrices
  9225. */
  9226. onBeforeComputeObservable: Observable<Skeleton>;
  9227. /**
  9228. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  9229. */
  9230. readonly isUsingTextureForMatrices: boolean;
  9231. /**
  9232. * Creates a new skeleton
  9233. * @param name defines the skeleton name
  9234. * @param id defines the skeleton Id
  9235. * @param scene defines the hosting scene
  9236. */
  9237. constructor(
  9238. /** defines the skeleton name */
  9239. name: string,
  9240. /** defines the skeleton Id */
  9241. id: string, scene: Scene);
  9242. /**
  9243. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  9244. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  9245. * @returns a Float32Array containing matrices data
  9246. */
  9247. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  9248. /**
  9249. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  9250. * @returns a raw texture containing the data
  9251. */
  9252. getTransformMatrixTexture(): Nullable<RawTexture>;
  9253. /**
  9254. * Gets the current hosting scene
  9255. * @returns a scene object
  9256. */
  9257. getScene(): Scene;
  9258. /**
  9259. * Gets a string representing the current skeleton data
  9260. * @param fullDetails defines a boolean indicating if we want a verbose version
  9261. * @returns a string representing the current skeleton data
  9262. */
  9263. toString(fullDetails?: boolean): string;
  9264. /**
  9265. * Get bone's index searching by name
  9266. * @param name defines bone's name to search for
  9267. * @return the indice of the bone. Returns -1 if not found
  9268. */
  9269. getBoneIndexByName(name: string): number;
  9270. /**
  9271. * Creater a new animation range
  9272. * @param name defines the name of the range
  9273. * @param from defines the start key
  9274. * @param to defines the end key
  9275. */
  9276. createAnimationRange(name: string, from: number, to: number): void;
  9277. /**
  9278. * Delete a specific animation range
  9279. * @param name defines the name of the range
  9280. * @param deleteFrames defines if frames must be removed as well
  9281. */
  9282. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  9283. /**
  9284. * Gets a specific animation range
  9285. * @param name defines the name of the range to look for
  9286. * @returns the requested animation range or null if not found
  9287. */
  9288. getAnimationRange(name: string): Nullable<AnimationRange>;
  9289. /**
  9290. * Gets the list of all animation ranges defined on this skeleton
  9291. * @returns an array
  9292. */
  9293. getAnimationRanges(): Nullable<AnimationRange>[];
  9294. /**
  9295. * Copy animation range from a source skeleton.
  9296. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  9297. * @param source defines the source skeleton
  9298. * @param name defines the name of the range to copy
  9299. * @param rescaleAsRequired defines if rescaling must be applied if required
  9300. * @returns true if operation was successful
  9301. */
  9302. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  9303. /**
  9304. * Forces the skeleton to go to rest pose
  9305. */
  9306. returnToRest(): void;
  9307. private _getHighestAnimationFrame;
  9308. /**
  9309. * Begin a specific animation range
  9310. * @param name defines the name of the range to start
  9311. * @param loop defines if looping must be turned on (false by default)
  9312. * @param speedRatio defines the speed ratio to apply (1 by default)
  9313. * @param onAnimationEnd defines a callback which will be called when animation will end
  9314. * @returns a new animatable
  9315. */
  9316. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  9317. /** @hidden */
  9318. _markAsDirty(): void;
  9319. /** @hidden */
  9320. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9321. /** @hidden */
  9322. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9323. private _computeTransformMatrices;
  9324. /**
  9325. * Build all resources required to render a skeleton
  9326. */
  9327. prepare(): void;
  9328. /**
  9329. * Gets the list of animatables currently running for this skeleton
  9330. * @returns an array of animatables
  9331. */
  9332. getAnimatables(): IAnimatable[];
  9333. /**
  9334. * Clone the current skeleton
  9335. * @param name defines the name of the new skeleton
  9336. * @param id defines the id of the enw skeleton
  9337. * @returns the new skeleton
  9338. */
  9339. clone(name: string, id: string): Skeleton;
  9340. /**
  9341. * Enable animation blending for this skeleton
  9342. * @param blendingSpeed defines the blending speed to apply
  9343. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9344. */
  9345. enableBlending(blendingSpeed?: number): void;
  9346. /**
  9347. * Releases all resources associated with the current skeleton
  9348. */
  9349. dispose(): void;
  9350. /**
  9351. * Serialize the skeleton in a JSON object
  9352. * @returns a JSON object
  9353. */
  9354. serialize(): any;
  9355. /**
  9356. * Creates a new skeleton from serialized data
  9357. * @param parsedSkeleton defines the serialized data
  9358. * @param scene defines the hosting scene
  9359. * @returns a new skeleton
  9360. */
  9361. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  9362. /**
  9363. * Compute all node absolute transforms
  9364. * @param forceUpdate defines if computation must be done even if cache is up to date
  9365. */
  9366. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  9367. /**
  9368. * Gets the root pose matrix
  9369. * @returns a matrix
  9370. */
  9371. getPoseMatrix(): Nullable<Matrix>;
  9372. /**
  9373. * Sorts bones per internal index
  9374. */
  9375. sortBones(): void;
  9376. private _sortBones;
  9377. }
  9378. }
  9379. declare module "babylonjs/Bones/bone" {
  9380. import { Skeleton } from "babylonjs/Bones/skeleton";
  9381. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  9382. import { Nullable } from "babylonjs/types";
  9383. import { Animation } from "babylonjs/Animations/animation";
  9384. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  9385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9386. import { TransformNode } from "babylonjs/Meshes/transformNode";
  9387. import { Node } from "babylonjs/node";
  9388. /**
  9389. * Class used to store bone information
  9390. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9391. */
  9392. export class Bone extends Node {
  9393. /**
  9394. * defines the bone name
  9395. */
  9396. name: string;
  9397. private static _tmpVecs;
  9398. private static _tmpQuat;
  9399. private static _tmpMats;
  9400. /**
  9401. * Gets the list of child bones
  9402. */
  9403. children: Bone[];
  9404. /** Gets the animations associated with this bone */
  9405. animations: Animation[];
  9406. /**
  9407. * Gets or sets bone length
  9408. */
  9409. length: number;
  9410. /**
  9411. * @hidden Internal only
  9412. * Set this value to map this bone to a different index in the transform matrices
  9413. * Set this value to -1 to exclude the bone from the transform matrices
  9414. */
  9415. _index: Nullable<number>;
  9416. private _skeleton;
  9417. private _localMatrix;
  9418. private _restPose;
  9419. private _baseMatrix;
  9420. private _absoluteTransform;
  9421. private _invertedAbsoluteTransform;
  9422. private _parent;
  9423. private _scalingDeterminant;
  9424. private _worldTransform;
  9425. private _localScaling;
  9426. private _localRotation;
  9427. private _localPosition;
  9428. private _needToDecompose;
  9429. private _needToCompose;
  9430. /** @hidden */
  9431. _linkedTransformNode: Nullable<TransformNode>;
  9432. /** @hidden */
  9433. /** @hidden */
  9434. _matrix: Matrix;
  9435. /**
  9436. * Create a new bone
  9437. * @param name defines the bone name
  9438. * @param skeleton defines the parent skeleton
  9439. * @param parentBone defines the parent (can be null if the bone is the root)
  9440. * @param localMatrix defines the local matrix
  9441. * @param restPose defines the rest pose matrix
  9442. * @param baseMatrix defines the base matrix
  9443. * @param index defines index of the bone in the hiearchy
  9444. */
  9445. constructor(
  9446. /**
  9447. * defines the bone name
  9448. */
  9449. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9450. /**
  9451. * Gets the parent skeleton
  9452. * @returns a skeleton
  9453. */
  9454. getSkeleton(): Skeleton;
  9455. /**
  9456. * Gets parent bone
  9457. * @returns a bone or null if the bone is the root of the bone hierarchy
  9458. */
  9459. getParent(): Nullable<Bone>;
  9460. /**
  9461. * Sets the parent bone
  9462. * @param parent defines the parent (can be null if the bone is the root)
  9463. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9464. */
  9465. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9466. /**
  9467. * Gets the local matrix
  9468. * @returns a matrix
  9469. */
  9470. getLocalMatrix(): Matrix;
  9471. /**
  9472. * Gets the base matrix (initial matrix which remains unchanged)
  9473. * @returns a matrix
  9474. */
  9475. getBaseMatrix(): Matrix;
  9476. /**
  9477. * Gets the rest pose matrix
  9478. * @returns a matrix
  9479. */
  9480. getRestPose(): Matrix;
  9481. /**
  9482. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9483. */
  9484. getWorldMatrix(): Matrix;
  9485. /**
  9486. * Sets the local matrix to rest pose matrix
  9487. */
  9488. returnToRest(): void;
  9489. /**
  9490. * Gets the inverse of the absolute transform matrix.
  9491. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9492. * @returns a matrix
  9493. */
  9494. getInvertedAbsoluteTransform(): Matrix;
  9495. /**
  9496. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9497. * @returns a matrix
  9498. */
  9499. getAbsoluteTransform(): Matrix;
  9500. /**
  9501. * Links with the given transform node.
  9502. * The local matrix of this bone is copied from the transform node every frame.
  9503. * @param transformNode defines the transform node to link to
  9504. */
  9505. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9506. /** Gets or sets current position (in local space) */
  9507. position: Vector3;
  9508. /** Gets or sets current rotation (in local space) */
  9509. rotation: Vector3;
  9510. /** Gets or sets current rotation quaternion (in local space) */
  9511. rotationQuaternion: Quaternion;
  9512. /** Gets or sets current scaling (in local space) */
  9513. scaling: Vector3;
  9514. /**
  9515. * Gets the animation properties override
  9516. */
  9517. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9518. private _decompose;
  9519. private _compose;
  9520. /**
  9521. * Update the base and local matrices
  9522. * @param matrix defines the new base or local matrix
  9523. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9524. * @param updateLocalMatrix defines if the local matrix should be updated
  9525. */
  9526. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9527. /** @hidden */
  9528. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9529. /**
  9530. * Flag the bone as dirty (Forcing it to update everything)
  9531. */
  9532. markAsDirty(): void;
  9533. private _markAsDirtyAndCompose;
  9534. private _markAsDirtyAndDecompose;
  9535. /**
  9536. * Copy an animation range from another bone
  9537. * @param source defines the source bone
  9538. * @param rangeName defines the range name to copy
  9539. * @param frameOffset defines the frame offset
  9540. * @param rescaleAsRequired defines if rescaling must be applied if required
  9541. * @param skelDimensionsRatio defines the scaling ratio
  9542. * @returns true if operation was successful
  9543. */
  9544. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  9545. /**
  9546. * Translate the bone in local or world space
  9547. * @param vec The amount to translate the bone
  9548. * @param space The space that the translation is in
  9549. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9550. */
  9551. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9552. /**
  9553. * Set the postion of the bone in local or world space
  9554. * @param position The position to set the bone
  9555. * @param space The space that the position is in
  9556. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9557. */
  9558. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9559. /**
  9560. * Set the absolute position of the bone (world space)
  9561. * @param position The position to set the bone
  9562. * @param mesh The mesh that this bone is attached to
  9563. */
  9564. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9565. /**
  9566. * Scale the bone on the x, y and z axes (in local space)
  9567. * @param x The amount to scale the bone on the x axis
  9568. * @param y The amount to scale the bone on the y axis
  9569. * @param z The amount to scale the bone on the z axis
  9570. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9571. */
  9572. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9573. /**
  9574. * Set the bone scaling in local space
  9575. * @param scale defines the scaling vector
  9576. */
  9577. setScale(scale: Vector3): void;
  9578. /**
  9579. * Gets the current scaling in local space
  9580. * @returns the current scaling vector
  9581. */
  9582. getScale(): Vector3;
  9583. /**
  9584. * Gets the current scaling in local space and stores it in a target vector
  9585. * @param result defines the target vector
  9586. */
  9587. getScaleToRef(result: Vector3): void;
  9588. /**
  9589. * Set the yaw, pitch, and roll of the bone in local or world space
  9590. * @param yaw The rotation of the bone on the y axis
  9591. * @param pitch The rotation of the bone on the x axis
  9592. * @param roll The rotation of the bone on the z axis
  9593. * @param space The space that the axes of rotation are in
  9594. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9595. */
  9596. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9597. /**
  9598. * Add a rotation to the bone on an axis in local or world space
  9599. * @param axis The axis to rotate the bone on
  9600. * @param amount The amount to rotate the bone
  9601. * @param space The space that the axis is in
  9602. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9603. */
  9604. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9605. /**
  9606. * Set the rotation of the bone to a particular axis angle in local or world space
  9607. * @param axis The axis to rotate the bone on
  9608. * @param angle The angle that the bone should be rotated to
  9609. * @param space The space that the axis is in
  9610. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9611. */
  9612. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9613. /**
  9614. * Set the euler rotation of the bone in local of world space
  9615. * @param rotation The euler rotation that the bone should be set to
  9616. * @param space The space that the rotation is in
  9617. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9618. */
  9619. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9620. /**
  9621. * Set the quaternion rotation of the bone in local of world space
  9622. * @param quat The quaternion rotation that the bone should be set to
  9623. * @param space The space that the rotation is in
  9624. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9625. */
  9626. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9627. /**
  9628. * Set the rotation matrix of the bone in local of world space
  9629. * @param rotMat The rotation matrix that the bone should be set to
  9630. * @param space The space that the rotation is in
  9631. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9632. */
  9633. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9634. private _rotateWithMatrix;
  9635. private _getNegativeRotationToRef;
  9636. /**
  9637. * Get the position of the bone in local or world space
  9638. * @param space The space that the returned position is in
  9639. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9640. * @returns The position of the bone
  9641. */
  9642. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9643. /**
  9644. * Copy the position of the bone to a vector3 in local or world space
  9645. * @param space The space that the returned position is in
  9646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9647. * @param result The vector3 to copy the position to
  9648. */
  9649. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9650. /**
  9651. * Get the absolute position of the bone (world space)
  9652. * @param mesh The mesh that this bone is attached to
  9653. * @returns The absolute position of the bone
  9654. */
  9655. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9656. /**
  9657. * Copy the absolute position of the bone (world space) to the result param
  9658. * @param mesh The mesh that this bone is attached to
  9659. * @param result The vector3 to copy the absolute position to
  9660. */
  9661. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9662. /**
  9663. * Compute the absolute transforms of this bone and its children
  9664. */
  9665. computeAbsoluteTransforms(): void;
  9666. /**
  9667. * Get the world direction from an axis that is in the local space of the bone
  9668. * @param localAxis The local direction that is used to compute the world direction
  9669. * @param mesh The mesh that this bone is attached to
  9670. * @returns The world direction
  9671. */
  9672. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9673. /**
  9674. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9675. * @param localAxis The local direction that is used to compute the world direction
  9676. * @param mesh The mesh that this bone is attached to
  9677. * @param result The vector3 that the world direction will be copied to
  9678. */
  9679. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9680. /**
  9681. * Get the euler rotation of the bone in local or world space
  9682. * @param space The space that the rotation should be in
  9683. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9684. * @returns The euler rotation
  9685. */
  9686. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9687. /**
  9688. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9689. * @param space The space that the rotation should be in
  9690. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9691. * @param result The vector3 that the rotation should be copied to
  9692. */
  9693. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9694. /**
  9695. * Get the quaternion rotation of the bone in either local or world space
  9696. * @param space The space that the rotation should be in
  9697. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9698. * @returns The quaternion rotation
  9699. */
  9700. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9701. /**
  9702. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9703. * @param space The space that the rotation should be in
  9704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9705. * @param result The quaternion that the rotation should be copied to
  9706. */
  9707. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9708. /**
  9709. * Get the rotation matrix of the bone in local or world space
  9710. * @param space The space that the rotation should be in
  9711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9712. * @returns The rotation matrix
  9713. */
  9714. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9715. /**
  9716. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9717. * @param space The space that the rotation should be in
  9718. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9719. * @param result The quaternion that the rotation should be copied to
  9720. */
  9721. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9722. /**
  9723. * Get the world position of a point that is in the local space of the bone
  9724. * @param position The local position
  9725. * @param mesh The mesh that this bone is attached to
  9726. * @returns The world position
  9727. */
  9728. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9729. /**
  9730. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9731. * @param position The local position
  9732. * @param mesh The mesh that this bone is attached to
  9733. * @param result The vector3 that the world position should be copied to
  9734. */
  9735. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9736. /**
  9737. * Get the local position of a point that is in world space
  9738. * @param position The world position
  9739. * @param mesh The mesh that this bone is attached to
  9740. * @returns The local position
  9741. */
  9742. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9743. /**
  9744. * Get the local position of a point that is in world space and copy it to the result param
  9745. * @param position The world position
  9746. * @param mesh The mesh that this bone is attached to
  9747. * @param result The vector3 that the local position should be copied to
  9748. */
  9749. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9750. }
  9751. }
  9752. declare module "babylonjs/Meshes/transformNode" {
  9753. import { DeepImmutable } from "babylonjs/types";
  9754. import { Observable } from "babylonjs/Misc/observable";
  9755. import { Nullable } from "babylonjs/types";
  9756. import { Camera } from "babylonjs/Cameras/camera";
  9757. import { Scene } from "babylonjs/scene";
  9758. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  9759. import { Node } from "babylonjs/node";
  9760. import { Bone } from "babylonjs/Bones/bone";
  9761. /**
  9762. * 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.
  9763. * @see https://doc.babylonjs.com/how_to/transformnode
  9764. */
  9765. export class TransformNode extends Node {
  9766. /**
  9767. * Object will not rotate to face the camera
  9768. */
  9769. static BILLBOARDMODE_NONE: number;
  9770. /**
  9771. * Object will rotate to face the camera but only on the x axis
  9772. */
  9773. static BILLBOARDMODE_X: number;
  9774. /**
  9775. * Object will rotate to face the camera but only on the y axis
  9776. */
  9777. static BILLBOARDMODE_Y: number;
  9778. /**
  9779. * Object will rotate to face the camera but only on the z axis
  9780. */
  9781. static BILLBOARDMODE_Z: number;
  9782. /**
  9783. * Object will rotate to face the camera
  9784. */
  9785. static BILLBOARDMODE_ALL: number;
  9786. private _forward;
  9787. private _forwardInverted;
  9788. private _up;
  9789. private _right;
  9790. private _rightInverted;
  9791. private _position;
  9792. private _rotation;
  9793. private _rotationQuaternion;
  9794. protected _scaling: Vector3;
  9795. protected _isDirty: boolean;
  9796. private _transformToBoneReferal;
  9797. /**
  9798. * Set the billboard mode. Default is 0.
  9799. *
  9800. * | Value | Type | Description |
  9801. * | --- | --- | --- |
  9802. * | 0 | BILLBOARDMODE_NONE | |
  9803. * | 1 | BILLBOARDMODE_X | |
  9804. * | 2 | BILLBOARDMODE_Y | |
  9805. * | 4 | BILLBOARDMODE_Z | |
  9806. * | 7 | BILLBOARDMODE_ALL | |
  9807. *
  9808. */
  9809. billboardMode: number;
  9810. /**
  9811. * 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
  9812. */
  9813. scalingDeterminant: number;
  9814. /**
  9815. * Sets the distance of the object to max, often used by skybox
  9816. */
  9817. infiniteDistance: boolean;
  9818. /**
  9819. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  9820. * By default the system will update normals to compensate
  9821. */
  9822. ignoreNonUniformScaling: boolean;
  9823. /** @hidden */
  9824. _poseMatrix: Matrix;
  9825. /** @hidden */
  9826. _localMatrix: Matrix;
  9827. private _absolutePosition;
  9828. private _pivotMatrix;
  9829. private _pivotMatrixInverse;
  9830. protected _postMultiplyPivotMatrix: boolean;
  9831. protected _isWorldMatrixFrozen: boolean;
  9832. /** @hidden */
  9833. _indexInSceneTransformNodesArray: number;
  9834. /**
  9835. * An event triggered after the world matrix is updated
  9836. */
  9837. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  9838. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  9839. /**
  9840. * Gets a string identifying the name of the class
  9841. * @returns "TransformNode" string
  9842. */
  9843. getClassName(): string;
  9844. /**
  9845. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  9846. */
  9847. position: Vector3;
  9848. /**
  9849. * 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)).
  9850. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  9851. */
  9852. rotation: Vector3;
  9853. /**
  9854. * 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)).
  9855. */
  9856. scaling: Vector3;
  9857. /**
  9858. * 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).
  9859. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  9860. */
  9861. rotationQuaternion: Nullable<Quaternion>;
  9862. /**
  9863. * The forward direction of that transform in world space.
  9864. */
  9865. readonly forward: Vector3;
  9866. /**
  9867. * The up direction of that transform in world space.
  9868. */
  9869. readonly up: Vector3;
  9870. /**
  9871. * The right direction of that transform in world space.
  9872. */
  9873. readonly right: Vector3;
  9874. /**
  9875. * Copies the parameter passed Matrix into the mesh Pose matrix.
  9876. * @param matrix the matrix to copy the pose from
  9877. * @returns this TransformNode.
  9878. */
  9879. updatePoseMatrix(matrix: Matrix): TransformNode;
  9880. /**
  9881. * Returns the mesh Pose matrix.
  9882. * @returns the pose matrix
  9883. */
  9884. getPoseMatrix(): Matrix;
  9885. /** @hidden */
  9886. _isSynchronized(): boolean;
  9887. /** @hidden */
  9888. _initCache(): void;
  9889. /**
  9890. * Flag the transform node as dirty (Forcing it to update everything)
  9891. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  9892. * @returns this transform node
  9893. */
  9894. markAsDirty(property: string): TransformNode;
  9895. /**
  9896. * Returns the current mesh absolute position.
  9897. * Returns a Vector3.
  9898. */
  9899. readonly absolutePosition: Vector3;
  9900. /**
  9901. * Sets a new matrix to apply before all other transformation
  9902. * @param matrix defines the transform matrix
  9903. * @returns the current TransformNode
  9904. */
  9905. setPreTransformMatrix(matrix: Matrix): TransformNode;
  9906. /**
  9907. * Sets a new pivot matrix to the current node
  9908. * @param matrix defines the new pivot matrix to use
  9909. * @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
  9910. * @returns the current TransformNode
  9911. */
  9912. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  9913. /**
  9914. * Returns the mesh pivot matrix.
  9915. * Default : Identity.
  9916. * @returns the matrix
  9917. */
  9918. getPivotMatrix(): Matrix;
  9919. /**
  9920. * Prevents the World matrix to be computed any longer.
  9921. * @returns the TransformNode.
  9922. */
  9923. freezeWorldMatrix(): TransformNode;
  9924. /**
  9925. * Allows back the World matrix computation.
  9926. * @returns the TransformNode.
  9927. */
  9928. unfreezeWorldMatrix(): this;
  9929. /**
  9930. * True if the World matrix has been frozen.
  9931. */
  9932. readonly isWorldMatrixFrozen: boolean;
  9933. /**
  9934. * Retuns the mesh absolute position in the World.
  9935. * @returns a Vector3.
  9936. */
  9937. getAbsolutePosition(): Vector3;
  9938. /**
  9939. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  9940. * @param absolutePosition the absolute position to set
  9941. * @returns the TransformNode.
  9942. */
  9943. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  9944. /**
  9945. * Sets the mesh position in its local space.
  9946. * @param vector3 the position to set in localspace
  9947. * @returns the TransformNode.
  9948. */
  9949. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  9950. /**
  9951. * Returns the mesh position in the local space from the current World matrix values.
  9952. * @returns a new Vector3.
  9953. */
  9954. getPositionExpressedInLocalSpace(): Vector3;
  9955. /**
  9956. * Translates the mesh along the passed Vector3 in its local space.
  9957. * @param vector3 the distance to translate in localspace
  9958. * @returns the TransformNode.
  9959. */
  9960. locallyTranslate(vector3: Vector3): TransformNode;
  9961. private static _lookAtVectorCache;
  9962. /**
  9963. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  9964. * @param targetPoint the position (must be in same space as current mesh) to look at
  9965. * @param yawCor optional yaw (y-axis) correction in radians
  9966. * @param pitchCor optional pitch (x-axis) correction in radians
  9967. * @param rollCor optional roll (z-axis) correction in radians
  9968. * @param space the choosen space of the target
  9969. * @returns the TransformNode.
  9970. */
  9971. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  9972. /**
  9973. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9974. * This Vector3 is expressed in the World space.
  9975. * @param localAxis axis to rotate
  9976. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9977. */
  9978. getDirection(localAxis: Vector3): Vector3;
  9979. /**
  9980. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  9981. * localAxis is expressed in the mesh local space.
  9982. * result is computed in the Wordl space from the mesh World matrix.
  9983. * @param localAxis axis to rotate
  9984. * @param result the resulting transformnode
  9985. * @returns this TransformNode.
  9986. */
  9987. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  9988. /**
  9989. * Sets this transform node rotation to the given local axis.
  9990. * @param localAxis the axis in local space
  9991. * @param yawCor optional yaw (y-axis) correction in radians
  9992. * @param pitchCor optional pitch (x-axis) correction in radians
  9993. * @param rollCor optional roll (z-axis) correction in radians
  9994. * @returns this TransformNode
  9995. */
  9996. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  9997. /**
  9998. * Sets a new pivot point to the current node
  9999. * @param point defines the new pivot point to use
  10000. * @param space defines if the point is in world or local space (local by default)
  10001. * @returns the current TransformNode
  10002. */
  10003. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  10004. /**
  10005. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  10006. * @returns the pivot point
  10007. */
  10008. getPivotPoint(): Vector3;
  10009. /**
  10010. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  10011. * @param result the vector3 to store the result
  10012. * @returns this TransformNode.
  10013. */
  10014. getPivotPointToRef(result: Vector3): TransformNode;
  10015. /**
  10016. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  10017. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  10018. */
  10019. getAbsolutePivotPoint(): Vector3;
  10020. /**
  10021. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  10022. * @param result vector3 to store the result
  10023. * @returns this TransformNode.
  10024. */
  10025. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  10026. /**
  10027. * Defines the passed node as the parent of the current node.
  10028. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  10029. * @param node the node ot set as the parent
  10030. * @returns this TransformNode.
  10031. */
  10032. setParent(node: Nullable<Node>): TransformNode;
  10033. private _nonUniformScaling;
  10034. /**
  10035. * True if the scaling property of this object is non uniform eg. (1,2,1)
  10036. */
  10037. readonly nonUniformScaling: boolean;
  10038. /** @hidden */
  10039. _updateNonUniformScalingState(value: boolean): boolean;
  10040. /**
  10041. * Attach the current TransformNode to another TransformNode associated with a bone
  10042. * @param bone Bone affecting the TransformNode
  10043. * @param affectedTransformNode TransformNode associated with the bone
  10044. * @returns this object
  10045. */
  10046. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  10047. /**
  10048. * Detach the transform node if its associated with a bone
  10049. * @returns this object
  10050. */
  10051. detachFromBone(): TransformNode;
  10052. private static _rotationAxisCache;
  10053. /**
  10054. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  10055. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  10056. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  10057. * The passed axis is also normalized.
  10058. * @param axis the axis to rotate around
  10059. * @param amount the amount to rotate in radians
  10060. * @param space Space to rotate in (Default: local)
  10061. * @returns the TransformNode.
  10062. */
  10063. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  10064. /**
  10065. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  10066. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  10067. * The passed axis is also normalized. .
  10068. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  10069. * @param point the point to rotate around
  10070. * @param axis the axis to rotate around
  10071. * @param amount the amount to rotate in radians
  10072. * @returns the TransformNode
  10073. */
  10074. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  10075. /**
  10076. * Translates the mesh along the axis vector for the passed distance in the given space.
  10077. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  10078. * @param axis the axis to translate in
  10079. * @param distance the distance to translate
  10080. * @param space Space to rotate in (Default: local)
  10081. * @returns the TransformNode.
  10082. */
  10083. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  10084. /**
  10085. * Adds a rotation step to the mesh current rotation.
  10086. * x, y, z are Euler angles expressed in radians.
  10087. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  10088. * This means this rotation is made in the mesh local space only.
  10089. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  10090. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  10091. * ```javascript
  10092. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  10093. * ```
  10094. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  10095. * 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.
  10096. * @param x Rotation to add
  10097. * @param y Rotation to add
  10098. * @param z Rotation to add
  10099. * @returns the TransformNode.
  10100. */
  10101. addRotation(x: number, y: number, z: number): TransformNode;
  10102. /**
  10103. * Computes the world matrix of the node
  10104. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10105. * @returns the world matrix
  10106. */
  10107. computeWorldMatrix(force?: boolean): Matrix;
  10108. protected _afterComputeWorldMatrix(): void;
  10109. /**
  10110. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  10111. * @param func callback function to add
  10112. *
  10113. * @returns the TransformNode.
  10114. */
  10115. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  10116. /**
  10117. * Removes a registered callback function.
  10118. * @param func callback function to remove
  10119. * @returns the TransformNode.
  10120. */
  10121. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  10122. /**
  10123. * Gets the position of the current mesh in camera space
  10124. * @param camera defines the camera to use
  10125. * @returns a position
  10126. */
  10127. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  10128. /**
  10129. * Returns the distance from the mesh to the active camera
  10130. * @param camera defines the camera to use
  10131. * @returns the distance
  10132. */
  10133. getDistanceToCamera(camera?: Nullable<Camera>): number;
  10134. /**
  10135. * Clone the current transform node
  10136. * @param name Name of the new clone
  10137. * @param newParent New parent for the clone
  10138. * @param doNotCloneChildren Do not clone children hierarchy
  10139. * @returns the new transform node
  10140. */
  10141. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  10142. /**
  10143. * Serializes the objects information.
  10144. * @param currentSerializationObject defines the object to serialize in
  10145. * @returns the serialized object
  10146. */
  10147. serialize(currentSerializationObject?: any): any;
  10148. /**
  10149. * Returns a new TransformNode object parsed from the source provided.
  10150. * @param parsedTransformNode is the source.
  10151. * @param scene the scne the object belongs to
  10152. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  10153. * @returns a new TransformNode object parsed from the source provided.
  10154. */
  10155. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  10156. /**
  10157. * Get all child-transformNodes of this node
  10158. * @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
  10159. * @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
  10160. * @returns an array of TransformNode
  10161. */
  10162. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  10163. /**
  10164. * Releases resources associated with this transform node.
  10165. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10166. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10167. */
  10168. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10169. }
  10170. }
  10171. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  10172. import { Observable } from "babylonjs/Misc/observable";
  10173. import { Nullable } from "babylonjs/types";
  10174. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  10175. import { TransformNode } from "babylonjs/Meshes/transformNode";
  10176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10177. import { Ray } from "babylonjs/Culling/ray";
  10178. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  10179. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  10180. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  10181. /**
  10182. * Defines the types of pose enabled controllers that are supported
  10183. */
  10184. export enum PoseEnabledControllerType {
  10185. /**
  10186. * HTC Vive
  10187. */
  10188. VIVE = 0,
  10189. /**
  10190. * Oculus Rift
  10191. */
  10192. OCULUS = 1,
  10193. /**
  10194. * Windows mixed reality
  10195. */
  10196. WINDOWS = 2,
  10197. /**
  10198. * Samsung gear VR
  10199. */
  10200. GEAR_VR = 3,
  10201. /**
  10202. * Google Daydream
  10203. */
  10204. DAYDREAM = 4,
  10205. /**
  10206. * Generic
  10207. */
  10208. GENERIC = 5
  10209. }
  10210. /**
  10211. * Defines the MutableGamepadButton interface for the state of a gamepad button
  10212. */
  10213. export interface MutableGamepadButton {
  10214. /**
  10215. * Value of the button/trigger
  10216. */
  10217. value: number;
  10218. /**
  10219. * If the button/trigger is currently touched
  10220. */
  10221. touched: boolean;
  10222. /**
  10223. * If the button/trigger is currently pressed
  10224. */
  10225. pressed: boolean;
  10226. }
  10227. /**
  10228. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  10229. * @hidden
  10230. */
  10231. export interface ExtendedGamepadButton extends GamepadButton {
  10232. /**
  10233. * If the button/trigger is currently pressed
  10234. */
  10235. readonly pressed: boolean;
  10236. /**
  10237. * If the button/trigger is currently touched
  10238. */
  10239. readonly touched: boolean;
  10240. /**
  10241. * Value of the button/trigger
  10242. */
  10243. readonly value: number;
  10244. }
  10245. /** @hidden */
  10246. export interface _GamePadFactory {
  10247. /**
  10248. * Returns wether or not the current gamepad can be created for this type of controller.
  10249. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  10250. * @returns true if it can be created, otherwise false
  10251. */
  10252. canCreate(gamepadInfo: any): boolean;
  10253. /**
  10254. * Creates a new instance of the Gamepad.
  10255. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  10256. * @returns the new gamepad instance
  10257. */
  10258. create(gamepadInfo: any): Gamepad;
  10259. }
  10260. /**
  10261. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  10262. */
  10263. export class PoseEnabledControllerHelper {
  10264. /** @hidden */
  10265. static _ControllerFactories: _GamePadFactory[];
  10266. /** @hidden */
  10267. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  10268. /**
  10269. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  10270. * @param vrGamepad the gamepad to initialized
  10271. * @returns a vr controller of the type the gamepad identified as
  10272. */
  10273. static InitiateController(vrGamepad: any): Gamepad;
  10274. }
  10275. /**
  10276. * Defines the PoseEnabledController object that contains state of a vr capable controller
  10277. */
  10278. export class PoseEnabledController extends Gamepad implements PoseControlled {
  10279. private _deviceRoomPosition;
  10280. private _deviceRoomRotationQuaternion;
  10281. /**
  10282. * The device position in babylon space
  10283. */
  10284. devicePosition: Vector3;
  10285. /**
  10286. * The device rotation in babylon space
  10287. */
  10288. deviceRotationQuaternion: Quaternion;
  10289. /**
  10290. * The scale factor of the device in babylon space
  10291. */
  10292. deviceScaleFactor: number;
  10293. /**
  10294. * (Likely devicePosition should be used instead) The device position in its room space
  10295. */
  10296. position: Vector3;
  10297. /**
  10298. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  10299. */
  10300. rotationQuaternion: Quaternion;
  10301. /**
  10302. * The type of controller (Eg. Windows mixed reality)
  10303. */
  10304. controllerType: PoseEnabledControllerType;
  10305. protected _calculatedPosition: Vector3;
  10306. private _calculatedRotation;
  10307. /**
  10308. * The raw pose from the device
  10309. */
  10310. rawPose: DevicePose;
  10311. private _trackPosition;
  10312. private _maxRotationDistFromHeadset;
  10313. private _draggedRoomRotation;
  10314. /**
  10315. * @hidden
  10316. */
  10317. _disableTrackPosition(fixedPosition: Vector3): void;
  10318. /**
  10319. * Internal, the mesh attached to the controller
  10320. * @hidden
  10321. */
  10322. _mesh: Nullable<AbstractMesh>;
  10323. private _poseControlledCamera;
  10324. private _leftHandSystemQuaternion;
  10325. /**
  10326. * Internal, matrix used to convert room space to babylon space
  10327. * @hidden
  10328. */
  10329. _deviceToWorld: Matrix;
  10330. /**
  10331. * Node to be used when casting a ray from the controller
  10332. * @hidden
  10333. */
  10334. _pointingPoseNode: Nullable<TransformNode>;
  10335. /**
  10336. * Name of the child mesh that can be used to cast a ray from the controller
  10337. */
  10338. static readonly POINTING_POSE: string;
  10339. /**
  10340. * Creates a new PoseEnabledController from a gamepad
  10341. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  10342. */
  10343. constructor(browserGamepad: any);
  10344. private _workingMatrix;
  10345. /**
  10346. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  10347. */
  10348. update(): void;
  10349. /**
  10350. * Updates only the pose device and mesh without doing any button event checking
  10351. */
  10352. protected _updatePoseAndMesh(): void;
  10353. /**
  10354. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  10355. * @param poseData raw pose fromthe device
  10356. */
  10357. updateFromDevice(poseData: DevicePose): void;
  10358. /**
  10359. * @hidden
  10360. */
  10361. _meshAttachedObservable: Observable<AbstractMesh>;
  10362. /**
  10363. * Attaches a mesh to the controller
  10364. * @param mesh the mesh to be attached
  10365. */
  10366. attachToMesh(mesh: AbstractMesh): void;
  10367. /**
  10368. * Attaches the controllers mesh to a camera
  10369. * @param camera the camera the mesh should be attached to
  10370. */
  10371. attachToPoseControlledCamera(camera: TargetCamera): void;
  10372. /**
  10373. * Disposes of the controller
  10374. */
  10375. dispose(): void;
  10376. /**
  10377. * The mesh that is attached to the controller
  10378. */
  10379. readonly mesh: Nullable<AbstractMesh>;
  10380. /**
  10381. * Gets the ray of the controller in the direction the controller is pointing
  10382. * @param length the length the resulting ray should be
  10383. * @returns a ray in the direction the controller is pointing
  10384. */
  10385. getForwardRay(length?: number): Ray;
  10386. }
  10387. }
  10388. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  10389. import { Observable } from "babylonjs/Misc/observable";
  10390. import { Scene } from "babylonjs/scene";
  10391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10392. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  10393. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  10394. /**
  10395. * Defines the WebVRController object that represents controllers tracked in 3D space
  10396. */
  10397. export abstract class WebVRController extends PoseEnabledController {
  10398. /**
  10399. * Internal, the default controller model for the controller
  10400. */
  10401. protected _defaultModel: AbstractMesh;
  10402. /**
  10403. * Fired when the trigger state has changed
  10404. */
  10405. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  10406. /**
  10407. * Fired when the main button state has changed
  10408. */
  10409. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  10410. /**
  10411. * Fired when the secondary button state has changed
  10412. */
  10413. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  10414. /**
  10415. * Fired when the pad state has changed
  10416. */
  10417. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  10418. /**
  10419. * Fired when controllers stick values have changed
  10420. */
  10421. onPadValuesChangedObservable: Observable<StickValues>;
  10422. /**
  10423. * Array of button availible on the controller
  10424. */
  10425. protected _buttons: Array<MutableGamepadButton>;
  10426. private _onButtonStateChange;
  10427. /**
  10428. * Fired when a controller button's state has changed
  10429. * @param callback the callback containing the button that was modified
  10430. */
  10431. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  10432. /**
  10433. * X and Y axis corrisponding to the controllers joystick
  10434. */
  10435. pad: StickValues;
  10436. /**
  10437. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  10438. */
  10439. hand: string;
  10440. /**
  10441. * The default controller model for the controller
  10442. */
  10443. readonly defaultModel: AbstractMesh;
  10444. /**
  10445. * Creates a new WebVRController from a gamepad
  10446. * @param vrGamepad the gamepad that the WebVRController should be created from
  10447. */
  10448. constructor(vrGamepad: any);
  10449. /**
  10450. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  10451. */
  10452. update(): void;
  10453. /**
  10454. * Function to be called when a button is modified
  10455. */
  10456. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  10457. /**
  10458. * Loads a mesh and attaches it to the controller
  10459. * @param scene the scene the mesh should be added to
  10460. * @param meshLoaded callback for when the mesh has been loaded
  10461. */
  10462. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  10463. private _setButtonValue;
  10464. private _changes;
  10465. private _checkChanges;
  10466. /**
  10467. * Disposes of th webVRCOntroller
  10468. */
  10469. dispose(): void;
  10470. }
  10471. }
  10472. declare module "babylonjs/Lights/shadowLight" {
  10473. import { Camera } from "babylonjs/Cameras/camera";
  10474. import { Scene } from "babylonjs/scene";
  10475. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10477. import { Light } from "babylonjs/Lights/light";
  10478. /**
  10479. * Interface describing all the common properties and methods a shadow light needs to implement.
  10480. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10481. * as well as binding the different shadow properties to the effects.
  10482. */
  10483. export interface IShadowLight extends Light {
  10484. /**
  10485. * The light id in the scene (used in scene.findLighById for instance)
  10486. */
  10487. id: string;
  10488. /**
  10489. * The position the shdow will be casted from.
  10490. */
  10491. position: Vector3;
  10492. /**
  10493. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10494. */
  10495. direction: Vector3;
  10496. /**
  10497. * The transformed position. Position of the light in world space taking parenting in account.
  10498. */
  10499. transformedPosition: Vector3;
  10500. /**
  10501. * The transformed direction. Direction of the light in world space taking parenting in account.
  10502. */
  10503. transformedDirection: Vector3;
  10504. /**
  10505. * The friendly name of the light in the scene.
  10506. */
  10507. name: string;
  10508. /**
  10509. * Defines the shadow projection clipping minimum z value.
  10510. */
  10511. shadowMinZ: number;
  10512. /**
  10513. * Defines the shadow projection clipping maximum z value.
  10514. */
  10515. shadowMaxZ: number;
  10516. /**
  10517. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10518. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10519. */
  10520. computeTransformedInformation(): boolean;
  10521. /**
  10522. * Gets the scene the light belongs to.
  10523. * @returns The scene
  10524. */
  10525. getScene(): Scene;
  10526. /**
  10527. * Callback defining a custom Projection Matrix Builder.
  10528. * This can be used to override the default projection matrix computation.
  10529. */
  10530. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10531. /**
  10532. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10533. * @param matrix The materix to updated with the projection information
  10534. * @param viewMatrix The transform matrix of the light
  10535. * @param renderList The list of mesh to render in the map
  10536. * @returns The current light
  10537. */
  10538. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10539. /**
  10540. * Gets the current depth scale used in ESM.
  10541. * @returns The scale
  10542. */
  10543. getDepthScale(): number;
  10544. /**
  10545. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10546. * @returns true if a cube texture needs to be use
  10547. */
  10548. needCube(): boolean;
  10549. /**
  10550. * Detects if the projection matrix requires to be recomputed this frame.
  10551. * @returns true if it requires to be recomputed otherwise, false.
  10552. */
  10553. needProjectionMatrixCompute(): boolean;
  10554. /**
  10555. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10556. */
  10557. forceProjectionMatrixCompute(): void;
  10558. /**
  10559. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10560. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10561. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10562. */
  10563. getShadowDirection(faceIndex?: number): Vector3;
  10564. /**
  10565. * Gets the minZ used for shadow according to both the scene and the light.
  10566. * @param activeCamera The camera we are returning the min for
  10567. * @returns the depth min z
  10568. */
  10569. getDepthMinZ(activeCamera: Camera): number;
  10570. /**
  10571. * Gets the maxZ used for shadow according to both the scene and the light.
  10572. * @param activeCamera The camera we are returning the max for
  10573. * @returns the depth max z
  10574. */
  10575. getDepthMaxZ(activeCamera: Camera): number;
  10576. }
  10577. /**
  10578. * Base implementation IShadowLight
  10579. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10580. */
  10581. export abstract class ShadowLight extends Light implements IShadowLight {
  10582. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10583. protected _position: Vector3;
  10584. protected _setPosition(value: Vector3): void;
  10585. /**
  10586. * Sets the position the shadow will be casted from. Also use as the light position for both
  10587. * point and spot lights.
  10588. */
  10589. /**
  10590. * Sets the position the shadow will be casted from. Also use as the light position for both
  10591. * point and spot lights.
  10592. */
  10593. position: Vector3;
  10594. protected _direction: Vector3;
  10595. protected _setDirection(value: Vector3): void;
  10596. /**
  10597. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10598. * Also use as the light direction on spot and directional lights.
  10599. */
  10600. /**
  10601. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10602. * Also use as the light direction on spot and directional lights.
  10603. */
  10604. direction: Vector3;
  10605. private _shadowMinZ;
  10606. /**
  10607. * Gets the shadow projection clipping minimum z value.
  10608. */
  10609. /**
  10610. * Sets the shadow projection clipping minimum z value.
  10611. */
  10612. shadowMinZ: number;
  10613. private _shadowMaxZ;
  10614. /**
  10615. * Sets the shadow projection clipping maximum z value.
  10616. */
  10617. /**
  10618. * Gets the shadow projection clipping maximum z value.
  10619. */
  10620. shadowMaxZ: number;
  10621. /**
  10622. * Callback defining a custom Projection Matrix Builder.
  10623. * This can be used to override the default projection matrix computation.
  10624. */
  10625. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10626. /**
  10627. * The transformed position. Position of the light in world space taking parenting in account.
  10628. */
  10629. transformedPosition: Vector3;
  10630. /**
  10631. * The transformed direction. Direction of the light in world space taking parenting in account.
  10632. */
  10633. transformedDirection: Vector3;
  10634. private _needProjectionMatrixCompute;
  10635. /**
  10636. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10637. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10638. */
  10639. computeTransformedInformation(): boolean;
  10640. /**
  10641. * Return the depth scale used for the shadow map.
  10642. * @returns the depth scale.
  10643. */
  10644. getDepthScale(): number;
  10645. /**
  10646. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10647. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10648. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10649. */
  10650. getShadowDirection(faceIndex?: number): Vector3;
  10651. /**
  10652. * Returns the ShadowLight absolute position in the World.
  10653. * @returns the position vector in world space
  10654. */
  10655. getAbsolutePosition(): Vector3;
  10656. /**
  10657. * Sets the ShadowLight direction toward the passed target.
  10658. * @param target The point tot target in local space
  10659. * @returns the updated ShadowLight direction
  10660. */
  10661. setDirectionToTarget(target: Vector3): Vector3;
  10662. /**
  10663. * Returns the light rotation in euler definition.
  10664. * @returns the x y z rotation in local space.
  10665. */
  10666. getRotation(): Vector3;
  10667. /**
  10668. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10669. * @returns true if a cube texture needs to be use
  10670. */
  10671. needCube(): boolean;
  10672. /**
  10673. * Detects if the projection matrix requires to be recomputed this frame.
  10674. * @returns true if it requires to be recomputed otherwise, false.
  10675. */
  10676. needProjectionMatrixCompute(): boolean;
  10677. /**
  10678. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10679. */
  10680. forceProjectionMatrixCompute(): void;
  10681. /** @hidden */
  10682. _initCache(): void;
  10683. /** @hidden */
  10684. _isSynchronized(): boolean;
  10685. /**
  10686. * Computes the world matrix of the node
  10687. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10688. * @returns the world matrix
  10689. */
  10690. computeWorldMatrix(force?: boolean): Matrix;
  10691. /**
  10692. * Gets the minZ used for shadow according to both the scene and the light.
  10693. * @param activeCamera The camera we are returning the min for
  10694. * @returns the depth min z
  10695. */
  10696. getDepthMinZ(activeCamera: Camera): number;
  10697. /**
  10698. * Gets the maxZ used for shadow according to both the scene and the light.
  10699. * @param activeCamera The camera we are returning the max for
  10700. * @returns the depth max z
  10701. */
  10702. getDepthMaxZ(activeCamera: Camera): number;
  10703. /**
  10704. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10705. * @param matrix The materix to updated with the projection information
  10706. * @param viewMatrix The transform matrix of the light
  10707. * @param renderList The list of mesh to render in the map
  10708. * @returns The current light
  10709. */
  10710. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10711. }
  10712. }
  10713. declare module "babylonjs/Materials/materialHelper" {
  10714. import { Nullable } from "babylonjs/types";
  10715. import { Scene } from "babylonjs/scene";
  10716. import { Engine } from "babylonjs/Engines/engine";
  10717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10718. import { Light } from "babylonjs/Lights/light";
  10719. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10720. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  10721. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  10722. /**
  10723. * "Static Class" containing the most commonly used helper while dealing with material for
  10724. * rendering purpose.
  10725. *
  10726. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10727. *
  10728. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10729. */
  10730. export class MaterialHelper {
  10731. /**
  10732. * Bind the current view position to an effect.
  10733. * @param effect The effect to be bound
  10734. * @param scene The scene the eyes position is used from
  10735. */
  10736. static BindEyePosition(effect: Effect, scene: Scene): void;
  10737. /**
  10738. * Helps preparing the defines values about the UVs in used in the effect.
  10739. * UVs are shared as much as we can accross channels in the shaders.
  10740. * @param texture The texture we are preparing the UVs for
  10741. * @param defines The defines to update
  10742. * @param key The channel key "diffuse", "specular"... used in the shader
  10743. */
  10744. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10745. /**
  10746. * Binds a texture matrix value to its corrsponding uniform
  10747. * @param texture The texture to bind the matrix for
  10748. * @param uniformBuffer The uniform buffer receivin the data
  10749. * @param key The channel key "diffuse", "specular"... used in the shader
  10750. */
  10751. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10752. /**
  10753. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10754. * @param mesh defines the current mesh
  10755. * @param scene defines the current scene
  10756. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10757. * @param pointsCloud defines if point cloud rendering has to be turned on
  10758. * @param fogEnabled defines if fog has to be turned on
  10759. * @param alphaTest defines if alpha testing has to be turned on
  10760. * @param defines defines the current list of defines
  10761. */
  10762. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10763. /**
  10764. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10765. * @param scene defines the current scene
  10766. * @param engine defines the current engine
  10767. * @param defines specifies the list of active defines
  10768. * @param useInstances defines if instances have to be turned on
  10769. * @param useClipPlane defines if clip plane have to be turned on
  10770. */
  10771. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10772. /**
  10773. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10774. * @param mesh The mesh containing the geometry data we will draw
  10775. * @param defines The defines to update
  10776. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10777. * @param useBones Precise whether bones should be used or not (override mesh info)
  10778. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10779. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10780. * @returns false if defines are considered not dirty and have not been checked
  10781. */
  10782. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10783. /**
  10784. * Prepares the defines related to the light information passed in parameter
  10785. * @param scene The scene we are intending to draw
  10786. * @param mesh The mesh the effect is compiling for
  10787. * @param defines The defines to update
  10788. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10789. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10790. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10791. * @returns true if normals will be required for the rest of the effect
  10792. */
  10793. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10794. /**
  10795. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  10796. * that won t be acctive due to defines being turned off.
  10797. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10798. * @param samplersList The samplers list
  10799. * @param defines The defines helping in the list generation
  10800. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10801. */
  10802. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10803. /**
  10804. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10805. * @param defines The defines to update while falling back
  10806. * @param fallbacks The authorized effect fallbacks
  10807. * @param maxSimultaneousLights The maximum number of lights allowed
  10808. * @param rank the current rank of the Effect
  10809. * @returns The newly affected rank
  10810. */
  10811. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  10812. /**
  10813. * Prepares the list of attributes required for morph targets according to the effect defines.
  10814. * @param attribs The current list of supported attribs
  10815. * @param mesh The mesh to prepare the morph targets attributes for
  10816. * @param defines The current Defines of the effect
  10817. */
  10818. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  10819. /**
  10820. * Prepares the list of attributes required for bones according to the effect defines.
  10821. * @param attribs The current list of supported attribs
  10822. * @param mesh The mesh to prepare the bones attributes for
  10823. * @param defines The current Defines of the effect
  10824. * @param fallbacks The current efffect fallback strategy
  10825. */
  10826. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  10827. /**
  10828. * Prepares the list of attributes required for instances according to the effect defines.
  10829. * @param attribs The current list of supported attribs
  10830. * @param defines The current Defines of the effect
  10831. */
  10832. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  10833. /**
  10834. * Binds the light shadow information to the effect for the given mesh.
  10835. * @param light The light containing the generator
  10836. * @param scene The scene the lights belongs to
  10837. * @param mesh The mesh we are binding the information to render
  10838. * @param lightIndex The light index in the effect used to render the mesh
  10839. * @param effect The effect we are binding the data to
  10840. */
  10841. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  10842. /**
  10843. * Binds the light information to the effect.
  10844. * @param light The light containing the generator
  10845. * @param effect The effect we are binding the data to
  10846. * @param lightIndex The light index in the effect used to render
  10847. */
  10848. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  10849. /**
  10850. * Binds the lights information from the scene to the effect for the given mesh.
  10851. * @param scene The scene the lights belongs to
  10852. * @param mesh The mesh we are binding the information to render
  10853. * @param effect The effect we are binding the data to
  10854. * @param defines The generated defines for the effect
  10855. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  10856. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10857. */
  10858. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  10859. private static _tempFogColor;
  10860. /**
  10861. * Binds the fog information from the scene to the effect for the given mesh.
  10862. * @param scene The scene the lights belongs to
  10863. * @param mesh The mesh we are binding the information to render
  10864. * @param effect The effect we are binding the data to
  10865. * @param linearSpace Defines if the fog effect is applied in linear space
  10866. */
  10867. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  10868. /**
  10869. * Binds the bones information from the mesh to the effect.
  10870. * @param mesh The mesh we are binding the information to render
  10871. * @param effect The effect we are binding the data to
  10872. */
  10873. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  10874. /**
  10875. * Binds the morph targets information from the mesh to the effect.
  10876. * @param abstractMesh The mesh we are binding the information to render
  10877. * @param effect The effect we are binding the data to
  10878. */
  10879. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  10880. /**
  10881. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  10882. * @param defines The generated defines used in the effect
  10883. * @param effect The effect we are binding the data to
  10884. * @param scene The scene we are willing to render with logarithmic scale for
  10885. */
  10886. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  10887. /**
  10888. * Binds the clip plane information from the scene to the effect.
  10889. * @param scene The scene the clip plane information are extracted from
  10890. * @param effect The effect we are binding the data to
  10891. */
  10892. static BindClipPlane(effect: Effect, scene: Scene): void;
  10893. }
  10894. }
  10895. declare module "babylonjs/Shaders/shadowMap.fragment" {
  10896. /** @hidden */
  10897. export var shadowMapPixelShader: {
  10898. name: string;
  10899. shader: string;
  10900. };
  10901. }
  10902. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  10903. /** @hidden */
  10904. export var bonesDeclaration: {
  10905. name: string;
  10906. shader: string;
  10907. };
  10908. }
  10909. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  10910. /** @hidden */
  10911. export var morphTargetsVertexGlobalDeclaration: {
  10912. name: string;
  10913. shader: string;
  10914. };
  10915. }
  10916. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  10917. /** @hidden */
  10918. export var morphTargetsVertexDeclaration: {
  10919. name: string;
  10920. shader: string;
  10921. };
  10922. }
  10923. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  10924. /** @hidden */
  10925. export var instancesDeclaration: {
  10926. name: string;
  10927. shader: string;
  10928. };
  10929. }
  10930. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  10931. /** @hidden */
  10932. export var helperFunctions: {
  10933. name: string;
  10934. shader: string;
  10935. };
  10936. }
  10937. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  10938. /** @hidden */
  10939. export var morphTargetsVertex: {
  10940. name: string;
  10941. shader: string;
  10942. };
  10943. }
  10944. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  10945. /** @hidden */
  10946. export var instancesVertex: {
  10947. name: string;
  10948. shader: string;
  10949. };
  10950. }
  10951. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  10952. /** @hidden */
  10953. export var bonesVertex: {
  10954. name: string;
  10955. shader: string;
  10956. };
  10957. }
  10958. declare module "babylonjs/Shaders/shadowMap.vertex" {
  10959. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  10960. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  10961. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  10962. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  10963. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  10964. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  10965. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  10966. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  10967. /** @hidden */
  10968. export var shadowMapVertexShader: {
  10969. name: string;
  10970. shader: string;
  10971. };
  10972. }
  10973. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  10974. /** @hidden */
  10975. export var depthBoxBlurPixelShader: {
  10976. name: string;
  10977. shader: string;
  10978. };
  10979. }
  10980. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  10981. import { Nullable } from "babylonjs/types";
  10982. import { Scene } from "babylonjs/scene";
  10983. import { Matrix } from "babylonjs/Maths/math";
  10984. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10986. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  10987. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  10988. import { Effect } from "babylonjs/Materials/effect";
  10989. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10990. import "babylonjs/Shaders/shadowMap.fragment";
  10991. import "babylonjs/Shaders/shadowMap.vertex";
  10992. import "babylonjs/Shaders/depthBoxBlur.fragment";
  10993. /**
  10994. * Interface to implement to create a shadow generator compatible with BJS.
  10995. */
  10996. export interface IShadowGenerator {
  10997. /**
  10998. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10999. * @returns The render target texture if present otherwise, null
  11000. */
  11001. getShadowMap(): Nullable<RenderTargetTexture>;
  11002. /**
  11003. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11004. * @returns The render target texture if the shadow map is present otherwise, null
  11005. */
  11006. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11007. /**
  11008. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11009. * @param subMesh The submesh we want to render in the shadow map
  11010. * @param useInstances Defines wether will draw in the map using instances
  11011. * @returns true if ready otherwise, false
  11012. */
  11013. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11014. /**
  11015. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11016. * @param defines Defines of the material we want to update
  11017. * @param lightIndex Index of the light in the enabled light list of the material
  11018. */
  11019. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11020. /**
  11021. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11022. * defined in the generator but impacting the effect).
  11023. * It implies the unifroms available on the materials are the standard BJS ones.
  11024. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11025. * @param effect The effect we are binfing the information for
  11026. */
  11027. bindShadowLight(lightIndex: string, effect: Effect): void;
  11028. /**
  11029. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11030. * (eq to shadow prjection matrix * light transform matrix)
  11031. * @returns The transform matrix used to create the shadow map
  11032. */
  11033. getTransformMatrix(): Matrix;
  11034. /**
  11035. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11036. * Cube and 2D textures for instance.
  11037. */
  11038. recreateShadowMap(): void;
  11039. /**
  11040. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11041. * @param onCompiled Callback triggered at the and of the effects compilation
  11042. * @param options Sets of optional options forcing the compilation with different modes
  11043. */
  11044. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11045. useInstances: boolean;
  11046. }>): void;
  11047. /**
  11048. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11049. * @param options Sets of optional options forcing the compilation with different modes
  11050. * @returns A promise that resolves when the compilation completes
  11051. */
  11052. forceCompilationAsync(options?: Partial<{
  11053. useInstances: boolean;
  11054. }>): Promise<void>;
  11055. /**
  11056. * Serializes the shadow generator setup to a json object.
  11057. * @returns The serialized JSON object
  11058. */
  11059. serialize(): any;
  11060. /**
  11061. * Disposes the Shadow map and related Textures and effects.
  11062. */
  11063. dispose(): void;
  11064. }
  11065. /**
  11066. * Default implementation IShadowGenerator.
  11067. * This is the main object responsible of generating shadows in the framework.
  11068. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11069. */
  11070. export class ShadowGenerator implements IShadowGenerator {
  11071. /**
  11072. * Shadow generator mode None: no filtering applied.
  11073. */
  11074. static readonly FILTER_NONE: number;
  11075. /**
  11076. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11077. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11078. */
  11079. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11080. /**
  11081. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11082. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11083. */
  11084. static readonly FILTER_POISSONSAMPLING: number;
  11085. /**
  11086. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11087. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11088. */
  11089. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11090. /**
  11091. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11092. * edge artifacts on steep falloff.
  11093. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11094. */
  11095. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11096. /**
  11097. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11098. * edge artifacts on steep falloff.
  11099. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11100. */
  11101. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11102. /**
  11103. * Shadow generator mode PCF: Percentage Closer Filtering
  11104. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11105. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11106. */
  11107. static readonly FILTER_PCF: number;
  11108. /**
  11109. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11110. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11111. * Contact Hardening
  11112. */
  11113. static readonly FILTER_PCSS: number;
  11114. /**
  11115. * Reserved for PCF and PCSS
  11116. * Highest Quality.
  11117. *
  11118. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11119. *
  11120. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11121. */
  11122. static readonly QUALITY_HIGH: number;
  11123. /**
  11124. * Reserved for PCF and PCSS
  11125. * Good tradeoff for quality/perf cross devices
  11126. *
  11127. * Execute PCF on a 3*3 kernel.
  11128. *
  11129. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11130. */
  11131. static readonly QUALITY_MEDIUM: number;
  11132. /**
  11133. * Reserved for PCF and PCSS
  11134. * The lowest quality but the fastest.
  11135. *
  11136. * Execute PCF on a 1*1 kernel.
  11137. *
  11138. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11139. */
  11140. static readonly QUALITY_LOW: number;
  11141. private _bias;
  11142. /**
  11143. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11144. */
  11145. /**
  11146. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11147. */
  11148. bias: number;
  11149. private _normalBias;
  11150. /**
  11151. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11152. */
  11153. /**
  11154. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11155. */
  11156. normalBias: number;
  11157. private _blurBoxOffset;
  11158. /**
  11159. * Gets the blur box offset: offset applied during the blur pass.
  11160. * Only useful if useKernelBlur = false
  11161. */
  11162. /**
  11163. * Sets the blur box offset: offset applied during the blur pass.
  11164. * Only useful if useKernelBlur = false
  11165. */
  11166. blurBoxOffset: number;
  11167. private _blurScale;
  11168. /**
  11169. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11170. * 2 means half of the size.
  11171. */
  11172. /**
  11173. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11174. * 2 means half of the size.
  11175. */
  11176. blurScale: number;
  11177. private _blurKernel;
  11178. /**
  11179. * Gets the blur kernel: kernel size of the blur pass.
  11180. * Only useful if useKernelBlur = true
  11181. */
  11182. /**
  11183. * Sets the blur kernel: kernel size of the blur pass.
  11184. * Only useful if useKernelBlur = true
  11185. */
  11186. blurKernel: number;
  11187. private _useKernelBlur;
  11188. /**
  11189. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11190. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11191. */
  11192. /**
  11193. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11194. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11195. */
  11196. useKernelBlur: boolean;
  11197. private _depthScale;
  11198. /**
  11199. * Gets the depth scale used in ESM mode.
  11200. */
  11201. /**
  11202. * Sets the depth scale used in ESM mode.
  11203. * This can override the scale stored on the light.
  11204. */
  11205. depthScale: number;
  11206. private _filter;
  11207. /**
  11208. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11209. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11210. */
  11211. /**
  11212. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11213. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11214. */
  11215. filter: number;
  11216. /**
  11217. * Gets if the current filter is set to Poisson Sampling.
  11218. */
  11219. /**
  11220. * Sets the current filter to Poisson Sampling.
  11221. */
  11222. usePoissonSampling: boolean;
  11223. /**
  11224. * Gets if the current filter is set to ESM.
  11225. */
  11226. /**
  11227. * Sets the current filter is to ESM.
  11228. */
  11229. useExponentialShadowMap: boolean;
  11230. /**
  11231. * Gets if the current filter is set to filtered ESM.
  11232. */
  11233. /**
  11234. * Gets if the current filter is set to filtered ESM.
  11235. */
  11236. useBlurExponentialShadowMap: boolean;
  11237. /**
  11238. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11239. * exponential to prevent steep falloff artifacts).
  11240. */
  11241. /**
  11242. * Sets the current filter to "close ESM" (using the inverse of the
  11243. * exponential to prevent steep falloff artifacts).
  11244. */
  11245. useCloseExponentialShadowMap: boolean;
  11246. /**
  11247. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11248. * exponential to prevent steep falloff artifacts).
  11249. */
  11250. /**
  11251. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11252. * exponential to prevent steep falloff artifacts).
  11253. */
  11254. useBlurCloseExponentialShadowMap: boolean;
  11255. /**
  11256. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11257. */
  11258. /**
  11259. * Sets the current filter to "PCF" (percentage closer filtering).
  11260. */
  11261. usePercentageCloserFiltering: boolean;
  11262. private _filteringQuality;
  11263. /**
  11264. * Gets the PCF or PCSS Quality.
  11265. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11266. */
  11267. /**
  11268. * Sets the PCF or PCSS Quality.
  11269. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11270. */
  11271. filteringQuality: number;
  11272. /**
  11273. * Gets if the current filter is set to "PCSS" (contact hardening).
  11274. */
  11275. /**
  11276. * Sets the current filter to "PCSS" (contact hardening).
  11277. */
  11278. useContactHardeningShadow: boolean;
  11279. private _contactHardeningLightSizeUVRatio;
  11280. /**
  11281. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11282. * Using a ratio helps keeping shape stability independently of the map size.
  11283. *
  11284. * It does not account for the light projection as it was having too much
  11285. * instability during the light setup or during light position changes.
  11286. *
  11287. * Only valid if useContactHardeningShadow is true.
  11288. */
  11289. /**
  11290. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11291. * Using a ratio helps keeping shape stability independently of the map size.
  11292. *
  11293. * It does not account for the light projection as it was having too much
  11294. * instability during the light setup or during light position changes.
  11295. *
  11296. * Only valid if useContactHardeningShadow is true.
  11297. */
  11298. contactHardeningLightSizeUVRatio: number;
  11299. private _darkness;
  11300. /**
  11301. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11302. * 0 means strongest and 1 would means no shadow.
  11303. * @returns the darkness.
  11304. */
  11305. getDarkness(): number;
  11306. /**
  11307. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11308. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11309. * @returns the shadow generator allowing fluent coding.
  11310. */
  11311. setDarkness(darkness: number): ShadowGenerator;
  11312. private _transparencyShadow;
  11313. /**
  11314. * Sets the ability to have transparent shadow (boolean).
  11315. * @param transparent True if transparent else False
  11316. * @returns the shadow generator allowing fluent coding
  11317. */
  11318. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11319. private _shadowMap;
  11320. private _shadowMap2;
  11321. /**
  11322. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11323. * @returns The render target texture if present otherwise, null
  11324. */
  11325. getShadowMap(): Nullable<RenderTargetTexture>;
  11326. /**
  11327. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11328. * @returns The render target texture if the shadow map is present otherwise, null
  11329. */
  11330. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11331. /**
  11332. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11333. * @param mesh Mesh to add
  11334. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11335. * @returns the Shadow Generator itself
  11336. */
  11337. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11338. /**
  11339. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11340. * @param mesh Mesh to remove
  11341. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11342. * @returns the Shadow Generator itself
  11343. */
  11344. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11345. /**
  11346. * Controls the extent to which the shadows fade out at the edge of the frustum
  11347. * Used only by directionals and spots
  11348. */
  11349. frustumEdgeFalloff: number;
  11350. private _light;
  11351. /**
  11352. * Returns the associated light object.
  11353. * @returns the light generating the shadow
  11354. */
  11355. getLight(): IShadowLight;
  11356. /**
  11357. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11358. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11359. * It might on the other hand introduce peter panning.
  11360. */
  11361. forceBackFacesOnly: boolean;
  11362. private _scene;
  11363. private _lightDirection;
  11364. private _effect;
  11365. private _viewMatrix;
  11366. private _projectionMatrix;
  11367. private _transformMatrix;
  11368. private _cachedPosition;
  11369. private _cachedDirection;
  11370. private _cachedDefines;
  11371. private _currentRenderID;
  11372. private _boxBlurPostprocess;
  11373. private _kernelBlurXPostprocess;
  11374. private _kernelBlurYPostprocess;
  11375. private _blurPostProcesses;
  11376. private _mapSize;
  11377. private _currentFaceIndex;
  11378. private _currentFaceIndexCache;
  11379. private _textureType;
  11380. private _defaultTextureMatrix;
  11381. /** @hidden */
  11382. static _SceneComponentInitialization: (scene: Scene) => void;
  11383. /**
  11384. * Creates a ShadowGenerator object.
  11385. * A ShadowGenerator is the required tool to use the shadows.
  11386. * Each light casting shadows needs to use its own ShadowGenerator.
  11387. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11388. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11389. * @param light The light object generating the shadows.
  11390. * @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.
  11391. */
  11392. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11393. private _initializeGenerator;
  11394. private _initializeShadowMap;
  11395. private _initializeBlurRTTAndPostProcesses;
  11396. private _renderForShadowMap;
  11397. private _renderSubMeshForShadowMap;
  11398. private _applyFilterValues;
  11399. /**
  11400. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11401. * @param onCompiled Callback triggered at the and of the effects compilation
  11402. * @param options Sets of optional options forcing the compilation with different modes
  11403. */
  11404. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11405. useInstances: boolean;
  11406. }>): void;
  11407. /**
  11408. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11409. * @param options Sets of optional options forcing the compilation with different modes
  11410. * @returns A promise that resolves when the compilation completes
  11411. */
  11412. forceCompilationAsync(options?: Partial<{
  11413. useInstances: boolean;
  11414. }>): Promise<void>;
  11415. /**
  11416. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11417. * @param subMesh The submesh we want to render in the shadow map
  11418. * @param useInstances Defines wether will draw in the map using instances
  11419. * @returns true if ready otherwise, false
  11420. */
  11421. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11422. /**
  11423. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11424. * @param defines Defines of the material we want to update
  11425. * @param lightIndex Index of the light in the enabled light list of the material
  11426. */
  11427. prepareDefines(defines: any, lightIndex: number): void;
  11428. /**
  11429. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11430. * defined in the generator but impacting the effect).
  11431. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11432. * @param effect The effect we are binfing the information for
  11433. */
  11434. bindShadowLight(lightIndex: string, effect: Effect): void;
  11435. /**
  11436. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11437. * (eq to shadow prjection matrix * light transform matrix)
  11438. * @returns The transform matrix used to create the shadow map
  11439. */
  11440. getTransformMatrix(): Matrix;
  11441. /**
  11442. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11443. * Cube and 2D textures for instance.
  11444. */
  11445. recreateShadowMap(): void;
  11446. private _disposeBlurPostProcesses;
  11447. private _disposeRTTandPostProcesses;
  11448. /**
  11449. * Disposes the ShadowGenerator.
  11450. * Returns nothing.
  11451. */
  11452. dispose(): void;
  11453. /**
  11454. * Serializes the shadow generator setup to a json object.
  11455. * @returns The serialized JSON object
  11456. */
  11457. serialize(): any;
  11458. /**
  11459. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11460. * @param parsedShadowGenerator The JSON object to parse
  11461. * @param scene The scene to create the shadow map for
  11462. * @returns The parsed shadow generator
  11463. */
  11464. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11465. }
  11466. }
  11467. declare module "babylonjs/Lights/light" {
  11468. import { Nullable } from "babylonjs/types";
  11469. import { Scene } from "babylonjs/scene";
  11470. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11471. import { Node } from "babylonjs/node";
  11472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11473. import { Effect } from "babylonjs/Materials/effect";
  11474. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11475. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11476. /**
  11477. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11478. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11479. * 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.
  11480. */
  11481. export abstract class Light extends Node {
  11482. /**
  11483. * Falloff Default: light is falling off following the material specification:
  11484. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11485. */
  11486. static readonly FALLOFF_DEFAULT: number;
  11487. /**
  11488. * Falloff Physical: light is falling off following the inverse squared distance law.
  11489. */
  11490. static readonly FALLOFF_PHYSICAL: number;
  11491. /**
  11492. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11493. * to enhance interoperability with other engines.
  11494. */
  11495. static readonly FALLOFF_GLTF: number;
  11496. /**
  11497. * Falloff Standard: light is falling off like in the standard material
  11498. * to enhance interoperability with other materials.
  11499. */
  11500. static readonly FALLOFF_STANDARD: number;
  11501. /**
  11502. * If every light affecting the material is in this lightmapMode,
  11503. * material.lightmapTexture adds or multiplies
  11504. * (depends on material.useLightmapAsShadowmap)
  11505. * after every other light calculations.
  11506. */
  11507. static readonly LIGHTMAP_DEFAULT: number;
  11508. /**
  11509. * material.lightmapTexture as only diffuse lighting from this light
  11510. * adds only specular lighting from this light
  11511. * adds dynamic shadows
  11512. */
  11513. static readonly LIGHTMAP_SPECULAR: number;
  11514. /**
  11515. * material.lightmapTexture as only lighting
  11516. * no light calculation from this light
  11517. * only adds dynamic shadows from this light
  11518. */
  11519. static readonly LIGHTMAP_SHADOWSONLY: number;
  11520. /**
  11521. * Each light type uses the default quantity according to its type:
  11522. * point/spot lights use luminous intensity
  11523. * directional lights use illuminance
  11524. */
  11525. static readonly INTENSITYMODE_AUTOMATIC: number;
  11526. /**
  11527. * lumen (lm)
  11528. */
  11529. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11530. /**
  11531. * candela (lm/sr)
  11532. */
  11533. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11534. /**
  11535. * lux (lm/m^2)
  11536. */
  11537. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11538. /**
  11539. * nit (cd/m^2)
  11540. */
  11541. static readonly INTENSITYMODE_LUMINANCE: number;
  11542. /**
  11543. * Light type const id of the point light.
  11544. */
  11545. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11546. /**
  11547. * Light type const id of the directional light.
  11548. */
  11549. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11550. /**
  11551. * Light type const id of the spot light.
  11552. */
  11553. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11554. /**
  11555. * Light type const id of the hemispheric light.
  11556. */
  11557. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11558. /**
  11559. * Diffuse gives the basic color to an object.
  11560. */
  11561. diffuse: Color3;
  11562. /**
  11563. * Specular produces a highlight color on an object.
  11564. * Note: This is note affecting PBR materials.
  11565. */
  11566. specular: Color3;
  11567. /**
  11568. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11569. * falling off base on range or angle.
  11570. * This can be set to any values in Light.FALLOFF_x.
  11571. *
  11572. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11573. * other types of materials.
  11574. */
  11575. falloffType: number;
  11576. /**
  11577. * Strength of the light.
  11578. * Note: By default it is define in the framework own unit.
  11579. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11580. */
  11581. intensity: number;
  11582. private _range;
  11583. protected _inverseSquaredRange: number;
  11584. /**
  11585. * Defines how far from the source the light is impacting in scene units.
  11586. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11587. */
  11588. /**
  11589. * Defines how far from the source the light is impacting in scene units.
  11590. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11591. */
  11592. range: number;
  11593. /**
  11594. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11595. * of light.
  11596. */
  11597. private _photometricScale;
  11598. private _intensityMode;
  11599. /**
  11600. * Gets the photometric scale used to interpret the intensity.
  11601. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11602. */
  11603. /**
  11604. * Sets the photometric scale used to interpret the intensity.
  11605. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11606. */
  11607. intensityMode: number;
  11608. private _radius;
  11609. /**
  11610. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11611. */
  11612. /**
  11613. * sets the light radius used by PBR Materials to simulate soft area lights.
  11614. */
  11615. radius: number;
  11616. private _renderPriority;
  11617. /**
  11618. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11619. * exceeding the number allowed of the materials.
  11620. */
  11621. renderPriority: number;
  11622. private _shadowEnabled;
  11623. /**
  11624. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11625. * the current shadow generator.
  11626. */
  11627. /**
  11628. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11629. * the current shadow generator.
  11630. */
  11631. shadowEnabled: boolean;
  11632. private _includedOnlyMeshes;
  11633. /**
  11634. * Gets the only meshes impacted by this light.
  11635. */
  11636. /**
  11637. * Sets the only meshes impacted by this light.
  11638. */
  11639. includedOnlyMeshes: AbstractMesh[];
  11640. private _excludedMeshes;
  11641. /**
  11642. * Gets the meshes not impacted by this light.
  11643. */
  11644. /**
  11645. * Sets the meshes not impacted by this light.
  11646. */
  11647. excludedMeshes: AbstractMesh[];
  11648. private _excludeWithLayerMask;
  11649. /**
  11650. * Gets the layer id use to find what meshes are not impacted by the light.
  11651. * Inactive if 0
  11652. */
  11653. /**
  11654. * Sets the layer id use to find what meshes are not impacted by the light.
  11655. * Inactive if 0
  11656. */
  11657. excludeWithLayerMask: number;
  11658. private _includeOnlyWithLayerMask;
  11659. /**
  11660. * Gets the layer id use to find what meshes are impacted by the light.
  11661. * Inactive if 0
  11662. */
  11663. /**
  11664. * Sets the layer id use to find what meshes are impacted by the light.
  11665. * Inactive if 0
  11666. */
  11667. includeOnlyWithLayerMask: number;
  11668. private _lightmapMode;
  11669. /**
  11670. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11671. */
  11672. /**
  11673. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11674. */
  11675. lightmapMode: number;
  11676. /**
  11677. * Shadow generator associted to the light.
  11678. * @hidden Internal use only.
  11679. */
  11680. _shadowGenerator: Nullable<IShadowGenerator>;
  11681. /**
  11682. * @hidden Internal use only.
  11683. */
  11684. _excludedMeshesIds: string[];
  11685. /**
  11686. * @hidden Internal use only.
  11687. */
  11688. _includedOnlyMeshesIds: string[];
  11689. /**
  11690. * The current light unifom buffer.
  11691. * @hidden Internal use only.
  11692. */
  11693. _uniformBuffer: UniformBuffer;
  11694. /**
  11695. * Creates a Light object in the scene.
  11696. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11697. * @param name The firendly name of the light
  11698. * @param scene The scene the light belongs too
  11699. */
  11700. constructor(name: string, scene: Scene);
  11701. protected abstract _buildUniformLayout(): void;
  11702. /**
  11703. * Sets the passed Effect "effect" with the Light information.
  11704. * @param effect The effect to update
  11705. * @param lightIndex The index of the light in the effect to update
  11706. * @returns The light
  11707. */
  11708. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11709. /**
  11710. * Returns the string "Light".
  11711. * @returns the class name
  11712. */
  11713. getClassName(): string;
  11714. /** @hidden */
  11715. readonly _isLight: boolean;
  11716. /**
  11717. * Converts the light information to a readable string for debug purpose.
  11718. * @param fullDetails Supports for multiple levels of logging within scene loading
  11719. * @returns the human readable light info
  11720. */
  11721. toString(fullDetails?: boolean): string;
  11722. /** @hidden */
  11723. protected _syncParentEnabledState(): void;
  11724. /**
  11725. * Set the enabled state of this node.
  11726. * @param value - the new enabled state
  11727. */
  11728. setEnabled(value: boolean): void;
  11729. /**
  11730. * Returns the Light associated shadow generator if any.
  11731. * @return the associated shadow generator.
  11732. */
  11733. getShadowGenerator(): Nullable<IShadowGenerator>;
  11734. /**
  11735. * Returns a Vector3, the absolute light position in the World.
  11736. * @returns the world space position of the light
  11737. */
  11738. getAbsolutePosition(): Vector3;
  11739. /**
  11740. * Specifies if the light will affect the passed mesh.
  11741. * @param mesh The mesh to test against the light
  11742. * @return true the mesh is affected otherwise, false.
  11743. */
  11744. canAffectMesh(mesh: AbstractMesh): boolean;
  11745. /**
  11746. * Sort function to order lights for rendering.
  11747. * @param a First Light object to compare to second.
  11748. * @param b Second Light object to compare first.
  11749. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11750. */
  11751. static CompareLightsPriority(a: Light, b: Light): number;
  11752. /**
  11753. * Releases resources associated with this node.
  11754. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11755. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11756. */
  11757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11758. /**
  11759. * Returns the light type ID (integer).
  11760. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11761. */
  11762. getTypeID(): number;
  11763. /**
  11764. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11765. * @returns the scaled intensity in intensity mode unit
  11766. */
  11767. getScaledIntensity(): number;
  11768. /**
  11769. * Returns a new Light object, named "name", from the current one.
  11770. * @param name The name of the cloned light
  11771. * @returns the new created light
  11772. */
  11773. clone(name: string): Nullable<Light>;
  11774. /**
  11775. * Serializes the current light into a Serialization object.
  11776. * @returns the serialized object.
  11777. */
  11778. serialize(): any;
  11779. /**
  11780. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11781. * This new light is named "name" and added to the passed scene.
  11782. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11783. * @param name The friendly name of the light
  11784. * @param scene The scene the new light will belong to
  11785. * @returns the constructor function
  11786. */
  11787. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11788. /**
  11789. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11790. * @param parsedLight The JSON representation of the light
  11791. * @param scene The scene to create the parsed light in
  11792. * @returns the created light after parsing
  11793. */
  11794. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11795. private _hookArrayForExcluded;
  11796. private _hookArrayForIncludedOnly;
  11797. private _resyncMeshes;
  11798. /**
  11799. * Forces the meshes to update their light related information in their rendering used effects
  11800. * @hidden Internal Use Only
  11801. */
  11802. _markMeshesAsLightDirty(): void;
  11803. /**
  11804. * Recomputes the cached photometric scale if needed.
  11805. */
  11806. private _computePhotometricScale;
  11807. /**
  11808. * Returns the Photometric Scale according to the light type and intensity mode.
  11809. */
  11810. private _getPhotometricScale;
  11811. /**
  11812. * Reorder the light in the scene according to their defined priority.
  11813. * @hidden Internal Use Only
  11814. */
  11815. _reorderLightsInScene(): void;
  11816. /**
  11817. * Prepares the list of defines specific to the light type.
  11818. * @param defines the list of defines
  11819. * @param lightIndex defines the index of the light for the effect
  11820. */
  11821. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11822. }
  11823. }
  11824. declare module "babylonjs/Lights/hemisphericLight" {
  11825. import { Nullable } from "babylonjs/types";
  11826. import { Scene } from "babylonjs/scene";
  11827. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  11828. import { Effect } from "babylonjs/Materials/effect";
  11829. import { Light } from "babylonjs/Lights/light";
  11830. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11831. /**
  11832. * The HemisphericLight simulates the ambient environment light,
  11833. * so the passed direction is the light reflection direction, not the incoming direction.
  11834. */
  11835. export class HemisphericLight extends Light {
  11836. /**
  11837. * The groundColor is the light in the opposite direction to the one specified during creation.
  11838. * 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.
  11839. */
  11840. groundColor: Color3;
  11841. /**
  11842. * The light reflection direction, not the incoming direction.
  11843. */
  11844. direction: Vector3;
  11845. /**
  11846. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11847. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11848. * The HemisphericLight can't cast shadows.
  11849. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11850. * @param name The friendly name of the light
  11851. * @param direction The direction of the light reflection
  11852. * @param scene The scene the light belongs to
  11853. */
  11854. constructor(name: string, direction: Vector3, scene: Scene);
  11855. protected _buildUniformLayout(): void;
  11856. /**
  11857. * Returns the string "HemisphericLight".
  11858. * @return The class name
  11859. */
  11860. getClassName(): string;
  11861. /**
  11862. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11863. * Returns the updated direction.
  11864. * @param target The target the direction should point to
  11865. * @return The computed direction
  11866. */
  11867. setDirectionToTarget(target: Vector3): Vector3;
  11868. /**
  11869. * Returns the shadow generator associated to the light.
  11870. * @returns Always null for hemispheric lights because it does not support shadows.
  11871. */
  11872. getShadowGenerator(): Nullable<IShadowGenerator>;
  11873. /**
  11874. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11875. * @param effect The effect to update
  11876. * @param lightIndex The index of the light in the effect to update
  11877. * @returns The hemispheric light
  11878. */
  11879. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11880. /**
  11881. * Computes the world matrix of the node
  11882. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11883. * @param useWasUpdatedFlag defines a reserved property
  11884. * @returns the world matrix
  11885. */
  11886. computeWorldMatrix(): Matrix;
  11887. /**
  11888. * Returns the integer 3.
  11889. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11890. */
  11891. getTypeID(): number;
  11892. /**
  11893. * Prepares the list of defines specific to the light type.
  11894. * @param defines the list of defines
  11895. * @param lightIndex defines the index of the light for the effect
  11896. */
  11897. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11898. }
  11899. }
  11900. declare module "babylonjs/Cameras/VR/webVRCamera" {
  11901. import { Nullable } from "babylonjs/types";
  11902. import { Observable } from "babylonjs/Misc/observable";
  11903. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11904. import { Scene } from "babylonjs/scene";
  11905. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  11906. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  11907. import { Node } from "babylonjs/node";
  11908. import { Ray } from "babylonjs/Culling/ray";
  11909. /**
  11910. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  11911. * IMPORTANT!! The data is right-hand data.
  11912. * @export
  11913. * @interface DevicePose
  11914. */
  11915. export interface DevicePose {
  11916. /**
  11917. * The position of the device, values in array are [x,y,z].
  11918. */
  11919. readonly position: Nullable<Float32Array>;
  11920. /**
  11921. * The linearVelocity of the device, values in array are [x,y,z].
  11922. */
  11923. readonly linearVelocity: Nullable<Float32Array>;
  11924. /**
  11925. * The linearAcceleration of the device, values in array are [x,y,z].
  11926. */
  11927. readonly linearAcceleration: Nullable<Float32Array>;
  11928. /**
  11929. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  11930. */
  11931. readonly orientation: Nullable<Float32Array>;
  11932. /**
  11933. * The angularVelocity of the device, values in array are [x,y,z].
  11934. */
  11935. readonly angularVelocity: Nullable<Float32Array>;
  11936. /**
  11937. * The angularAcceleration of the device, values in array are [x,y,z].
  11938. */
  11939. readonly angularAcceleration: Nullable<Float32Array>;
  11940. }
  11941. /**
  11942. * Interface representing a pose controlled object in Babylon.
  11943. * A pose controlled object has both regular pose values as well as pose values
  11944. * from an external device such as a VR head mounted display
  11945. */
  11946. export interface PoseControlled {
  11947. /**
  11948. * The position of the object in babylon space.
  11949. */
  11950. position: Vector3;
  11951. /**
  11952. * The rotation quaternion of the object in babylon space.
  11953. */
  11954. rotationQuaternion: Quaternion;
  11955. /**
  11956. * The position of the device in babylon space.
  11957. */
  11958. devicePosition?: Vector3;
  11959. /**
  11960. * The rotation quaternion of the device in babylon space.
  11961. */
  11962. deviceRotationQuaternion: Quaternion;
  11963. /**
  11964. * The raw pose coming from the device.
  11965. */
  11966. rawPose: Nullable<DevicePose>;
  11967. /**
  11968. * The scale of the device to be used when translating from device space to babylon space.
  11969. */
  11970. deviceScaleFactor: number;
  11971. /**
  11972. * Updates the poseControlled values based on the input device pose.
  11973. * @param poseData the pose data to update the object with
  11974. */
  11975. updateFromDevice(poseData: DevicePose): void;
  11976. }
  11977. /**
  11978. * Set of options to customize the webVRCamera
  11979. */
  11980. export interface WebVROptions {
  11981. /**
  11982. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  11983. */
  11984. trackPosition?: boolean;
  11985. /**
  11986. * Sets the scale of the vrDevice in babylon space. (default: 1)
  11987. */
  11988. positionScale?: number;
  11989. /**
  11990. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  11991. */
  11992. displayName?: string;
  11993. /**
  11994. * Should the native controller meshes be initialized. (default: true)
  11995. */
  11996. controllerMeshes?: boolean;
  11997. /**
  11998. * Creating a default HemiLight only on controllers. (default: true)
  11999. */
  12000. defaultLightingOnControllers?: boolean;
  12001. /**
  12002. * If you don't want to use the default VR button of the helper. (default: false)
  12003. */
  12004. useCustomVRButton?: boolean;
  12005. /**
  12006. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  12007. */
  12008. customVRButton?: HTMLButtonElement;
  12009. /**
  12010. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  12011. */
  12012. rayLength?: number;
  12013. /**
  12014. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  12015. */
  12016. defaultHeight?: number;
  12017. }
  12018. /**
  12019. * This represents a WebVR camera.
  12020. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  12021. * @example http://doc.babylonjs.com/how_to/webvr_camera
  12022. */
  12023. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  12024. private webVROptions;
  12025. /**
  12026. * @hidden
  12027. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  12028. */
  12029. _vrDevice: any;
  12030. /**
  12031. * The rawPose of the vrDevice.
  12032. */
  12033. rawPose: Nullable<DevicePose>;
  12034. private _onVREnabled;
  12035. private _specsVersion;
  12036. private _attached;
  12037. private _frameData;
  12038. protected _descendants: Array<Node>;
  12039. private _deviceRoomPosition;
  12040. /** @hidden */
  12041. _deviceRoomRotationQuaternion: Quaternion;
  12042. private _standingMatrix;
  12043. /**
  12044. * Represents device position in babylon space.
  12045. */
  12046. devicePosition: Vector3;
  12047. /**
  12048. * Represents device rotation in babylon space.
  12049. */
  12050. deviceRotationQuaternion: Quaternion;
  12051. /**
  12052. * The scale of the device to be used when translating from device space to babylon space.
  12053. */
  12054. deviceScaleFactor: number;
  12055. private _deviceToWorld;
  12056. private _worldToDevice;
  12057. /**
  12058. * References to the webVR controllers for the vrDevice.
  12059. */
  12060. controllers: Array<WebVRController>;
  12061. /**
  12062. * Emits an event when a controller is attached.
  12063. */
  12064. onControllersAttachedObservable: Observable<WebVRController[]>;
  12065. /**
  12066. * Emits an event when a controller's mesh has been loaded;
  12067. */
  12068. onControllerMeshLoadedObservable: Observable<WebVRController>;
  12069. /**
  12070. * Emits an event when the HMD's pose has been updated.
  12071. */
  12072. onPoseUpdatedFromDeviceObservable: Observable<any>;
  12073. private _poseSet;
  12074. /**
  12075. * If the rig cameras be used as parent instead of this camera.
  12076. */
  12077. rigParenting: boolean;
  12078. private _lightOnControllers;
  12079. private _defaultHeight?;
  12080. /**
  12081. * Instantiates a WebVRFreeCamera.
  12082. * @param name The name of the WebVRFreeCamera
  12083. * @param position The starting anchor position for the camera
  12084. * @param scene The scene the camera belongs to
  12085. * @param webVROptions a set of customizable options for the webVRCamera
  12086. */
  12087. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  12088. /**
  12089. * Gets the device distance from the ground in meters.
  12090. * @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.
  12091. */
  12092. deviceDistanceToRoomGround(): number;
  12093. /**
  12094. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  12095. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  12096. */
  12097. useStandingMatrix(callback?: (bool: boolean) => void): void;
  12098. /**
  12099. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  12100. * @returns A promise with a boolean set to if the standing matrix is supported.
  12101. */
  12102. useStandingMatrixAsync(): Promise<boolean>;
  12103. /**
  12104. * Disposes the camera
  12105. */
  12106. dispose(): void;
  12107. /**
  12108. * Gets a vrController by name.
  12109. * @param name The name of the controller to retreive
  12110. * @returns the controller matching the name specified or null if not found
  12111. */
  12112. getControllerByName(name: string): Nullable<WebVRController>;
  12113. private _leftController;
  12114. /**
  12115. * The controller corrisponding to the users left hand.
  12116. */
  12117. readonly leftController: Nullable<WebVRController>;
  12118. private _rightController;
  12119. /**
  12120. * The controller corrisponding to the users right hand.
  12121. */
  12122. readonly rightController: Nullable<WebVRController>;
  12123. /**
  12124. * Casts a ray forward from the vrCamera's gaze.
  12125. * @param length Length of the ray (default: 100)
  12126. * @returns the ray corrisponding to the gaze
  12127. */
  12128. getForwardRay(length?: number): Ray;
  12129. /**
  12130. * @hidden
  12131. * Updates the camera based on device's frame data
  12132. */
  12133. _checkInputs(): void;
  12134. /**
  12135. * Updates the poseControlled values based on the input device pose.
  12136. * @param poseData Pose coming from the device
  12137. */
  12138. updateFromDevice(poseData: DevicePose): void;
  12139. private _htmlElementAttached;
  12140. private _detachIfAttached;
  12141. /**
  12142. * WebVR's attach control will start broadcasting frames to the device.
  12143. * Note that in certain browsers (chrome for example) this function must be called
  12144. * within a user-interaction callback. Example:
  12145. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  12146. *
  12147. * @param element html element to attach the vrDevice to
  12148. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  12149. */
  12150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12151. /**
  12152. * Detaches the camera from the html element and disables VR
  12153. *
  12154. * @param element html element to detach from
  12155. */
  12156. detachControl(element: HTMLElement): void;
  12157. /**
  12158. * @returns the name of this class
  12159. */
  12160. getClassName(): string;
  12161. /**
  12162. * Calls resetPose on the vrDisplay
  12163. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  12164. */
  12165. resetToCurrentRotation(): void;
  12166. /**
  12167. * @hidden
  12168. * Updates the rig cameras (left and right eye)
  12169. */
  12170. _updateRigCameras(): void;
  12171. private _workingVector;
  12172. private _oneVector;
  12173. private _workingMatrix;
  12174. private updateCacheCalled;
  12175. private _correctPositionIfNotTrackPosition;
  12176. /**
  12177. * @hidden
  12178. * Updates the cached values of the camera
  12179. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  12180. */
  12181. _updateCache(ignoreParentClass?: boolean): void;
  12182. /**
  12183. * @hidden
  12184. * Get current device position in babylon world
  12185. */
  12186. _computeDevicePosition(): void;
  12187. /**
  12188. * Updates the current device position and rotation in the babylon world
  12189. */
  12190. update(): void;
  12191. /**
  12192. * @hidden
  12193. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  12194. * @returns an identity matrix
  12195. */
  12196. _getViewMatrix(): Matrix;
  12197. private _tmpMatrix;
  12198. /**
  12199. * This function is called by the two RIG cameras.
  12200. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  12201. */
  12202. protected _getWebVRViewMatrix(): Matrix;
  12203. protected _getWebVRProjectionMatrix(): Matrix;
  12204. private _onGamepadConnectedObserver;
  12205. private _onGamepadDisconnectedObserver;
  12206. private _updateCacheWhenTrackingDisabledObserver;
  12207. /**
  12208. * Initializes the controllers and their meshes
  12209. */
  12210. initControllers(): void;
  12211. }
  12212. }
  12213. declare module "babylonjs/PostProcesses/postProcess" {
  12214. import { Nullable } from "babylonjs/types";
  12215. import { SmartArray } from "babylonjs/Misc/smartArray";
  12216. import { Observable } from "babylonjs/Misc/observable";
  12217. import { Color4, Vector2 } from "babylonjs/Maths/math";
  12218. import { Camera } from "babylonjs/Cameras/camera";
  12219. import { Effect } from "babylonjs/Materials/effect";
  12220. import { Animation } from "babylonjs/Animations/animation";
  12221. import "babylonjs/Shaders/postprocess.vertex";
  12222. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12223. import { Engine } from "babylonjs/Engines/engine";
  12224. /**
  12225. * Size options for a post process
  12226. */
  12227. export type PostProcessOptions = {
  12228. width: number;
  12229. height: number;
  12230. };
  12231. /**
  12232. * PostProcess can be used to apply a shader to a texture after it has been rendered
  12233. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  12234. */
  12235. export class PostProcess {
  12236. /** Name of the PostProcess. */
  12237. name: string;
  12238. /**
  12239. * Width of the texture to apply the post process on
  12240. */
  12241. width: number;
  12242. /**
  12243. * Height of the texture to apply the post process on
  12244. */
  12245. height: number;
  12246. /**
  12247. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  12248. * @hidden
  12249. */
  12250. _outputTexture: Nullable<InternalTexture>;
  12251. /**
  12252. * Sampling mode used by the shader
  12253. * See https://doc.babylonjs.com/classes/3.1/texture
  12254. */
  12255. renderTargetSamplingMode: number;
  12256. /**
  12257. * Clear color to use when screen clearing
  12258. */
  12259. clearColor: Color4;
  12260. /**
  12261. * If the buffer needs to be cleared before applying the post process. (default: true)
  12262. * Should be set to false if shader will overwrite all previous pixels.
  12263. */
  12264. autoClear: boolean;
  12265. /**
  12266. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  12267. */
  12268. alphaMode: number;
  12269. /**
  12270. * Sets the setAlphaBlendConstants of the babylon engine
  12271. */
  12272. alphaConstants: Color4;
  12273. /**
  12274. * Animations to be used for the post processing
  12275. */
  12276. animations: Animation[];
  12277. /**
  12278. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  12279. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  12280. */
  12281. enablePixelPerfectMode: boolean;
  12282. /**
  12283. * Force the postprocess to be applied without taking in account viewport
  12284. */
  12285. forceFullscreenViewport: boolean;
  12286. /**
  12287. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  12288. *
  12289. * | Value | Type | Description |
  12290. * | ----- | ----------------------------------- | ----------- |
  12291. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  12292. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  12293. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  12294. *
  12295. */
  12296. scaleMode: number;
  12297. /**
  12298. * Force textures to be a power of two (default: false)
  12299. */
  12300. alwaysForcePOT: boolean;
  12301. private _samples;
  12302. /**
  12303. * Number of sample textures (default: 1)
  12304. */
  12305. samples: number;
  12306. /**
  12307. * Modify the scale of the post process to be the same as the viewport (default: false)
  12308. */
  12309. adaptScaleToCurrentViewport: boolean;
  12310. private _camera;
  12311. private _scene;
  12312. private _engine;
  12313. private _options;
  12314. private _reusable;
  12315. private _textureType;
  12316. /**
  12317. * Smart array of input and output textures for the post process.
  12318. * @hidden
  12319. */
  12320. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  12321. /**
  12322. * The index in _textures that corresponds to the output texture.
  12323. * @hidden
  12324. */
  12325. _currentRenderTextureInd: number;
  12326. private _effect;
  12327. private _samplers;
  12328. private _fragmentUrl;
  12329. private _vertexUrl;
  12330. private _parameters;
  12331. private _scaleRatio;
  12332. protected _indexParameters: any;
  12333. private _shareOutputWithPostProcess;
  12334. private _texelSize;
  12335. private _forcedOutputTexture;
  12336. /**
  12337. * An event triggered when the postprocess is activated.
  12338. */
  12339. onActivateObservable: Observable<Camera>;
  12340. private _onActivateObserver;
  12341. /**
  12342. * A function that is added to the onActivateObservable
  12343. */
  12344. onActivate: Nullable<(camera: Camera) => void>;
  12345. /**
  12346. * An event triggered when the postprocess changes its size.
  12347. */
  12348. onSizeChangedObservable: Observable<PostProcess>;
  12349. private _onSizeChangedObserver;
  12350. /**
  12351. * A function that is added to the onSizeChangedObservable
  12352. */
  12353. onSizeChanged: (postProcess: PostProcess) => void;
  12354. /**
  12355. * An event triggered when the postprocess applies its effect.
  12356. */
  12357. onApplyObservable: Observable<Effect>;
  12358. private _onApplyObserver;
  12359. /**
  12360. * A function that is added to the onApplyObservable
  12361. */
  12362. onApply: (effect: Effect) => void;
  12363. /**
  12364. * An event triggered before rendering the postprocess
  12365. */
  12366. onBeforeRenderObservable: Observable<Effect>;
  12367. private _onBeforeRenderObserver;
  12368. /**
  12369. * A function that is added to the onBeforeRenderObservable
  12370. */
  12371. onBeforeRender: (effect: Effect) => void;
  12372. /**
  12373. * An event triggered after rendering the postprocess
  12374. */
  12375. onAfterRenderObservable: Observable<Effect>;
  12376. private _onAfterRenderObserver;
  12377. /**
  12378. * A function that is added to the onAfterRenderObservable
  12379. */
  12380. onAfterRender: (efect: Effect) => void;
  12381. /**
  12382. * 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
  12383. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  12384. */
  12385. inputTexture: InternalTexture;
  12386. /**
  12387. * Gets the camera which post process is applied to.
  12388. * @returns The camera the post process is applied to.
  12389. */
  12390. getCamera(): Camera;
  12391. /**
  12392. * Gets the texel size of the postprocess.
  12393. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  12394. */
  12395. readonly texelSize: Vector2;
  12396. /**
  12397. * Creates a new instance PostProcess
  12398. * @param name The name of the PostProcess.
  12399. * @param fragmentUrl The url of the fragment shader to be used.
  12400. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  12401. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  12402. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12403. * @param camera The camera to apply the render pass to.
  12404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12405. * @param engine The engine which the post process will be applied. (default: current engine)
  12406. * @param reusable If the post process can be reused on the same frame. (default: false)
  12407. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  12408. * @param textureType Type of textures used when performing the post process. (default: 0)
  12409. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  12410. * @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
  12411. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  12412. */
  12413. constructor(
  12414. /** Name of the PostProcess. */
  12415. 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);
  12416. /**
  12417. * Gets the engine which this post process belongs to.
  12418. * @returns The engine the post process was enabled with.
  12419. */
  12420. getEngine(): Engine;
  12421. /**
  12422. * The effect that is created when initializing the post process.
  12423. * @returns The created effect corrisponding the the postprocess.
  12424. */
  12425. getEffect(): Effect;
  12426. /**
  12427. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  12428. * @param postProcess The post process to share the output with.
  12429. * @returns This post process.
  12430. */
  12431. shareOutputWith(postProcess: PostProcess): PostProcess;
  12432. /**
  12433. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  12434. * This should be called if the post process that shares output with this post process is disabled/disposed.
  12435. */
  12436. useOwnOutput(): void;
  12437. /**
  12438. * Updates the effect with the current post process compile time values and recompiles the shader.
  12439. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12440. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12441. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12442. * @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
  12443. * @param onCompiled Called when the shader has been compiled.
  12444. * @param onError Called if there is an error when compiling a shader.
  12445. */
  12446. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12447. /**
  12448. * The post process is reusable if it can be used multiple times within one frame.
  12449. * @returns If the post process is reusable
  12450. */
  12451. isReusable(): boolean;
  12452. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  12453. markTextureDirty(): void;
  12454. /**
  12455. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  12456. * 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.
  12457. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  12458. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  12459. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  12460. * @returns The target texture that was bound to be written to.
  12461. */
  12462. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  12463. /**
  12464. * If the post process is supported.
  12465. */
  12466. readonly isSupported: boolean;
  12467. /**
  12468. * The aspect ratio of the output texture.
  12469. */
  12470. readonly aspectRatio: number;
  12471. /**
  12472. * Get a value indicating if the post-process is ready to be used
  12473. * @returns true if the post-process is ready (shader is compiled)
  12474. */
  12475. isReady(): boolean;
  12476. /**
  12477. * Binds all textures and uniforms to the shader, this will be run on every pass.
  12478. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  12479. */
  12480. apply(): Nullable<Effect>;
  12481. private _disposeTextures;
  12482. /**
  12483. * Disposes the post process.
  12484. * @param camera The camera to dispose the post process on.
  12485. */
  12486. dispose(camera?: Camera): void;
  12487. }
  12488. }
  12489. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  12490. /** @hidden */
  12491. export var kernelBlurVaryingDeclaration: {
  12492. name: string;
  12493. shader: string;
  12494. };
  12495. }
  12496. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  12497. /** @hidden */
  12498. export var kernelBlurFragment: {
  12499. name: string;
  12500. shader: string;
  12501. };
  12502. }
  12503. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  12504. /** @hidden */
  12505. export var kernelBlurFragment2: {
  12506. name: string;
  12507. shader: string;
  12508. };
  12509. }
  12510. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  12511. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  12512. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  12513. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  12514. /** @hidden */
  12515. export var kernelBlurPixelShader: {
  12516. name: string;
  12517. shader: string;
  12518. };
  12519. }
  12520. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  12521. /** @hidden */
  12522. export var kernelBlurVertex: {
  12523. name: string;
  12524. shader: string;
  12525. };
  12526. }
  12527. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  12528. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  12529. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  12530. /** @hidden */
  12531. export var kernelBlurVertexShader: {
  12532. name: string;
  12533. shader: string;
  12534. };
  12535. }
  12536. declare module "babylonjs/PostProcesses/blurPostProcess" {
  12537. import { Vector2 } from "babylonjs/Maths/math";
  12538. import { Nullable } from "babylonjs/types";
  12539. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  12540. import { Camera } from "babylonjs/Cameras/camera";
  12541. import { Effect } from "babylonjs/Materials/effect";
  12542. import { Engine } from "babylonjs/Engines/engine";
  12543. import "babylonjs/Shaders/kernelBlur.fragment";
  12544. import "babylonjs/Shaders/kernelBlur.vertex";
  12545. /**
  12546. * The Blur Post Process which blurs an image based on a kernel and direction.
  12547. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  12548. */
  12549. export class BlurPostProcess extends PostProcess {
  12550. /** The direction in which to blur the image. */
  12551. direction: Vector2;
  12552. private blockCompilation;
  12553. protected _kernel: number;
  12554. protected _idealKernel: number;
  12555. protected _packedFloat: boolean;
  12556. private _staticDefines;
  12557. /**
  12558. * Sets the length in pixels of the blur sample region
  12559. */
  12560. /**
  12561. * Gets the length in pixels of the blur sample region
  12562. */
  12563. kernel: number;
  12564. /**
  12565. * Sets wether or not the blur needs to unpack/repack floats
  12566. */
  12567. /**
  12568. * Gets wether or not the blur is unpacking/repacking floats
  12569. */
  12570. packedFloat: boolean;
  12571. /**
  12572. * Creates a new instance BlurPostProcess
  12573. * @param name The name of the effect.
  12574. * @param direction The direction in which to blur the image.
  12575. * @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.
  12576. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12577. * @param camera The camera to apply the render pass to.
  12578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12579. * @param engine The engine which the post process will be applied. (default: current engine)
  12580. * @param reusable If the post process can be reused on the same frame. (default: false)
  12581. * @param textureType Type of textures used when performing the post process. (default: 0)
  12582. * @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)
  12583. */
  12584. constructor(name: string,
  12585. /** The direction in which to blur the image. */
  12586. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  12587. /**
  12588. * Updates the effect with the current post process compile time values and recompiles the shader.
  12589. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12590. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12591. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12592. * @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
  12593. * @param onCompiled Called when the shader has been compiled.
  12594. * @param onError Called if there is an error when compiling a shader.
  12595. */
  12596. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12597. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12598. /**
  12599. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  12600. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  12601. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  12602. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  12603. * The gaps between physical kernels are compensated for in the weighting of the samples
  12604. * @param idealKernel Ideal blur kernel.
  12605. * @return Nearest best kernel.
  12606. */
  12607. protected _nearestBestKernel(idealKernel: number): number;
  12608. /**
  12609. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  12610. * @param x The point on the Gaussian distribution to sample.
  12611. * @return the value of the Gaussian function at x.
  12612. */
  12613. protected _gaussianWeight(x: number): number;
  12614. /**
  12615. * Generates a string that can be used as a floating point number in GLSL.
  12616. * @param x Value to print.
  12617. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  12618. * @return GLSL float string.
  12619. */
  12620. protected _glslFloat(x: number, decimalFigures?: number): string;
  12621. }
  12622. }
  12623. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  12624. import { Scene } from "babylonjs/scene";
  12625. import { Plane } from "babylonjs/Maths/math";
  12626. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  12627. /**
  12628. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12629. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12630. * You can then easily use it as a reflectionTexture on a flat surface.
  12631. * In case the surface is not a plane, please consider relying on reflection probes.
  12632. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12633. */
  12634. export class MirrorTexture extends RenderTargetTexture {
  12635. private scene;
  12636. /**
  12637. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  12638. * 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.
  12639. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12640. */
  12641. mirrorPlane: Plane;
  12642. /**
  12643. * Define the blur ratio used to blur the reflection if needed.
  12644. */
  12645. blurRatio: number;
  12646. /**
  12647. * Define the adaptive blur kernel used to blur the reflection if needed.
  12648. * This will autocompute the closest best match for the `blurKernel`
  12649. */
  12650. adaptiveBlurKernel: number;
  12651. /**
  12652. * Define the blur kernel used to blur the reflection if needed.
  12653. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12654. */
  12655. blurKernel: number;
  12656. /**
  12657. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  12658. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12659. */
  12660. blurKernelX: number;
  12661. /**
  12662. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  12663. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12664. */
  12665. blurKernelY: number;
  12666. private _autoComputeBlurKernel;
  12667. protected _onRatioRescale(): void;
  12668. private _updateGammaSpace;
  12669. private _imageProcessingConfigChangeObserver;
  12670. private _transformMatrix;
  12671. private _mirrorMatrix;
  12672. private _savedViewMatrix;
  12673. private _blurX;
  12674. private _blurY;
  12675. private _adaptiveBlurKernel;
  12676. private _blurKernelX;
  12677. private _blurKernelY;
  12678. private _blurRatio;
  12679. /**
  12680. * Instantiates a Mirror Texture.
  12681. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12682. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12683. * You can then easily use it as a reflectionTexture on a flat surface.
  12684. * In case the surface is not a plane, please consider relying on reflection probes.
  12685. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12686. * @param name
  12687. * @param size
  12688. * @param scene
  12689. * @param generateMipMaps
  12690. * @param type
  12691. * @param samplingMode
  12692. * @param generateDepthBuffer
  12693. */
  12694. constructor(name: string, size: number | {
  12695. width: number;
  12696. height: number;
  12697. } | {
  12698. ratio: number;
  12699. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  12700. private _preparePostProcesses;
  12701. /**
  12702. * Clone the mirror texture.
  12703. * @returns the cloned texture
  12704. */
  12705. clone(): MirrorTexture;
  12706. /**
  12707. * Serialize the texture to a JSON representation you could use in Parse later on
  12708. * @returns the serialized JSON representation
  12709. */
  12710. serialize(): any;
  12711. /**
  12712. * Dispose the texture and release its associated resources.
  12713. */
  12714. dispose(): void;
  12715. }
  12716. }
  12717. declare module "babylonjs/Materials/Textures/texture" {
  12718. import { Observable } from "babylonjs/Misc/observable";
  12719. import { Nullable } from "babylonjs/types";
  12720. import { Scene } from "babylonjs/scene";
  12721. import { Matrix } from "babylonjs/Maths/math";
  12722. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12723. /**
  12724. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12725. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12726. */
  12727. export class Texture extends BaseTexture {
  12728. /** @hidden */
  12729. static _AnimationParser: (jsonAnimation: any) => import("babylonjs/Animations/animation").Animation;
  12730. /** @hidden */
  12731. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  12732. /** @hidden */
  12733. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  12734. /** @hidden */
  12735. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  12736. /** nearest is mag = nearest and min = nearest and mip = linear */
  12737. static readonly NEAREST_SAMPLINGMODE: number;
  12738. /** nearest is mag = nearest and min = nearest and mip = linear */
  12739. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  12740. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12741. static readonly BILINEAR_SAMPLINGMODE: number;
  12742. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12743. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  12744. /** Trilinear is mag = linear and min = linear and mip = linear */
  12745. static readonly TRILINEAR_SAMPLINGMODE: number;
  12746. /** Trilinear is mag = linear and min = linear and mip = linear */
  12747. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  12748. /** mag = nearest and min = nearest and mip = nearest */
  12749. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  12750. /** mag = nearest and min = linear and mip = nearest */
  12751. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  12752. /** mag = nearest and min = linear and mip = linear */
  12753. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  12754. /** mag = nearest and min = linear and mip = none */
  12755. static readonly NEAREST_LINEAR: number;
  12756. /** mag = nearest and min = nearest and mip = none */
  12757. static readonly NEAREST_NEAREST: number;
  12758. /** mag = linear and min = nearest and mip = nearest */
  12759. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  12760. /** mag = linear and min = nearest and mip = linear */
  12761. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  12762. /** mag = linear and min = linear and mip = none */
  12763. static readonly LINEAR_LINEAR: number;
  12764. /** mag = linear and min = nearest and mip = none */
  12765. static readonly LINEAR_NEAREST: number;
  12766. /** Explicit coordinates mode */
  12767. static readonly EXPLICIT_MODE: number;
  12768. /** Spherical coordinates mode */
  12769. static readonly SPHERICAL_MODE: number;
  12770. /** Planar coordinates mode */
  12771. static readonly PLANAR_MODE: number;
  12772. /** Cubic coordinates mode */
  12773. static readonly CUBIC_MODE: number;
  12774. /** Projection coordinates mode */
  12775. static readonly PROJECTION_MODE: number;
  12776. /** Inverse Cubic coordinates mode */
  12777. static readonly SKYBOX_MODE: number;
  12778. /** Inverse Cubic coordinates mode */
  12779. static readonly INVCUBIC_MODE: number;
  12780. /** Equirectangular coordinates mode */
  12781. static readonly EQUIRECTANGULAR_MODE: number;
  12782. /** Equirectangular Fixed coordinates mode */
  12783. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  12784. /** Equirectangular Fixed Mirrored coordinates mode */
  12785. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  12786. /** Texture is not repeating outside of 0..1 UVs */
  12787. static readonly CLAMP_ADDRESSMODE: number;
  12788. /** Texture is repeating outside of 0..1 UVs */
  12789. static readonly WRAP_ADDRESSMODE: number;
  12790. /** Texture is repeating and mirrored */
  12791. static readonly MIRROR_ADDRESSMODE: number;
  12792. /**
  12793. * 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
  12794. */
  12795. static UseSerializedUrlIfAny: boolean;
  12796. /**
  12797. * Define the url of the texture.
  12798. */
  12799. url: Nullable<string>;
  12800. /**
  12801. * Define an offset on the texture to offset the u coordinates of the UVs
  12802. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12803. */
  12804. uOffset: number;
  12805. /**
  12806. * Define an offset on the texture to offset the v coordinates of the UVs
  12807. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12808. */
  12809. vOffset: number;
  12810. /**
  12811. * Define an offset on the texture to scale the u coordinates of the UVs
  12812. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12813. */
  12814. uScale: number;
  12815. /**
  12816. * Define an offset on the texture to scale the v coordinates of the UVs
  12817. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12818. */
  12819. vScale: number;
  12820. /**
  12821. * Define an offset on the texture to rotate around the u coordinates of the UVs
  12822. * @see http://doc.babylonjs.com/how_to/more_materials
  12823. */
  12824. uAng: number;
  12825. /**
  12826. * Define an offset on the texture to rotate around the v coordinates of the UVs
  12827. * @see http://doc.babylonjs.com/how_to/more_materials
  12828. */
  12829. vAng: number;
  12830. /**
  12831. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  12832. * @see http://doc.babylonjs.com/how_to/more_materials
  12833. */
  12834. wAng: number;
  12835. /**
  12836. * Defines the center of rotation (U)
  12837. */
  12838. uRotationCenter: number;
  12839. /**
  12840. * Defines the center of rotation (V)
  12841. */
  12842. vRotationCenter: number;
  12843. /**
  12844. * Defines the center of rotation (W)
  12845. */
  12846. wRotationCenter: number;
  12847. /**
  12848. * Are mip maps generated for this texture or not.
  12849. */
  12850. readonly noMipmap: boolean;
  12851. private _noMipmap;
  12852. /** @hidden */
  12853. _invertY: boolean;
  12854. private _rowGenerationMatrix;
  12855. private _cachedTextureMatrix;
  12856. private _projectionModeMatrix;
  12857. private _t0;
  12858. private _t1;
  12859. private _t2;
  12860. private _cachedUOffset;
  12861. private _cachedVOffset;
  12862. private _cachedUScale;
  12863. private _cachedVScale;
  12864. private _cachedUAng;
  12865. private _cachedVAng;
  12866. private _cachedWAng;
  12867. private _cachedProjectionMatrixId;
  12868. private _cachedCoordinatesMode;
  12869. /** @hidden */
  12870. protected _initialSamplingMode: number;
  12871. /** @hidden */
  12872. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  12873. private _deleteBuffer;
  12874. protected _format: Nullable<number>;
  12875. private _delayedOnLoad;
  12876. private _delayedOnError;
  12877. /**
  12878. * Observable triggered once the texture has been loaded.
  12879. */
  12880. onLoadObservable: Observable<Texture>;
  12881. protected _isBlocking: boolean;
  12882. /**
  12883. * Is the texture preventing material to render while loading.
  12884. * If false, a default texture will be used instead of the loading one during the preparation step.
  12885. */
  12886. isBlocking: boolean;
  12887. /**
  12888. * Get the current sampling mode associated with the texture.
  12889. */
  12890. readonly samplingMode: number;
  12891. /**
  12892. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  12893. */
  12894. readonly invertY: boolean;
  12895. /**
  12896. * Instantiates a new texture.
  12897. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12898. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12899. * @param url define the url of the picture to load as a texture
  12900. * @param scene define the scene the texture will belong to
  12901. * @param noMipmap define if the texture will require mip maps or not
  12902. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12903. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12904. * @param onLoad define a callback triggered when the texture has been loaded
  12905. * @param onError define a callback triggered when an error occurred during the loading session
  12906. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12907. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12908. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12909. */
  12910. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  12911. /**
  12912. * Update the url (and optional buffer) of this texture if url was null during construction.
  12913. * @param url the url of the texture
  12914. * @param buffer the buffer of the texture (defaults to null)
  12915. * @param onLoad callback called when the texture is loaded (defaults to null)
  12916. */
  12917. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  12918. /**
  12919. * Finish the loading sequence of a texture flagged as delayed load.
  12920. * @hidden
  12921. */
  12922. delayLoad(): void;
  12923. private _prepareRowForTextureGeneration;
  12924. /**
  12925. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  12926. * @returns the transform matrix of the texture.
  12927. */
  12928. getTextureMatrix(): Matrix;
  12929. /**
  12930. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  12931. * @returns The reflection texture transform
  12932. */
  12933. getReflectionTextureMatrix(): Matrix;
  12934. /**
  12935. * Clones the texture.
  12936. * @returns the cloned texture
  12937. */
  12938. clone(): Texture;
  12939. /**
  12940. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  12941. * @returns The JSON representation of the texture
  12942. */
  12943. serialize(): any;
  12944. /**
  12945. * Get the current class name of the texture useful for serialization or dynamic coding.
  12946. * @returns "Texture"
  12947. */
  12948. getClassName(): string;
  12949. /**
  12950. * Dispose the texture and release its associated resources.
  12951. */
  12952. dispose(): void;
  12953. /**
  12954. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  12955. * @param parsedTexture Define the JSON representation of the texture
  12956. * @param scene Define the scene the parsed texture should be instantiated in
  12957. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  12958. * @returns The parsed texture if successful
  12959. */
  12960. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  12961. /**
  12962. * Creates a texture from its base 64 representation.
  12963. * @param data Define the base64 payload without the data: prefix
  12964. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12965. * @param scene Define the scene the texture should belong to
  12966. * @param noMipmap Forces the texture to not create mip map information if true
  12967. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12968. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12969. * @param onLoad define a callback triggered when the texture has been loaded
  12970. * @param onError define a callback triggered when an error occurred during the loading session
  12971. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12972. * @returns the created texture
  12973. */
  12974. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  12975. /**
  12976. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  12977. * @param data Define the base64 payload without the data: prefix
  12978. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12979. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12980. * @param scene Define the scene the texture should belong to
  12981. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12982. * @param noMipmap Forces the texture to not create mip map information if true
  12983. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12984. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12985. * @param onLoad define a callback triggered when the texture has been loaded
  12986. * @param onError define a callback triggered when an error occurred during the loading session
  12987. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12988. * @returns the created texture
  12989. */
  12990. 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;
  12991. }
  12992. }
  12993. declare module "babylonjs/PostProcesses/postProcessManager" {
  12994. import { Nullable } from "babylonjs/types";
  12995. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12996. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  12997. import { Scene } from "babylonjs/scene";
  12998. /**
  12999. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13000. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13001. */
  13002. export class PostProcessManager {
  13003. private _scene;
  13004. private _indexBuffer;
  13005. private _vertexBuffers;
  13006. /**
  13007. * Creates a new instance PostProcess
  13008. * @param scene The scene that the post process is associated with.
  13009. */
  13010. constructor(scene: Scene);
  13011. private _prepareBuffers;
  13012. private _buildIndexBuffer;
  13013. /**
  13014. * Rebuilds the vertex buffers of the manager.
  13015. * @hidden
  13016. */
  13017. _rebuild(): void;
  13018. /**
  13019. * Prepares a frame to be run through a post process.
  13020. * @param sourceTexture The input texture to the post procesess. (default: null)
  13021. * @param postProcesses An array of post processes to be run. (default: null)
  13022. * @returns True if the post processes were able to be run.
  13023. * @hidden
  13024. */
  13025. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13026. /**
  13027. * Manually render a set of post processes to a texture.
  13028. * @param postProcesses An array of post processes to be run.
  13029. * @param targetTexture The target texture to render to.
  13030. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13031. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13032. * @param lodLevel defines which lod of the texture to render to
  13033. */
  13034. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13035. /**
  13036. * Finalize the result of the output of the postprocesses.
  13037. * @param doNotPresent If true the result will not be displayed to the screen.
  13038. * @param targetTexture The target texture to render to.
  13039. * @param faceIndex The index of the face to bind the target texture to.
  13040. * @param postProcesses The array of post processes to render.
  13041. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13042. * @hidden
  13043. */
  13044. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13045. /**
  13046. * Disposes of the post process manager.
  13047. */
  13048. dispose(): void;
  13049. }
  13050. }
  13051. declare module "babylonjs/sceneComponent" {
  13052. import { Scene } from "babylonjs/scene";
  13053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13054. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13055. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  13056. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  13057. import { Nullable } from "babylonjs/types";
  13058. import { Camera } from "babylonjs/Cameras/camera";
  13059. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13060. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  13061. import { AbstractScene } from "babylonjs/abstractScene";
  13062. /**
  13063. * Groups all the scene component constants in one place to ease maintenance.
  13064. * @hidden
  13065. */
  13066. export class SceneComponentConstants {
  13067. static readonly NAME_EFFECTLAYER: string;
  13068. static readonly NAME_LAYER: string;
  13069. static readonly NAME_LENSFLARESYSTEM: string;
  13070. static readonly NAME_BOUNDINGBOXRENDERER: string;
  13071. static readonly NAME_PARTICLESYSTEM: string;
  13072. static readonly NAME_GAMEPAD: string;
  13073. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  13074. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  13075. static readonly NAME_DEPTHRENDERER: string;
  13076. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  13077. static readonly NAME_SPRITE: string;
  13078. static readonly NAME_OUTLINERENDERER: string;
  13079. static readonly NAME_PROCEDURALTEXTURE: string;
  13080. static readonly NAME_SHADOWGENERATOR: string;
  13081. static readonly NAME_OCTREE: string;
  13082. static readonly NAME_PHYSICSENGINE: string;
  13083. static readonly NAME_AUDIO: string;
  13084. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  13085. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  13086. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  13087. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  13088. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  13089. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  13090. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  13091. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  13092. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  13093. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  13094. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  13095. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  13096. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  13097. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  13098. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  13099. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  13100. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  13101. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  13102. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  13103. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  13104. static readonly STEP_AFTERRENDER_AUDIO: number;
  13105. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  13106. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  13107. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  13108. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  13109. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  13110. static readonly STEP_POINTERMOVE_SPRITE: number;
  13111. static readonly STEP_POINTERDOWN_SPRITE: number;
  13112. static readonly STEP_POINTERUP_SPRITE: number;
  13113. }
  13114. /**
  13115. * This represents a scene component.
  13116. *
  13117. * This is used to decouple the dependency the scene is having on the different workloads like
  13118. * layers, post processes...
  13119. */
  13120. export interface ISceneComponent {
  13121. /**
  13122. * The name of the component. Each component must have a unique name.
  13123. */
  13124. name: string;
  13125. /**
  13126. * The scene the component belongs to.
  13127. */
  13128. scene: Scene;
  13129. /**
  13130. * Register the component to one instance of a scene.
  13131. */
  13132. register(): void;
  13133. /**
  13134. * Rebuilds the elements related to this component in case of
  13135. * context lost for instance.
  13136. */
  13137. rebuild(): void;
  13138. /**
  13139. * Disposes the component and the associated ressources.
  13140. */
  13141. dispose(): void;
  13142. }
  13143. /**
  13144. * This represents a SERIALIZABLE scene component.
  13145. *
  13146. * This extends Scene Component to add Serialization methods on top.
  13147. */
  13148. export interface ISceneSerializableComponent extends ISceneComponent {
  13149. /**
  13150. * Adds all the element from the container to the scene
  13151. * @param container the container holding the elements
  13152. */
  13153. addFromContainer(container: AbstractScene): void;
  13154. /**
  13155. * Removes all the elements in the container from the scene
  13156. * @param container contains the elements to remove
  13157. */
  13158. removeFromContainer(container: AbstractScene): void;
  13159. /**
  13160. * Serializes the component data to the specified json object
  13161. * @param serializationObject The object to serialize to
  13162. */
  13163. serialize(serializationObject: any): void;
  13164. }
  13165. /**
  13166. * Strong typing of a Mesh related stage step action
  13167. */
  13168. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  13169. /**
  13170. * Strong typing of a Evaluate Sub Mesh related stage step action
  13171. */
  13172. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  13173. /**
  13174. * Strong typing of a Active Mesh related stage step action
  13175. */
  13176. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  13177. /**
  13178. * Strong typing of a Camera related stage step action
  13179. */
  13180. export type CameraStageAction = (camera: Camera) => void;
  13181. /**
  13182. * Strong typing of a Render Target related stage step action
  13183. */
  13184. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  13185. /**
  13186. * Strong typing of a RenderingGroup related stage step action
  13187. */
  13188. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  13189. /**
  13190. * Strong typing of a Mesh Render related stage step action
  13191. */
  13192. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  13193. /**
  13194. * Strong typing of a simple stage step action
  13195. */
  13196. export type SimpleStageAction = () => void;
  13197. /**
  13198. * Strong typing of a render target action.
  13199. */
  13200. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  13201. /**
  13202. * Strong typing of a pointer move action.
  13203. */
  13204. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  13205. /**
  13206. * Strong typing of a pointer up/down action.
  13207. */
  13208. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  13209. /**
  13210. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  13211. * @hidden
  13212. */
  13213. export class Stage<T extends Function> extends Array<{
  13214. index: number;
  13215. component: ISceneComponent;
  13216. action: T;
  13217. }> {
  13218. /**
  13219. * Hide ctor from the rest of the world.
  13220. * @param items The items to add.
  13221. */
  13222. private constructor();
  13223. /**
  13224. * Creates a new Stage.
  13225. * @returns A new instance of a Stage
  13226. */
  13227. static Create<T extends Function>(): Stage<T>;
  13228. /**
  13229. * Registers a step in an ordered way in the targeted stage.
  13230. * @param index Defines the position to register the step in
  13231. * @param component Defines the component attached to the step
  13232. * @param action Defines the action to launch during the step
  13233. */
  13234. registerStep(index: number, component: ISceneComponent, action: T): void;
  13235. /**
  13236. * Clears all the steps from the stage.
  13237. */
  13238. clear(): void;
  13239. }
  13240. }
  13241. declare module "babylonjs/Sprites/spriteSceneComponent" {
  13242. import { Nullable } from "babylonjs/types";
  13243. import { Observable } from "babylonjs/Misc/observable";
  13244. import { Scene } from "babylonjs/scene";
  13245. import { Sprite } from "babylonjs/Sprites/sprite";
  13246. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  13247. import { Ray } from "babylonjs/Culling/ray";
  13248. import { Camera } from "babylonjs/Cameras/camera";
  13249. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  13250. import { ISceneComponent } from "babylonjs/sceneComponent";
  13251. module "babylonjs/scene" {
  13252. interface Scene {
  13253. /** @hidden */
  13254. _pointerOverSprite: Nullable<Sprite>;
  13255. /** @hidden */
  13256. _pickedDownSprite: Nullable<Sprite>;
  13257. /** @hidden */
  13258. _tempSpritePickingRay: Nullable<Ray>;
  13259. /**
  13260. * All of the sprite managers added to this scene
  13261. * @see http://doc.babylonjs.com/babylon101/sprites
  13262. */
  13263. spriteManagers: Array<ISpriteManager>;
  13264. /**
  13265. * An event triggered when sprites rendering is about to start
  13266. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  13267. */
  13268. onBeforeSpritesRenderingObservable: Observable<Scene>;
  13269. /**
  13270. * An event triggered when sprites rendering is done
  13271. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  13272. */
  13273. onAfterSpritesRenderingObservable: Observable<Scene>;
  13274. /** @hidden */
  13275. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  13276. /** Launch a ray to try to pick a sprite in the scene
  13277. * @param x position on screen
  13278. * @param y position on screen
  13279. * @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
  13280. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  13281. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  13282. * @returns a PickingInfo
  13283. */
  13284. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  13285. /** Use the given ray to pick a sprite in the scene
  13286. * @param ray The ray (in world space) to use to pick meshes
  13287. * @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
  13288. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  13289. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  13290. * @returns a PickingInfo
  13291. */
  13292. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  13293. /**
  13294. * Force the sprite under the pointer
  13295. * @param sprite defines the sprite to use
  13296. */
  13297. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  13298. /**
  13299. * Gets the sprite under the pointer
  13300. * @returns a Sprite or null if no sprite is under the pointer
  13301. */
  13302. getPointerOverSprite(): Nullable<Sprite>;
  13303. }
  13304. }
  13305. /**
  13306. * Defines the sprite scene component responsible to manage sprites
  13307. * in a given scene.
  13308. */
  13309. export class SpriteSceneComponent implements ISceneComponent {
  13310. /**
  13311. * The component name helpfull to identify the component in the list of scene components.
  13312. */
  13313. readonly name: string;
  13314. /**
  13315. * The scene the component belongs to.
  13316. */
  13317. scene: Scene;
  13318. /** @hidden */
  13319. private _spritePredicate;
  13320. /**
  13321. * Creates a new instance of the component for the given scene
  13322. * @param scene Defines the scene to register the component in
  13323. */
  13324. constructor(scene: Scene);
  13325. /**
  13326. * Registers the component in a given scene
  13327. */
  13328. register(): void;
  13329. /**
  13330. * Rebuilds the elements related to this component in case of
  13331. * context lost for instance.
  13332. */
  13333. rebuild(): void;
  13334. /**
  13335. * Disposes the component and the associated ressources.
  13336. */
  13337. dispose(): void;
  13338. private _pickSpriteButKeepRay;
  13339. private _pointerMove;
  13340. private _pointerDown;
  13341. private _pointerUp;
  13342. }
  13343. }
  13344. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  13345. /** @hidden */
  13346. export var fogFragmentDeclaration: {
  13347. name: string;
  13348. shader: string;
  13349. };
  13350. }
  13351. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  13352. /** @hidden */
  13353. export var fogFragment: {
  13354. name: string;
  13355. shader: string;
  13356. };
  13357. }
  13358. declare module "babylonjs/Shaders/sprites.fragment" {
  13359. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  13360. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  13361. /** @hidden */
  13362. export var spritesPixelShader: {
  13363. name: string;
  13364. shader: string;
  13365. };
  13366. }
  13367. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  13368. /** @hidden */
  13369. export var fogVertexDeclaration: {
  13370. name: string;
  13371. shader: string;
  13372. };
  13373. }
  13374. declare module "babylonjs/Shaders/sprites.vertex" {
  13375. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  13376. /** @hidden */
  13377. export var spritesVertexShader: {
  13378. name: string;
  13379. shader: string;
  13380. };
  13381. }
  13382. declare module "babylonjs/Sprites/spriteManager" {
  13383. import { IDisposable, Scene } from "babylonjs/scene";
  13384. import { Nullable } from "babylonjs/types";
  13385. import { Observable } from "babylonjs/Misc/observable";
  13386. import { Sprite } from "babylonjs/Sprites/sprite";
  13387. import { Ray } from "babylonjs/Culling/ray";
  13388. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  13389. import { Camera } from "babylonjs/Cameras/camera";
  13390. import { Texture } from "babylonjs/Materials/Textures/texture";
  13391. import "babylonjs/Shaders/sprites.fragment";
  13392. import "babylonjs/Shaders/sprites.vertex";
  13393. /**
  13394. * Defines the minimum interface to fullfil in order to be a sprite manager.
  13395. */
  13396. export interface ISpriteManager extends IDisposable {
  13397. /**
  13398. * Restricts the camera to viewing objects with the same layerMask.
  13399. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  13400. */
  13401. layerMask: number;
  13402. /**
  13403. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  13404. */
  13405. isPickable: boolean;
  13406. /**
  13407. * Specifies the rendering group id for this mesh (0 by default)
  13408. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  13409. */
  13410. renderingGroupId: number;
  13411. /**
  13412. * Defines the list of sprites managed by the manager.
  13413. */
  13414. sprites: Array<Sprite>;
  13415. /**
  13416. * Tests the intersection of a sprite with a specific ray.
  13417. * @param ray The ray we are sending to test the collision
  13418. * @param camera The camera space we are sending rays in
  13419. * @param predicate A predicate allowing excluding sprites from the list of object to test
  13420. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  13421. * @returns picking info or null.
  13422. */
  13423. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  13424. /**
  13425. * Renders the list of sprites on screen.
  13426. */
  13427. render(): void;
  13428. }
  13429. /**
  13430. * Class used to manage multiple sprites on the same spritesheet
  13431. * @see http://doc.babylonjs.com/babylon101/sprites
  13432. */
  13433. export class SpriteManager implements ISpriteManager {
  13434. /** defines the manager's name */
  13435. name: string;
  13436. /** Gets the list of sprites */
  13437. sprites: Sprite[];
  13438. /** Gets or sets the rendering group id (0 by default) */
  13439. renderingGroupId: number;
  13440. /** Gets or sets camera layer mask */
  13441. layerMask: number;
  13442. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  13443. fogEnabled: boolean;
  13444. /** Gets or sets a boolean indicating if the sprites are pickable */
  13445. isPickable: boolean;
  13446. /** Defines the default width of a cell in the spritesheet */
  13447. cellWidth: number;
  13448. /** Defines the default height of a cell in the spritesheet */
  13449. cellHeight: number;
  13450. /**
  13451. * An event triggered when the manager is disposed.
  13452. */
  13453. onDisposeObservable: Observable<SpriteManager>;
  13454. private _onDisposeObserver;
  13455. /**
  13456. * Callback called when the manager is disposed
  13457. */
  13458. onDispose: () => void;
  13459. private _capacity;
  13460. private _spriteTexture;
  13461. private _epsilon;
  13462. private _scene;
  13463. private _vertexData;
  13464. private _buffer;
  13465. private _vertexBuffers;
  13466. private _indexBuffer;
  13467. private _effectBase;
  13468. private _effectFog;
  13469. /**
  13470. * Gets or sets the spritesheet texture
  13471. */
  13472. texture: Texture;
  13473. /**
  13474. * Creates a new sprite manager
  13475. * @param name defines the manager's name
  13476. * @param imgUrl defines the sprite sheet url
  13477. * @param capacity defines the maximum allowed number of sprites
  13478. * @param cellSize defines the size of a sprite cell
  13479. * @param scene defines the hosting scene
  13480. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  13481. * @param samplingMode defines the smapling mode to use with spritesheet
  13482. */
  13483. constructor(
  13484. /** defines the manager's name */
  13485. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  13486. private _appendSpriteVertex;
  13487. /**
  13488. * Intersects the sprites with a ray
  13489. * @param ray defines the ray to intersect with
  13490. * @param camera defines the current active camera
  13491. * @param predicate defines a predicate used to select candidate sprites
  13492. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  13493. * @returns null if no hit or a PickingInfo
  13494. */
  13495. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  13496. /**
  13497. * Render all child sprites
  13498. */
  13499. render(): void;
  13500. /**
  13501. * Release associated resources
  13502. */
  13503. dispose(): void;
  13504. }
  13505. }
  13506. declare module "babylonjs/Layers/layerSceneComponent" {
  13507. import { Scene } from "babylonjs/scene";
  13508. import { ISceneComponent } from "babylonjs/sceneComponent";
  13509. import { Layer } from "babylonjs/Layers/layer";
  13510. module "babylonjs/abstractScene" {
  13511. interface AbstractScene {
  13512. /**
  13513. * The list of layers (background and foreground) of the scene
  13514. */
  13515. layers: Array<Layer>;
  13516. }
  13517. }
  13518. /**
  13519. * Defines the layer scene component responsible to manage any layers
  13520. * in a given scene.
  13521. */
  13522. export class LayerSceneComponent implements ISceneComponent {
  13523. /**
  13524. * The component name helpfull to identify the component in the list of scene components.
  13525. */
  13526. readonly name: string;
  13527. /**
  13528. * The scene the component belongs to.
  13529. */
  13530. scene: Scene;
  13531. private _engine;
  13532. /**
  13533. * Creates a new instance of the component for the given scene
  13534. * @param scene Defines the scene to register the component in
  13535. */
  13536. constructor(scene: Scene);
  13537. /**
  13538. * Registers the component in a given scene
  13539. */
  13540. register(): void;
  13541. /**
  13542. * Rebuilds the elements related to this component in case of
  13543. * context lost for instance.
  13544. */
  13545. rebuild(): void;
  13546. /**
  13547. * Disposes the component and the associated ressources.
  13548. */
  13549. dispose(): void;
  13550. private _draw;
  13551. private _drawCameraPredicate;
  13552. private _drawCameraBackground;
  13553. private _drawCameraForeground;
  13554. private _drawRenderTargetPredicate;
  13555. private _drawRenderTargetBackground;
  13556. private _drawRenderTargetForeground;
  13557. }
  13558. }
  13559. declare module "babylonjs/Shaders/layer.fragment" {
  13560. /** @hidden */
  13561. export var layerPixelShader: {
  13562. name: string;
  13563. shader: string;
  13564. };
  13565. }
  13566. declare module "babylonjs/Shaders/layer.vertex" {
  13567. /** @hidden */
  13568. export var layerVertexShader: {
  13569. name: string;
  13570. shader: string;
  13571. };
  13572. }
  13573. declare module "babylonjs/Layers/layer" {
  13574. import { Observable } from "babylonjs/Misc/observable";
  13575. import { Nullable } from "babylonjs/types";
  13576. import { Scene } from "babylonjs/scene";
  13577. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13578. import { Texture } from "babylonjs/Materials/Textures/texture";
  13579. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13580. import "babylonjs/Shaders/layer.fragment";
  13581. import "babylonjs/Shaders/layer.vertex";
  13582. /**
  13583. * This represents a full screen 2d layer.
  13584. * This can be useful to display a picture in the background of your scene for instance.
  13585. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13586. */
  13587. export class Layer {
  13588. /**
  13589. * Define the name of the layer.
  13590. */
  13591. name: string;
  13592. /**
  13593. * Define the texture the layer should display.
  13594. */
  13595. texture: Nullable<Texture>;
  13596. /**
  13597. * Is the layer in background or foreground.
  13598. */
  13599. isBackground: boolean;
  13600. /**
  13601. * Define the color of the layer (instead of texture).
  13602. */
  13603. color: Color4;
  13604. /**
  13605. * Define the scale of the layer in order to zoom in out of the texture.
  13606. */
  13607. scale: Vector2;
  13608. /**
  13609. * Define an offset for the layer in order to shift the texture.
  13610. */
  13611. offset: Vector2;
  13612. /**
  13613. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13614. */
  13615. alphaBlendingMode: number;
  13616. /**
  13617. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13618. * Alpha test will not mix with the background color in case of transparency.
  13619. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13620. */
  13621. alphaTest: boolean;
  13622. /**
  13623. * Define a mask to restrict the layer to only some of the scene cameras.
  13624. */
  13625. layerMask: number;
  13626. /**
  13627. * Define the list of render target the layer is visible into.
  13628. */
  13629. renderTargetTextures: RenderTargetTexture[];
  13630. /**
  13631. * Define if the layer is only used in renderTarget or if it also
  13632. * renders in the main frame buffer of the canvas.
  13633. */
  13634. renderOnlyInRenderTargetTextures: boolean;
  13635. private _scene;
  13636. private _vertexBuffers;
  13637. private _indexBuffer;
  13638. private _effect;
  13639. private _alphaTestEffect;
  13640. /**
  13641. * An event triggered when the layer is disposed.
  13642. */
  13643. onDisposeObservable: Observable<Layer>;
  13644. private _onDisposeObserver;
  13645. /**
  13646. * Back compatibility with callback before the onDisposeObservable existed.
  13647. * The set callback will be triggered when the layer has been disposed.
  13648. */
  13649. onDispose: () => void;
  13650. /**
  13651. * An event triggered before rendering the scene
  13652. */
  13653. onBeforeRenderObservable: Observable<Layer>;
  13654. private _onBeforeRenderObserver;
  13655. /**
  13656. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13657. * The set callback will be triggered just before rendering the layer.
  13658. */
  13659. onBeforeRender: () => void;
  13660. /**
  13661. * An event triggered after rendering the scene
  13662. */
  13663. onAfterRenderObservable: Observable<Layer>;
  13664. private _onAfterRenderObserver;
  13665. /**
  13666. * Back compatibility with callback before the onAfterRenderObservable existed.
  13667. * The set callback will be triggered just after rendering the layer.
  13668. */
  13669. onAfterRender: () => void;
  13670. /**
  13671. * Instantiates a new layer.
  13672. * This represents a full screen 2d layer.
  13673. * This can be useful to display a picture in the background of your scene for instance.
  13674. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13675. * @param name Define the name of the layer in the scene
  13676. * @param imgUrl Define the url of the texture to display in the layer
  13677. * @param scene Define the scene the layer belongs to
  13678. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13679. * @param color Defines a color for the layer
  13680. */
  13681. constructor(
  13682. /**
  13683. * Define the name of the layer.
  13684. */
  13685. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13686. private _createIndexBuffer;
  13687. /** @hidden */
  13688. _rebuild(): void;
  13689. /**
  13690. * Renders the layer in the scene.
  13691. */
  13692. render(): void;
  13693. /**
  13694. * Disposes and releases the associated ressources.
  13695. */
  13696. dispose(): void;
  13697. }
  13698. }
  13699. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13700. import { Scene } from "babylonjs/scene";
  13701. import { ISceneComponent } from "babylonjs/sceneComponent";
  13702. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13703. module "babylonjs/abstractScene" {
  13704. interface AbstractScene {
  13705. /**
  13706. * The list of procedural textures added to the scene
  13707. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13708. */
  13709. proceduralTextures: Array<ProceduralTexture>;
  13710. }
  13711. }
  13712. /**
  13713. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13714. * in a given scene.
  13715. */
  13716. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13717. /**
  13718. * The component name helpfull to identify the component in the list of scene components.
  13719. */
  13720. readonly name: string;
  13721. /**
  13722. * The scene the component belongs to.
  13723. */
  13724. scene: Scene;
  13725. /**
  13726. * Creates a new instance of the component for the given scene
  13727. * @param scene Defines the scene to register the component in
  13728. */
  13729. constructor(scene: Scene);
  13730. /**
  13731. * Registers the component in a given scene
  13732. */
  13733. register(): void;
  13734. /**
  13735. * Rebuilds the elements related to this component in case of
  13736. * context lost for instance.
  13737. */
  13738. rebuild(): void;
  13739. /**
  13740. * Disposes the component and the associated ressources.
  13741. */
  13742. dispose(): void;
  13743. private _beforeClear;
  13744. }
  13745. }
  13746. declare module "babylonjs/Shaders/procedural.vertex" {
  13747. /** @hidden */
  13748. export var proceduralVertexShader: {
  13749. name: string;
  13750. shader: string;
  13751. };
  13752. }
  13753. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13754. import { Observable } from "babylonjs/Misc/observable";
  13755. import { Nullable } from "babylonjs/types";
  13756. import { Scene } from "babylonjs/scene";
  13757. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13758. import { Effect } from "babylonjs/Materials/effect";
  13759. import { Texture } from "babylonjs/Materials/Textures/texture";
  13760. import "babylonjs/Shaders/procedural.vertex";
  13761. /**
  13762. * 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.
  13763. * This is the base class of any Procedural texture and contains most of the shareable code.
  13764. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13765. */
  13766. export class ProceduralTexture extends Texture {
  13767. isCube: boolean;
  13768. /**
  13769. * Define if the texture is enabled or not (disabled texture will not render)
  13770. */
  13771. isEnabled: boolean;
  13772. /**
  13773. * Define if the texture must be cleared before rendering (default is true)
  13774. */
  13775. autoClear: boolean;
  13776. /**
  13777. * Callback called when the texture is generated
  13778. */
  13779. onGenerated: () => void;
  13780. /**
  13781. * Event raised when the texture is generated
  13782. */
  13783. onGeneratedObservable: Observable<ProceduralTexture>;
  13784. /** @hidden */
  13785. _generateMipMaps: boolean;
  13786. /** @hidden **/
  13787. _effect: Effect;
  13788. /** @hidden */
  13789. _textures: {
  13790. [key: string]: Texture;
  13791. };
  13792. private _size;
  13793. private _currentRefreshId;
  13794. private _refreshRate;
  13795. private _vertexBuffers;
  13796. private _indexBuffer;
  13797. private _uniforms;
  13798. private _samplers;
  13799. private _fragment;
  13800. private _floats;
  13801. private _ints;
  13802. private _floatsArrays;
  13803. private _colors3;
  13804. private _colors4;
  13805. private _vectors2;
  13806. private _vectors3;
  13807. private _matrices;
  13808. private _fallbackTexture;
  13809. private _fallbackTextureUsed;
  13810. private _engine;
  13811. private _cachedDefines;
  13812. private _contentUpdateId;
  13813. private _contentData;
  13814. /**
  13815. * Instantiates a new procedural texture.
  13816. * 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.
  13817. * This is the base class of any Procedural texture and contains most of the shareable code.
  13818. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13819. * @param name Define the name of the texture
  13820. * @param size Define the size of the texture to create
  13821. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13822. * @param scene Define the scene the texture belongs to
  13823. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13824. * @param generateMipMaps Define if the texture should creates mip maps or not
  13825. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13826. */
  13827. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13828. /**
  13829. * The effect that is created when initializing the post process.
  13830. * @returns The created effect corrisponding the the postprocess.
  13831. */
  13832. getEffect(): Effect;
  13833. /**
  13834. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13835. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13836. */
  13837. getContent(): Nullable<ArrayBufferView>;
  13838. private _createIndexBuffer;
  13839. /** @hidden */
  13840. _rebuild(): void;
  13841. /**
  13842. * Resets the texture in order to recreate its associated resources.
  13843. * This can be called in case of context loss
  13844. */
  13845. reset(): void;
  13846. protected _getDefines(): string;
  13847. /**
  13848. * Is the texture ready to be used ? (rendered at least once)
  13849. * @returns true if ready, otherwise, false.
  13850. */
  13851. isReady(): boolean;
  13852. /**
  13853. * Resets the refresh counter of the texture and start bak from scratch.
  13854. * Could be useful to regenerate the texture if it is setup to render only once.
  13855. */
  13856. resetRefreshCounter(): void;
  13857. /**
  13858. * Set the fragment shader to use in order to render the texture.
  13859. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13860. */
  13861. setFragment(fragment: any): void;
  13862. /**
  13863. * Define the refresh rate of the texture or the rendering frequency.
  13864. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13865. */
  13866. refreshRate: number;
  13867. /** @hidden */
  13868. _shouldRender(): boolean;
  13869. /**
  13870. * Get the size the texture is rendering at.
  13871. * @returns the size (texture is always squared)
  13872. */
  13873. getRenderSize(): number;
  13874. /**
  13875. * Resize the texture to new value.
  13876. * @param size Define the new size the texture should have
  13877. * @param generateMipMaps Define whether the new texture should create mip maps
  13878. */
  13879. resize(size: number, generateMipMaps: boolean): void;
  13880. private _checkUniform;
  13881. /**
  13882. * Set a texture in the shader program used to render.
  13883. * @param name Define the name of the uniform samplers as defined in the shader
  13884. * @param texture Define the texture to bind to this sampler
  13885. * @return the texture itself allowing "fluent" like uniform updates
  13886. */
  13887. setTexture(name: string, texture: Texture): ProceduralTexture;
  13888. /**
  13889. * Set a float in the shader.
  13890. * @param name Define the name of the uniform as defined in the shader
  13891. * @param value Define the value to give to the uniform
  13892. * @return the texture itself allowing "fluent" like uniform updates
  13893. */
  13894. setFloat(name: string, value: number): ProceduralTexture;
  13895. /**
  13896. * Set a int in the shader.
  13897. * @param name Define the name of the uniform as defined in the shader
  13898. * @param value Define the value to give to the uniform
  13899. * @return the texture itself allowing "fluent" like uniform updates
  13900. */
  13901. setInt(name: string, value: number): ProceduralTexture;
  13902. /**
  13903. * Set an array of floats in the shader.
  13904. * @param name Define the name of the uniform as defined in the shader
  13905. * @param value Define the value to give to the uniform
  13906. * @return the texture itself allowing "fluent" like uniform updates
  13907. */
  13908. setFloats(name: string, value: number[]): ProceduralTexture;
  13909. /**
  13910. * Set a vec3 in the shader from a Color3.
  13911. * @param name Define the name of the uniform as defined in the shader
  13912. * @param value Define the value to give to the uniform
  13913. * @return the texture itself allowing "fluent" like uniform updates
  13914. */
  13915. setColor3(name: string, value: Color3): ProceduralTexture;
  13916. /**
  13917. * Set a vec4 in the shader from a Color4.
  13918. * @param name Define the name of the uniform as defined in the shader
  13919. * @param value Define the value to give to the uniform
  13920. * @return the texture itself allowing "fluent" like uniform updates
  13921. */
  13922. setColor4(name: string, value: Color4): ProceduralTexture;
  13923. /**
  13924. * Set a vec2 in the shader from a Vector2.
  13925. * @param name Define the name of the uniform as defined in the shader
  13926. * @param value Define the value to give to the uniform
  13927. * @return the texture itself allowing "fluent" like uniform updates
  13928. */
  13929. setVector2(name: string, value: Vector2): ProceduralTexture;
  13930. /**
  13931. * Set a vec3 in the shader from a Vector3.
  13932. * @param name Define the name of the uniform as defined in the shader
  13933. * @param value Define the value to give to the uniform
  13934. * @return the texture itself allowing "fluent" like uniform updates
  13935. */
  13936. setVector3(name: string, value: Vector3): ProceduralTexture;
  13937. /**
  13938. * Set a mat4 in the shader from a MAtrix.
  13939. * @param name Define the name of the uniform as defined in the shader
  13940. * @param value Define the value to give to the uniform
  13941. * @return the texture itself allowing "fluent" like uniform updates
  13942. */
  13943. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13944. /**
  13945. * Render the texture to its associated render target.
  13946. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13947. */
  13948. render(useCameraPostProcess?: boolean): void;
  13949. /**
  13950. * Clone the texture.
  13951. * @returns the cloned texture
  13952. */
  13953. clone(): ProceduralTexture;
  13954. /**
  13955. * Dispose the texture and release its asoociated resources.
  13956. */
  13957. dispose(): void;
  13958. }
  13959. }
  13960. declare module "babylonjs/Particles/baseParticleSystem" {
  13961. import { Nullable } from "babylonjs/types";
  13962. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  13963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13964. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  13965. import { Texture } from "babylonjs/Materials/Textures/texture";
  13966. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13967. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13968. import { Scene } from "babylonjs/scene";
  13969. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  13970. import { Animation } from "babylonjs/Animations/animation";
  13971. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13972. /**
  13973. * This represents the base class for particle system in Babylon.
  13974. * 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.
  13975. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13976. * @example https://doc.babylonjs.com/babylon101/particles
  13977. */
  13978. export class BaseParticleSystem {
  13979. /**
  13980. * Source color is added to the destination color without alpha affecting the result
  13981. */
  13982. static BLENDMODE_ONEONE: number;
  13983. /**
  13984. * Blend current color and particle color using particle’s alpha
  13985. */
  13986. static BLENDMODE_STANDARD: number;
  13987. /**
  13988. * Add current color and particle color multiplied by particle’s alpha
  13989. */
  13990. static BLENDMODE_ADD: number;
  13991. /**
  13992. * Multiply current color with particle color
  13993. */
  13994. static BLENDMODE_MULTIPLY: number;
  13995. /**
  13996. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13997. */
  13998. static BLENDMODE_MULTIPLYADD: number;
  13999. /**
  14000. * List of animations used by the particle system.
  14001. */
  14002. animations: Animation[];
  14003. /**
  14004. * The id of the Particle system.
  14005. */
  14006. id: string;
  14007. /**
  14008. * The friendly name of the Particle system.
  14009. */
  14010. name: string;
  14011. /**
  14012. * The rendering group used by the Particle system to chose when to render.
  14013. */
  14014. renderingGroupId: number;
  14015. /**
  14016. * The emitter represents the Mesh or position we are attaching the particle system to.
  14017. */
  14018. emitter: Nullable<AbstractMesh | Vector3>;
  14019. /**
  14020. * The maximum number of particles to emit per frame
  14021. */
  14022. emitRate: number;
  14023. /**
  14024. * If you want to launch only a few particles at once, that can be done, as well.
  14025. */
  14026. manualEmitCount: number;
  14027. /**
  14028. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14029. */
  14030. updateSpeed: number;
  14031. /**
  14032. * The amount of time the particle system is running (depends of the overall update speed).
  14033. */
  14034. targetStopDuration: number;
  14035. /**
  14036. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14037. */
  14038. disposeOnStop: boolean;
  14039. /**
  14040. * Minimum power of emitting particles.
  14041. */
  14042. minEmitPower: number;
  14043. /**
  14044. * Maximum power of emitting particles.
  14045. */
  14046. maxEmitPower: number;
  14047. /**
  14048. * Minimum life time of emitting particles.
  14049. */
  14050. minLifeTime: number;
  14051. /**
  14052. * Maximum life time of emitting particles.
  14053. */
  14054. maxLifeTime: number;
  14055. /**
  14056. * Minimum Size of emitting particles.
  14057. */
  14058. minSize: number;
  14059. /**
  14060. * Maximum Size of emitting particles.
  14061. */
  14062. maxSize: number;
  14063. /**
  14064. * Minimum scale of emitting particles on X axis.
  14065. */
  14066. minScaleX: number;
  14067. /**
  14068. * Maximum scale of emitting particles on X axis.
  14069. */
  14070. maxScaleX: number;
  14071. /**
  14072. * Minimum scale of emitting particles on Y axis.
  14073. */
  14074. minScaleY: number;
  14075. /**
  14076. * Maximum scale of emitting particles on Y axis.
  14077. */
  14078. maxScaleY: number;
  14079. /**
  14080. * Gets or sets the minimal initial rotation in radians.
  14081. */
  14082. minInitialRotation: number;
  14083. /**
  14084. * Gets or sets the maximal initial rotation in radians.
  14085. */
  14086. maxInitialRotation: number;
  14087. /**
  14088. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14089. */
  14090. minAngularSpeed: number;
  14091. /**
  14092. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14093. */
  14094. maxAngularSpeed: number;
  14095. /**
  14096. * The texture used to render each particle. (this can be a spritesheet)
  14097. */
  14098. particleTexture: Nullable<Texture>;
  14099. /**
  14100. * The layer mask we are rendering the particles through.
  14101. */
  14102. layerMask: number;
  14103. /**
  14104. * This can help using your own shader to render the particle system.
  14105. * The according effect will be created
  14106. */
  14107. customShader: any;
  14108. /**
  14109. * By default particle system starts as soon as they are created. This prevents the
  14110. * automatic start to happen and let you decide when to start emitting particles.
  14111. */
  14112. preventAutoStart: boolean;
  14113. private _noiseTexture;
  14114. /**
  14115. * Gets or sets a texture used to add random noise to particle positions
  14116. */
  14117. noiseTexture: Nullable<ProceduralTexture>;
  14118. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14119. noiseStrength: Vector3;
  14120. /**
  14121. * Callback triggered when the particle animation is ending.
  14122. */
  14123. onAnimationEnd: Nullable<() => void>;
  14124. /**
  14125. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14126. */
  14127. blendMode: number;
  14128. /**
  14129. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14130. * to override the particles.
  14131. */
  14132. forceDepthWrite: boolean;
  14133. /** 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 */
  14134. preWarmCycles: number;
  14135. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14136. preWarmStepOffset: number;
  14137. /**
  14138. * 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)
  14139. */
  14140. spriteCellChangeSpeed: number;
  14141. /**
  14142. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14143. */
  14144. startSpriteCellID: number;
  14145. /**
  14146. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14147. */
  14148. endSpriteCellID: number;
  14149. /**
  14150. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14151. */
  14152. spriteCellWidth: number;
  14153. /**
  14154. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14155. */
  14156. spriteCellHeight: number;
  14157. /**
  14158. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14159. */
  14160. spriteRandomStartCell: boolean;
  14161. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14162. translationPivot: Vector2;
  14163. /** @hidden */
  14164. protected _isAnimationSheetEnabled: boolean;
  14165. /**
  14166. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14167. */
  14168. beginAnimationOnStart: boolean;
  14169. /**
  14170. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14171. */
  14172. beginAnimationFrom: number;
  14173. /**
  14174. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14175. */
  14176. beginAnimationTo: number;
  14177. /**
  14178. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14179. */
  14180. beginAnimationLoop: boolean;
  14181. /**
  14182. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14183. */
  14184. isAnimationSheetEnabled: boolean;
  14185. /**
  14186. * Get hosting scene
  14187. * @returns the scene
  14188. */
  14189. getScene(): Scene;
  14190. /**
  14191. * You can use gravity if you want to give an orientation to your particles.
  14192. */
  14193. gravity: Vector3;
  14194. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14195. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14196. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14197. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14198. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14199. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14200. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14201. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14202. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14203. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14204. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14205. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14206. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14207. /**
  14208. * Defines the delay in milliseconds before starting the system (0 by default)
  14209. */
  14210. startDelay: number;
  14211. /**
  14212. * Gets the current list of drag gradients.
  14213. * You must use addDragGradient and removeDragGradient to udpate this list
  14214. * @returns the list of drag gradients
  14215. */
  14216. getDragGradients(): Nullable<Array<FactorGradient>>;
  14217. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14218. limitVelocityDamping: number;
  14219. /**
  14220. * Gets the current list of limit velocity gradients.
  14221. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14222. * @returns the list of limit velocity gradients
  14223. */
  14224. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14225. /**
  14226. * Gets the current list of color gradients.
  14227. * You must use addColorGradient and removeColorGradient to udpate this list
  14228. * @returns the list of color gradients
  14229. */
  14230. getColorGradients(): Nullable<Array<ColorGradient>>;
  14231. /**
  14232. * Gets the current list of size gradients.
  14233. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14234. * @returns the list of size gradients
  14235. */
  14236. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14237. /**
  14238. * Gets the current list of color remap gradients.
  14239. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14240. * @returns the list of color remap gradients
  14241. */
  14242. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14243. /**
  14244. * Gets the current list of alpha remap gradients.
  14245. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14246. * @returns the list of alpha remap gradients
  14247. */
  14248. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14249. /**
  14250. * Gets the current list of life time gradients.
  14251. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14252. * @returns the list of life time gradients
  14253. */
  14254. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14255. /**
  14256. * Gets the current list of angular speed gradients.
  14257. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14258. * @returns the list of angular speed gradients
  14259. */
  14260. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14261. /**
  14262. * Gets the current list of velocity gradients.
  14263. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14264. * @returns the list of velocity gradients
  14265. */
  14266. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14267. /**
  14268. * Gets the current list of start size gradients.
  14269. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14270. * @returns the list of start size gradients
  14271. */
  14272. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14273. /**
  14274. * Gets the current list of emit rate gradients.
  14275. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14276. * @returns the list of emit rate gradients
  14277. */
  14278. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14279. /**
  14280. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14281. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14282. */
  14283. direction1: Vector3;
  14284. /**
  14285. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14286. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14287. */
  14288. direction2: Vector3;
  14289. /**
  14290. * 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.
  14291. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14292. */
  14293. minEmitBox: Vector3;
  14294. /**
  14295. * 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.
  14296. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14297. */
  14298. maxEmitBox: Vector3;
  14299. /**
  14300. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14301. */
  14302. color1: Color4;
  14303. /**
  14304. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14305. */
  14306. color2: Color4;
  14307. /**
  14308. * Color the particle will have at the end of its lifetime
  14309. */
  14310. colorDead: Color4;
  14311. /**
  14312. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14313. */
  14314. textureMask: Color4;
  14315. /**
  14316. * The particle emitter type defines the emitter used by the particle system.
  14317. * It can be for example box, sphere, or cone...
  14318. */
  14319. particleEmitterType: IParticleEmitterType;
  14320. /** @hidden */
  14321. _isSubEmitter: boolean;
  14322. /**
  14323. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14324. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14325. */
  14326. billboardMode: number;
  14327. protected _isBillboardBased: boolean;
  14328. /**
  14329. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14330. */
  14331. isBillboardBased: boolean;
  14332. /**
  14333. * The scene the particle system belongs to.
  14334. */
  14335. protected _scene: Scene;
  14336. /**
  14337. * Local cache of defines for image processing.
  14338. */
  14339. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14340. /**
  14341. * Default configuration related to image processing available in the standard Material.
  14342. */
  14343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14344. /**
  14345. * Gets the image processing configuration used either in this material.
  14346. */
  14347. /**
  14348. * Sets the Default image processing configuration used either in the this material.
  14349. *
  14350. * If sets to null, the scene one is in use.
  14351. */
  14352. imageProcessingConfiguration: ImageProcessingConfiguration;
  14353. /**
  14354. * Attaches a new image processing configuration to the Standard Material.
  14355. * @param configuration
  14356. */
  14357. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14358. /** @hidden */
  14359. protected _reset(): void;
  14360. /** @hidden */
  14361. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14362. /**
  14363. * Instantiates a particle system.
  14364. * 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.
  14365. * @param name The name of the particle system
  14366. */
  14367. constructor(name: string);
  14368. /**
  14369. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14370. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14371. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14372. * @returns the emitter
  14373. */
  14374. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14375. /**
  14376. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14377. * @param radius The radius of the hemisphere to emit from
  14378. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14379. * @returns the emitter
  14380. */
  14381. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14382. /**
  14383. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14384. * @param radius The radius of the sphere to emit from
  14385. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14386. * @returns the emitter
  14387. */
  14388. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14389. /**
  14390. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14391. * @param radius The radius of the sphere to emit from
  14392. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14393. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14394. * @returns the emitter
  14395. */
  14396. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14397. /**
  14398. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14399. * @param radius The radius of the emission cylinder
  14400. * @param height The height of the emission cylinder
  14401. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14402. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14403. * @returns the emitter
  14404. */
  14405. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14406. /**
  14407. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14408. * @param radius The radius of the cylinder to emit from
  14409. * @param height The height of the emission cylinder
  14410. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14411. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14412. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14413. * @returns the emitter
  14414. */
  14415. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14416. /**
  14417. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14418. * @param radius The radius of the cone to emit from
  14419. * @param angle The base angle of the cone
  14420. * @returns the emitter
  14421. */
  14422. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14423. /**
  14424. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14425. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14426. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14427. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14428. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14429. * @returns the emitter
  14430. */
  14431. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14432. }
  14433. }
  14434. declare module "babylonjs/Particles/subEmitter" {
  14435. import { Scene } from "babylonjs/scene";
  14436. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14437. /**
  14438. * Type of sub emitter
  14439. */
  14440. export enum SubEmitterType {
  14441. /**
  14442. * Attached to the particle over it's lifetime
  14443. */
  14444. ATTACHED = 0,
  14445. /**
  14446. * Created when the particle dies
  14447. */
  14448. END = 1
  14449. }
  14450. /**
  14451. * Sub emitter class used to emit particles from an existing particle
  14452. */
  14453. export class SubEmitter {
  14454. /**
  14455. * the particle system to be used by the sub emitter
  14456. */
  14457. particleSystem: ParticleSystem;
  14458. /**
  14459. * Type of the submitter (Default: END)
  14460. */
  14461. type: SubEmitterType;
  14462. /**
  14463. * 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)
  14464. * Note: This only is supported when using an emitter of type Mesh
  14465. */
  14466. inheritDirection: boolean;
  14467. /**
  14468. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14469. */
  14470. inheritedVelocityAmount: number;
  14471. /**
  14472. * Creates a sub emitter
  14473. * @param particleSystem the particle system to be used by the sub emitter
  14474. */
  14475. constructor(
  14476. /**
  14477. * the particle system to be used by the sub emitter
  14478. */
  14479. particleSystem: ParticleSystem);
  14480. /**
  14481. * Clones the sub emitter
  14482. * @returns the cloned sub emitter
  14483. */
  14484. clone(): SubEmitter;
  14485. /**
  14486. * Serialize current object to a JSON object
  14487. * @returns the serialized object
  14488. */
  14489. serialize(): any;
  14490. /** @hidden */
  14491. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14492. /**
  14493. * Creates a new SubEmitter from a serialized JSON version
  14494. * @param serializationObject defines the JSON object to read from
  14495. * @param scene defines the hosting scene
  14496. * @param rootUrl defines the rootUrl for data loading
  14497. * @returns a new SubEmitter
  14498. */
  14499. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14500. /** Release associated resources */
  14501. dispose(): void;
  14502. }
  14503. }
  14504. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14505. /** @hidden */
  14506. export var clipPlaneFragmentDeclaration: {
  14507. name: string;
  14508. shader: string;
  14509. };
  14510. }
  14511. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14512. /** @hidden */
  14513. export var imageProcessingDeclaration: {
  14514. name: string;
  14515. shader: string;
  14516. };
  14517. }
  14518. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14519. /** @hidden */
  14520. export var imageProcessingFunctions: {
  14521. name: string;
  14522. shader: string;
  14523. };
  14524. }
  14525. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14526. /** @hidden */
  14527. export var clipPlaneFragment: {
  14528. name: string;
  14529. shader: string;
  14530. };
  14531. }
  14532. declare module "babylonjs/Shaders/particles.fragment" {
  14533. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14534. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14535. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14536. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14537. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14538. /** @hidden */
  14539. export var particlesPixelShader: {
  14540. name: string;
  14541. shader: string;
  14542. };
  14543. }
  14544. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14545. /** @hidden */
  14546. export var clipPlaneVertexDeclaration: {
  14547. name: string;
  14548. shader: string;
  14549. };
  14550. }
  14551. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14552. /** @hidden */
  14553. export var clipPlaneVertex: {
  14554. name: string;
  14555. shader: string;
  14556. };
  14557. }
  14558. declare module "babylonjs/Shaders/particles.vertex" {
  14559. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14560. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14561. /** @hidden */
  14562. export var particlesVertexShader: {
  14563. name: string;
  14564. shader: string;
  14565. };
  14566. }
  14567. declare module "babylonjs/Particles/particleSystem" {
  14568. import { Nullable } from "babylonjs/types";
  14569. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14570. import { Observable } from "babylonjs/Misc/observable";
  14571. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14572. import { Effect } from "babylonjs/Materials/effect";
  14573. import { Scene, IDisposable } from "babylonjs/scene";
  14574. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14575. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14576. import { Particle } from "babylonjs/Particles/particle";
  14577. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14578. import "babylonjs/Shaders/particles.fragment";
  14579. import "babylonjs/Shaders/particles.vertex";
  14580. /**
  14581. * This represents a particle system in Babylon.
  14582. * 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.
  14583. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14584. * @example https://doc.babylonjs.com/babylon101/particles
  14585. */
  14586. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14587. /**
  14588. * Billboard mode will only apply to Y axis
  14589. */
  14590. static readonly BILLBOARDMODE_Y: number;
  14591. /**
  14592. * Billboard mode will apply to all axes
  14593. */
  14594. static readonly BILLBOARDMODE_ALL: number;
  14595. /**
  14596. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14597. */
  14598. static readonly BILLBOARDMODE_STRETCHED: number;
  14599. /**
  14600. * This function can be defined to provide custom update for active particles.
  14601. * This function will be called instead of regular update (age, position, color, etc.).
  14602. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14603. */
  14604. updateFunction: (particles: Particle[]) => void;
  14605. private _emitterWorldMatrix;
  14606. /**
  14607. * This function can be defined to specify initial direction for every new particle.
  14608. * It by default use the emitterType defined function
  14609. */
  14610. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14611. /**
  14612. * This function can be defined to specify initial position for every new particle.
  14613. * It by default use the emitterType defined function
  14614. */
  14615. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14616. /**
  14617. * @hidden
  14618. */
  14619. _inheritedVelocityOffset: Vector3;
  14620. /**
  14621. * An event triggered when the system is disposed
  14622. */
  14623. onDisposeObservable: Observable<ParticleSystem>;
  14624. private _onDisposeObserver;
  14625. /**
  14626. * Sets a callback that will be triggered when the system is disposed
  14627. */
  14628. onDispose: () => void;
  14629. private _particles;
  14630. private _epsilon;
  14631. private _capacity;
  14632. private _stockParticles;
  14633. private _newPartsExcess;
  14634. private _vertexData;
  14635. private _vertexBuffer;
  14636. private _vertexBuffers;
  14637. private _spriteBuffer;
  14638. private _indexBuffer;
  14639. private _effect;
  14640. private _customEffect;
  14641. private _cachedDefines;
  14642. private _scaledColorStep;
  14643. private _colorDiff;
  14644. private _scaledDirection;
  14645. private _scaledGravity;
  14646. private _currentRenderId;
  14647. private _alive;
  14648. private _useInstancing;
  14649. private _started;
  14650. private _stopped;
  14651. private _actualFrame;
  14652. private _scaledUpdateSpeed;
  14653. private _vertexBufferSize;
  14654. /** @hidden */
  14655. _currentEmitRateGradient: Nullable<FactorGradient>;
  14656. /** @hidden */
  14657. _currentEmitRate1: number;
  14658. /** @hidden */
  14659. _currentEmitRate2: number;
  14660. /** @hidden */
  14661. _currentStartSizeGradient: Nullable<FactorGradient>;
  14662. /** @hidden */
  14663. _currentStartSize1: number;
  14664. /** @hidden */
  14665. _currentStartSize2: number;
  14666. private readonly _rawTextureWidth;
  14667. private _rampGradientsTexture;
  14668. private _useRampGradients;
  14669. /** Gets or sets a boolean indicating that ramp gradients must be used
  14670. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14671. */
  14672. useRampGradients: boolean;
  14673. /**
  14674. * 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.
  14675. * 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: [])
  14676. */
  14677. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14678. private _subEmitters;
  14679. /**
  14680. * @hidden
  14681. * If the particle systems emitter should be disposed when the particle system is disposed
  14682. */
  14683. _disposeEmitterOnDispose: boolean;
  14684. /**
  14685. * The current active Sub-systems, this property is used by the root particle system only.
  14686. */
  14687. activeSubSystems: Array<ParticleSystem>;
  14688. private _rootParticleSystem;
  14689. /**
  14690. * Gets the current list of active particles
  14691. */
  14692. readonly particles: Particle[];
  14693. /**
  14694. * Returns the string "ParticleSystem"
  14695. * @returns a string containing the class name
  14696. */
  14697. getClassName(): string;
  14698. /**
  14699. * Instantiates a particle system.
  14700. * 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.
  14701. * @param name The name of the particle system
  14702. * @param capacity The max number of particles alive at the same time
  14703. * @param scene The scene the particle system belongs to
  14704. * @param customEffect a custom effect used to change the way particles are rendered by default
  14705. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14706. * @param epsilon Offset used to render the particles
  14707. */
  14708. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14709. private _addFactorGradient;
  14710. private _removeFactorGradient;
  14711. /**
  14712. * Adds a new life time gradient
  14713. * @param gradient defines the gradient to use (between 0 and 1)
  14714. * @param factor defines the life time factor to affect to the specified gradient
  14715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14716. * @returns the current particle system
  14717. */
  14718. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14719. /**
  14720. * Remove a specific life time gradient
  14721. * @param gradient defines the gradient to remove
  14722. * @returns the current particle system
  14723. */
  14724. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14725. /**
  14726. * Adds a new size gradient
  14727. * @param gradient defines the gradient to use (between 0 and 1)
  14728. * @param factor defines the size factor to affect to the specified gradient
  14729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14730. * @returns the current particle system
  14731. */
  14732. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14733. /**
  14734. * Remove a specific size gradient
  14735. * @param gradient defines the gradient to remove
  14736. * @returns the current particle system
  14737. */
  14738. removeSizeGradient(gradient: number): IParticleSystem;
  14739. /**
  14740. * Adds a new color remap gradient
  14741. * @param gradient defines the gradient to use (between 0 and 1)
  14742. * @param min defines the color remap minimal range
  14743. * @param max defines the color remap maximal range
  14744. * @returns the current particle system
  14745. */
  14746. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14747. /**
  14748. * Remove a specific color remap gradient
  14749. * @param gradient defines the gradient to remove
  14750. * @returns the current particle system
  14751. */
  14752. removeColorRemapGradient(gradient: number): IParticleSystem;
  14753. /**
  14754. * Adds a new alpha remap gradient
  14755. * @param gradient defines the gradient to use (between 0 and 1)
  14756. * @param min defines the alpha remap minimal range
  14757. * @param max defines the alpha remap maximal range
  14758. * @returns the current particle system
  14759. */
  14760. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14761. /**
  14762. * Remove a specific alpha remap gradient
  14763. * @param gradient defines the gradient to remove
  14764. * @returns the current particle system
  14765. */
  14766. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14767. /**
  14768. * Adds a new angular speed gradient
  14769. * @param gradient defines the gradient to use (between 0 and 1)
  14770. * @param factor defines the angular speed to affect to the specified gradient
  14771. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14772. * @returns the current particle system
  14773. */
  14774. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14775. /**
  14776. * Remove a specific angular speed gradient
  14777. * @param gradient defines the gradient to remove
  14778. * @returns the current particle system
  14779. */
  14780. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14781. /**
  14782. * Adds a new velocity gradient
  14783. * @param gradient defines the gradient to use (between 0 and 1)
  14784. * @param factor defines the velocity to affect to the specified gradient
  14785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14786. * @returns the current particle system
  14787. */
  14788. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14789. /**
  14790. * Remove a specific velocity gradient
  14791. * @param gradient defines the gradient to remove
  14792. * @returns the current particle system
  14793. */
  14794. removeVelocityGradient(gradient: number): IParticleSystem;
  14795. /**
  14796. * Adds a new limit velocity gradient
  14797. * @param gradient defines the gradient to use (between 0 and 1)
  14798. * @param factor defines the limit velocity value to affect to the specified gradient
  14799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14800. * @returns the current particle system
  14801. */
  14802. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14803. /**
  14804. * Remove a specific limit velocity gradient
  14805. * @param gradient defines the gradient to remove
  14806. * @returns the current particle system
  14807. */
  14808. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14809. /**
  14810. * Adds a new drag gradient
  14811. * @param gradient defines the gradient to use (between 0 and 1)
  14812. * @param factor defines the drag value to affect to the specified gradient
  14813. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14814. * @returns the current particle system
  14815. */
  14816. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14817. /**
  14818. * Remove a specific drag gradient
  14819. * @param gradient defines the gradient to remove
  14820. * @returns the current particle system
  14821. */
  14822. removeDragGradient(gradient: number): IParticleSystem;
  14823. /**
  14824. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14825. * @param gradient defines the gradient to use (between 0 and 1)
  14826. * @param factor defines the emit rate value to affect to the specified gradient
  14827. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14828. * @returns the current particle system
  14829. */
  14830. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14831. /**
  14832. * Remove a specific emit rate gradient
  14833. * @param gradient defines the gradient to remove
  14834. * @returns the current particle system
  14835. */
  14836. removeEmitRateGradient(gradient: number): IParticleSystem;
  14837. /**
  14838. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14839. * @param gradient defines the gradient to use (between 0 and 1)
  14840. * @param factor defines the start size value to affect to the specified gradient
  14841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14842. * @returns the current particle system
  14843. */
  14844. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14845. /**
  14846. * Remove a specific start size gradient
  14847. * @param gradient defines the gradient to remove
  14848. * @returns the current particle system
  14849. */
  14850. removeStartSizeGradient(gradient: number): IParticleSystem;
  14851. private _createRampGradientTexture;
  14852. /**
  14853. * Gets the current list of ramp gradients.
  14854. * You must use addRampGradient and removeRampGradient to udpate this list
  14855. * @returns the list of ramp gradients
  14856. */
  14857. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14858. /**
  14859. * Adds a new ramp gradient used to remap particle colors
  14860. * @param gradient defines the gradient to use (between 0 and 1)
  14861. * @param color defines the color to affect to the specified gradient
  14862. * @returns the current particle system
  14863. */
  14864. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14865. /**
  14866. * Remove a specific ramp gradient
  14867. * @param gradient defines the gradient to remove
  14868. * @returns the current particle system
  14869. */
  14870. removeRampGradient(gradient: number): ParticleSystem;
  14871. /**
  14872. * Adds a new color gradient
  14873. * @param gradient defines the gradient to use (between 0 and 1)
  14874. * @param color1 defines the color to affect to the specified gradient
  14875. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14876. * @returns this particle system
  14877. */
  14878. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14879. /**
  14880. * Remove a specific color gradient
  14881. * @param gradient defines the gradient to remove
  14882. * @returns this particle system
  14883. */
  14884. removeColorGradient(gradient: number): IParticleSystem;
  14885. private _fetchR;
  14886. protected _reset(): void;
  14887. private _resetEffect;
  14888. private _createVertexBuffers;
  14889. private _createIndexBuffer;
  14890. /**
  14891. * Gets the maximum number of particles active at the same time.
  14892. * @returns The max number of active particles.
  14893. */
  14894. getCapacity(): number;
  14895. /**
  14896. * Gets whether there are still active particles in the system.
  14897. * @returns True if it is alive, otherwise false.
  14898. */
  14899. isAlive(): boolean;
  14900. /**
  14901. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14902. * @returns True if it has been started, otherwise false.
  14903. */
  14904. isStarted(): boolean;
  14905. private _prepareSubEmitterInternalArray;
  14906. /**
  14907. * Starts the particle system and begins to emit
  14908. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14909. */
  14910. start(delay?: number): void;
  14911. /**
  14912. * Stops the particle system.
  14913. * @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.
  14914. */
  14915. stop(stopSubEmitters?: boolean): void;
  14916. /**
  14917. * Remove all active particles
  14918. */
  14919. reset(): void;
  14920. /**
  14921. * @hidden (for internal use only)
  14922. */
  14923. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14924. /**
  14925. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14926. * Its lifetime will start back at 0.
  14927. */
  14928. recycleParticle: (particle: Particle) => void;
  14929. private _stopSubEmitters;
  14930. private _createParticle;
  14931. private _removeFromRoot;
  14932. private _emitFromParticle;
  14933. private _update;
  14934. /** @hidden */
  14935. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14936. /** @hidden */
  14937. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14938. /** @hidden */
  14939. private _getEffect;
  14940. /**
  14941. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14942. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14943. */
  14944. animate(preWarmOnly?: boolean): void;
  14945. private _appendParticleVertices;
  14946. /**
  14947. * Rebuilds the particle system.
  14948. */
  14949. rebuild(): void;
  14950. /**
  14951. * Is this system ready to be used/rendered
  14952. * @return true if the system is ready
  14953. */
  14954. isReady(): boolean;
  14955. private _render;
  14956. /**
  14957. * Renders the particle system in its current state.
  14958. * @returns the current number of particles
  14959. */
  14960. render(): number;
  14961. /**
  14962. * Disposes the particle system and free the associated resources
  14963. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14964. */
  14965. dispose(disposeTexture?: boolean): void;
  14966. /**
  14967. * Clones the particle system.
  14968. * @param name The name of the cloned object
  14969. * @param newEmitter The new emitter to use
  14970. * @returns the cloned particle system
  14971. */
  14972. clone(name: string, newEmitter: any): ParticleSystem;
  14973. /**
  14974. * Serializes the particle system to a JSON object.
  14975. * @returns the JSON object
  14976. */
  14977. serialize(): any;
  14978. /** @hidden */
  14979. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14980. /** @hidden */
  14981. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14982. /**
  14983. * Parses a JSON object to create a particle system.
  14984. * @param parsedParticleSystem The JSON object to parse
  14985. * @param scene The scene to create the particle system in
  14986. * @param rootUrl The root url to use to load external dependencies like texture
  14987. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14988. * @returns the Parsed particle system
  14989. */
  14990. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14991. }
  14992. }
  14993. declare module "babylonjs/Particles/particle" {
  14994. import { Nullable } from "babylonjs/types";
  14995. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  14996. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14997. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14998. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  14999. /**
  15000. * A particle represents one of the element emitted by a particle system.
  15001. * This is mainly define by its coordinates, direction, velocity and age.
  15002. */
  15003. export class Particle {
  15004. /**
  15005. * The particle system the particle belongs to.
  15006. */
  15007. particleSystem: ParticleSystem;
  15008. private static _Count;
  15009. /**
  15010. * Unique ID of the particle
  15011. */
  15012. id: number;
  15013. /**
  15014. * The world position of the particle in the scene.
  15015. */
  15016. position: Vector3;
  15017. /**
  15018. * The world direction of the particle in the scene.
  15019. */
  15020. direction: Vector3;
  15021. /**
  15022. * The color of the particle.
  15023. */
  15024. color: Color4;
  15025. /**
  15026. * The color change of the particle per step.
  15027. */
  15028. colorStep: Color4;
  15029. /**
  15030. * Defines how long will the life of the particle be.
  15031. */
  15032. lifeTime: number;
  15033. /**
  15034. * The current age of the particle.
  15035. */
  15036. age: number;
  15037. /**
  15038. * The current size of the particle.
  15039. */
  15040. size: number;
  15041. /**
  15042. * The current scale of the particle.
  15043. */
  15044. scale: Vector2;
  15045. /**
  15046. * The current angle of the particle.
  15047. */
  15048. angle: number;
  15049. /**
  15050. * Defines how fast is the angle changing.
  15051. */
  15052. angularSpeed: number;
  15053. /**
  15054. * Defines the cell index used by the particle to be rendered from a sprite.
  15055. */
  15056. cellIndex: number;
  15057. /**
  15058. * The information required to support color remapping
  15059. */
  15060. remapData: Vector4;
  15061. /** @hidden */
  15062. _randomCellOffset?: number;
  15063. /** @hidden */
  15064. _initialDirection: Nullable<Vector3>;
  15065. /** @hidden */
  15066. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15067. /** @hidden */
  15068. _initialStartSpriteCellID: number;
  15069. /** @hidden */
  15070. _initialEndSpriteCellID: number;
  15071. /** @hidden */
  15072. _currentColorGradient: Nullable<ColorGradient>;
  15073. /** @hidden */
  15074. _currentColor1: Color4;
  15075. /** @hidden */
  15076. _currentColor2: Color4;
  15077. /** @hidden */
  15078. _currentSizeGradient: Nullable<FactorGradient>;
  15079. /** @hidden */
  15080. _currentSize1: number;
  15081. /** @hidden */
  15082. _currentSize2: number;
  15083. /** @hidden */
  15084. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15085. /** @hidden */
  15086. _currentAngularSpeed1: number;
  15087. /** @hidden */
  15088. _currentAngularSpeed2: number;
  15089. /** @hidden */
  15090. _currentVelocityGradient: Nullable<FactorGradient>;
  15091. /** @hidden */
  15092. _currentVelocity1: number;
  15093. /** @hidden */
  15094. _currentVelocity2: number;
  15095. /** @hidden */
  15096. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15097. /** @hidden */
  15098. _currentLimitVelocity1: number;
  15099. /** @hidden */
  15100. _currentLimitVelocity2: number;
  15101. /** @hidden */
  15102. _currentDragGradient: Nullable<FactorGradient>;
  15103. /** @hidden */
  15104. _currentDrag1: number;
  15105. /** @hidden */
  15106. _currentDrag2: number;
  15107. /** @hidden */
  15108. _randomNoiseCoordinates1: Vector3;
  15109. /** @hidden */
  15110. _randomNoiseCoordinates2: Vector3;
  15111. /**
  15112. * Creates a new instance Particle
  15113. * @param particleSystem the particle system the particle belongs to
  15114. */
  15115. constructor(
  15116. /**
  15117. * The particle system the particle belongs to.
  15118. */
  15119. particleSystem: ParticleSystem);
  15120. private updateCellInfoFromSystem;
  15121. /**
  15122. * Defines how the sprite cell index is updated for the particle
  15123. */
  15124. updateCellIndex(): void;
  15125. /** @hidden */
  15126. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15127. /** @hidden */
  15128. _inheritParticleInfoToSubEmitters(): void;
  15129. /** @hidden */
  15130. _reset(): void;
  15131. /**
  15132. * Copy the properties of particle to another one.
  15133. * @param other the particle to copy the information to.
  15134. */
  15135. copyTo(other: Particle): void;
  15136. }
  15137. }
  15138. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15139. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15140. import { Effect } from "babylonjs/Materials/effect";
  15141. import { Particle } from "babylonjs/Particles/particle";
  15142. /**
  15143. * Particle emitter represents a volume emitting particles.
  15144. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15145. */
  15146. export interface IParticleEmitterType {
  15147. /**
  15148. * Called by the particle System when the direction is computed for the created particle.
  15149. * @param worldMatrix is the world matrix of the particle system
  15150. * @param directionToUpdate is the direction vector to update with the result
  15151. * @param particle is the particle we are computed the direction for
  15152. */
  15153. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15154. /**
  15155. * Called by the particle System when the position is computed for the created particle.
  15156. * @param worldMatrix is the world matrix of the particle system
  15157. * @param positionToUpdate is the position vector to update with the result
  15158. * @param particle is the particle we are computed the position for
  15159. */
  15160. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15161. /**
  15162. * Clones the current emitter and returns a copy of it
  15163. * @returns the new emitter
  15164. */
  15165. clone(): IParticleEmitterType;
  15166. /**
  15167. * Called by the GPUParticleSystem to setup the update shader
  15168. * @param effect defines the update shader
  15169. */
  15170. applyToShader(effect: Effect): void;
  15171. /**
  15172. * Returns a string to use to update the GPU particles update shader
  15173. * @returns the effect defines string
  15174. */
  15175. getEffectDefines(): string;
  15176. /**
  15177. * Returns a string representing the class name
  15178. * @returns a string containing the class name
  15179. */
  15180. getClassName(): string;
  15181. /**
  15182. * Serializes the particle system to a JSON object.
  15183. * @returns the JSON object
  15184. */
  15185. serialize(): any;
  15186. /**
  15187. * Parse properties from a JSON object
  15188. * @param serializationObject defines the JSON object
  15189. */
  15190. parse(serializationObject: any): void;
  15191. }
  15192. }
  15193. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15194. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15195. import { Effect } from "babylonjs/Materials/effect";
  15196. import { Particle } from "babylonjs/Particles/particle";
  15197. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15198. /**
  15199. * Particle emitter emitting particles from the inside of a box.
  15200. * It emits the particles randomly between 2 given directions.
  15201. */
  15202. export class BoxParticleEmitter implements IParticleEmitterType {
  15203. /**
  15204. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15205. */
  15206. direction1: Vector3;
  15207. /**
  15208. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15209. */
  15210. direction2: Vector3;
  15211. /**
  15212. * 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.
  15213. */
  15214. minEmitBox: Vector3;
  15215. /**
  15216. * 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.
  15217. */
  15218. maxEmitBox: Vector3;
  15219. /**
  15220. * Creates a new instance BoxParticleEmitter
  15221. */
  15222. constructor();
  15223. /**
  15224. * Called by the particle System when the direction is computed for the created particle.
  15225. * @param worldMatrix is the world matrix of the particle system
  15226. * @param directionToUpdate is the direction vector to update with the result
  15227. * @param particle is the particle we are computed the direction for
  15228. */
  15229. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15230. /**
  15231. * Called by the particle System when the position is computed for the created particle.
  15232. * @param worldMatrix is the world matrix of the particle system
  15233. * @param positionToUpdate is the position vector to update with the result
  15234. * @param particle is the particle we are computed the position for
  15235. */
  15236. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15237. /**
  15238. * Clones the current emitter and returns a copy of it
  15239. * @returns the new emitter
  15240. */
  15241. clone(): BoxParticleEmitter;
  15242. /**
  15243. * Called by the GPUParticleSystem to setup the update shader
  15244. * @param effect defines the update shader
  15245. */
  15246. applyToShader(effect: Effect): void;
  15247. /**
  15248. * Returns a string to use to update the GPU particles update shader
  15249. * @returns a string containng the defines string
  15250. */
  15251. getEffectDefines(): string;
  15252. /**
  15253. * Returns the string "BoxParticleEmitter"
  15254. * @returns a string containing the class name
  15255. */
  15256. getClassName(): string;
  15257. /**
  15258. * Serializes the particle system to a JSON object.
  15259. * @returns the JSON object
  15260. */
  15261. serialize(): any;
  15262. /**
  15263. * Parse properties from a JSON object
  15264. * @param serializationObject defines the JSON object
  15265. */
  15266. parse(serializationObject: any): void;
  15267. }
  15268. }
  15269. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15270. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15271. import { Effect } from "babylonjs/Materials/effect";
  15272. import { Particle } from "babylonjs/Particles/particle";
  15273. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15274. /**
  15275. * Particle emitter emitting particles from the inside of a cone.
  15276. * It emits the particles alongside the cone volume from the base to the particle.
  15277. * The emission direction might be randomized.
  15278. */
  15279. export class ConeParticleEmitter implements IParticleEmitterType {
  15280. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15281. directionRandomizer: number;
  15282. private _radius;
  15283. private _angle;
  15284. private _height;
  15285. /**
  15286. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15287. */
  15288. radiusRange: number;
  15289. /**
  15290. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15291. */
  15292. heightRange: number;
  15293. /**
  15294. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15295. */
  15296. emitFromSpawnPointOnly: boolean;
  15297. /**
  15298. * Gets or sets the radius of the emission cone
  15299. */
  15300. radius: number;
  15301. /**
  15302. * Gets or sets the angle of the emission cone
  15303. */
  15304. angle: number;
  15305. private _buildHeight;
  15306. /**
  15307. * Creates a new instance ConeParticleEmitter
  15308. * @param radius the radius of the emission cone (1 by default)
  15309. * @param angles the cone base angle (PI by default)
  15310. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15311. */
  15312. constructor(radius?: number, angle?: number,
  15313. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15314. directionRandomizer?: number);
  15315. /**
  15316. * Called by the particle System when the direction is computed for the created particle.
  15317. * @param worldMatrix is the world matrix of the particle system
  15318. * @param directionToUpdate is the direction vector to update with the result
  15319. * @param particle is the particle we are computed the direction for
  15320. */
  15321. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15322. /**
  15323. * Called by the particle System when the position is computed for the created particle.
  15324. * @param worldMatrix is the world matrix of the particle system
  15325. * @param positionToUpdate is the position vector to update with the result
  15326. * @param particle is the particle we are computed the position for
  15327. */
  15328. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15329. /**
  15330. * Clones the current emitter and returns a copy of it
  15331. * @returns the new emitter
  15332. */
  15333. clone(): ConeParticleEmitter;
  15334. /**
  15335. * Called by the GPUParticleSystem to setup the update shader
  15336. * @param effect defines the update shader
  15337. */
  15338. applyToShader(effect: Effect): void;
  15339. /**
  15340. * Returns a string to use to update the GPU particles update shader
  15341. * @returns a string containng the defines string
  15342. */
  15343. getEffectDefines(): string;
  15344. /**
  15345. * Returns the string "ConeParticleEmitter"
  15346. * @returns a string containing the class name
  15347. */
  15348. getClassName(): string;
  15349. /**
  15350. * Serializes the particle system to a JSON object.
  15351. * @returns the JSON object
  15352. */
  15353. serialize(): any;
  15354. /**
  15355. * Parse properties from a JSON object
  15356. * @param serializationObject defines the JSON object
  15357. */
  15358. parse(serializationObject: any): void;
  15359. }
  15360. }
  15361. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15362. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15363. import { Effect } from "babylonjs/Materials/effect";
  15364. import { Particle } from "babylonjs/Particles/particle";
  15365. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15366. /**
  15367. * Particle emitter emitting particles from the inside of a cylinder.
  15368. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15369. */
  15370. export class CylinderParticleEmitter implements IParticleEmitterType {
  15371. /**
  15372. * The radius of the emission cylinder.
  15373. */
  15374. radius: number;
  15375. /**
  15376. * The height of the emission cylinder.
  15377. */
  15378. height: number;
  15379. /**
  15380. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15381. */
  15382. radiusRange: number;
  15383. /**
  15384. * How much to randomize the particle direction [0-1].
  15385. */
  15386. directionRandomizer: number;
  15387. /**
  15388. * Creates a new instance CylinderParticleEmitter
  15389. * @param radius the radius of the emission cylinder (1 by default)
  15390. * @param height the height of the emission cylinder (1 by default)
  15391. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15392. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15393. */
  15394. constructor(
  15395. /**
  15396. * The radius of the emission cylinder.
  15397. */
  15398. radius?: number,
  15399. /**
  15400. * The height of the emission cylinder.
  15401. */
  15402. height?: number,
  15403. /**
  15404. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15405. */
  15406. radiusRange?: number,
  15407. /**
  15408. * How much to randomize the particle direction [0-1].
  15409. */
  15410. directionRandomizer?: number);
  15411. /**
  15412. * Called by the particle System when the direction is computed for the created particle.
  15413. * @param worldMatrix is the world matrix of the particle system
  15414. * @param directionToUpdate is the direction vector to update with the result
  15415. * @param particle is the particle we are computed the direction for
  15416. */
  15417. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15418. /**
  15419. * Called by the particle System when the position is computed for the created particle.
  15420. * @param worldMatrix is the world matrix of the particle system
  15421. * @param positionToUpdate is the position vector to update with the result
  15422. * @param particle is the particle we are computed the position for
  15423. */
  15424. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15425. /**
  15426. * Clones the current emitter and returns a copy of it
  15427. * @returns the new emitter
  15428. */
  15429. clone(): CylinderParticleEmitter;
  15430. /**
  15431. * Called by the GPUParticleSystem to setup the update shader
  15432. * @param effect defines the update shader
  15433. */
  15434. applyToShader(effect: Effect): void;
  15435. /**
  15436. * Returns a string to use to update the GPU particles update shader
  15437. * @returns a string containng the defines string
  15438. */
  15439. getEffectDefines(): string;
  15440. /**
  15441. * Returns the string "CylinderParticleEmitter"
  15442. * @returns a string containing the class name
  15443. */
  15444. getClassName(): string;
  15445. /**
  15446. * Serializes the particle system to a JSON object.
  15447. * @returns the JSON object
  15448. */
  15449. serialize(): any;
  15450. /**
  15451. * Parse properties from a JSON object
  15452. * @param serializationObject defines the JSON object
  15453. */
  15454. parse(serializationObject: any): void;
  15455. }
  15456. /**
  15457. * Particle emitter emitting particles from the inside of a cylinder.
  15458. * It emits the particles randomly between two vectors.
  15459. */
  15460. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15461. /**
  15462. * The min limit of the emission direction.
  15463. */
  15464. direction1: Vector3;
  15465. /**
  15466. * The max limit of the emission direction.
  15467. */
  15468. direction2: Vector3;
  15469. /**
  15470. * Creates a new instance CylinderDirectedParticleEmitter
  15471. * @param radius the radius of the emission cylinder (1 by default)
  15472. * @param height the height of the emission cylinder (1 by default)
  15473. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15474. * @param direction1 the min limit of the emission direction (up vector by default)
  15475. * @param direction2 the max limit of the emission direction (up vector by default)
  15476. */
  15477. constructor(radius?: number, height?: number, radiusRange?: number,
  15478. /**
  15479. * The min limit of the emission direction.
  15480. */
  15481. direction1?: Vector3,
  15482. /**
  15483. * The max limit of the emission direction.
  15484. */
  15485. direction2?: Vector3);
  15486. /**
  15487. * Called by the particle System when the direction is computed for the created particle.
  15488. * @param worldMatrix is the world matrix of the particle system
  15489. * @param directionToUpdate is the direction vector to update with the result
  15490. * @param particle is the particle we are computed the direction for
  15491. */
  15492. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15493. /**
  15494. * Clones the current emitter and returns a copy of it
  15495. * @returns the new emitter
  15496. */
  15497. clone(): CylinderDirectedParticleEmitter;
  15498. /**
  15499. * Called by the GPUParticleSystem to setup the update shader
  15500. * @param effect defines the update shader
  15501. */
  15502. applyToShader(effect: Effect): void;
  15503. /**
  15504. * Returns a string to use to update the GPU particles update shader
  15505. * @returns a string containng the defines string
  15506. */
  15507. getEffectDefines(): string;
  15508. /**
  15509. * Returns the string "CylinderDirectedParticleEmitter"
  15510. * @returns a string containing the class name
  15511. */
  15512. getClassName(): string;
  15513. /**
  15514. * Serializes the particle system to a JSON object.
  15515. * @returns the JSON object
  15516. */
  15517. serialize(): any;
  15518. /**
  15519. * Parse properties from a JSON object
  15520. * @param serializationObject defines the JSON object
  15521. */
  15522. parse(serializationObject: any): void;
  15523. }
  15524. }
  15525. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15526. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15527. import { Effect } from "babylonjs/Materials/effect";
  15528. import { Particle } from "babylonjs/Particles/particle";
  15529. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15530. /**
  15531. * Particle emitter emitting particles from the inside of a hemisphere.
  15532. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15533. */
  15534. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15535. /**
  15536. * The radius of the emission hemisphere.
  15537. */
  15538. radius: number;
  15539. /**
  15540. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15541. */
  15542. radiusRange: number;
  15543. /**
  15544. * How much to randomize the particle direction [0-1].
  15545. */
  15546. directionRandomizer: number;
  15547. /**
  15548. * Creates a new instance HemisphericParticleEmitter
  15549. * @param radius the radius of the emission hemisphere (1 by default)
  15550. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15551. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15552. */
  15553. constructor(
  15554. /**
  15555. * The radius of the emission hemisphere.
  15556. */
  15557. radius?: number,
  15558. /**
  15559. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15560. */
  15561. radiusRange?: number,
  15562. /**
  15563. * How much to randomize the particle direction [0-1].
  15564. */
  15565. directionRandomizer?: number);
  15566. /**
  15567. * Called by the particle System when the direction is computed for the created particle.
  15568. * @param worldMatrix is the world matrix of the particle system
  15569. * @param directionToUpdate is the direction vector to update with the result
  15570. * @param particle is the particle we are computed the direction for
  15571. */
  15572. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15573. /**
  15574. * Called by the particle System when the position is computed for the created particle.
  15575. * @param worldMatrix is the world matrix of the particle system
  15576. * @param positionToUpdate is the position vector to update with the result
  15577. * @param particle is the particle we are computed the position for
  15578. */
  15579. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15580. /**
  15581. * Clones the current emitter and returns a copy of it
  15582. * @returns the new emitter
  15583. */
  15584. clone(): HemisphericParticleEmitter;
  15585. /**
  15586. * Called by the GPUParticleSystem to setup the update shader
  15587. * @param effect defines the update shader
  15588. */
  15589. applyToShader(effect: Effect): void;
  15590. /**
  15591. * Returns a string to use to update the GPU particles update shader
  15592. * @returns a string containng the defines string
  15593. */
  15594. getEffectDefines(): string;
  15595. /**
  15596. * Returns the string "HemisphericParticleEmitter"
  15597. * @returns a string containing the class name
  15598. */
  15599. getClassName(): string;
  15600. /**
  15601. * Serializes the particle system to a JSON object.
  15602. * @returns the JSON object
  15603. */
  15604. serialize(): any;
  15605. /**
  15606. * Parse properties from a JSON object
  15607. * @param serializationObject defines the JSON object
  15608. */
  15609. parse(serializationObject: any): void;
  15610. }
  15611. }
  15612. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15613. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15614. import { Effect } from "babylonjs/Materials/effect";
  15615. import { Particle } from "babylonjs/Particles/particle";
  15616. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15617. /**
  15618. * Particle emitter emitting particles from a point.
  15619. * It emits the particles randomly between 2 given directions.
  15620. */
  15621. export class PointParticleEmitter implements IParticleEmitterType {
  15622. /**
  15623. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15624. */
  15625. direction1: Vector3;
  15626. /**
  15627. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15628. */
  15629. direction2: Vector3;
  15630. /**
  15631. * Creates a new instance PointParticleEmitter
  15632. */
  15633. constructor();
  15634. /**
  15635. * Called by the particle System when the direction is computed for the created particle.
  15636. * @param worldMatrix is the world matrix of the particle system
  15637. * @param directionToUpdate is the direction vector to update with the result
  15638. * @param particle is the particle we are computed the direction for
  15639. */
  15640. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15641. /**
  15642. * Called by the particle System when the position is computed for the created particle.
  15643. * @param worldMatrix is the world matrix of the particle system
  15644. * @param positionToUpdate is the position vector to update with the result
  15645. * @param particle is the particle we are computed the position for
  15646. */
  15647. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15648. /**
  15649. * Clones the current emitter and returns a copy of it
  15650. * @returns the new emitter
  15651. */
  15652. clone(): PointParticleEmitter;
  15653. /**
  15654. * Called by the GPUParticleSystem to setup the update shader
  15655. * @param effect defines the update shader
  15656. */
  15657. applyToShader(effect: Effect): void;
  15658. /**
  15659. * Returns a string to use to update the GPU particles update shader
  15660. * @returns a string containng the defines string
  15661. */
  15662. getEffectDefines(): string;
  15663. /**
  15664. * Returns the string "PointParticleEmitter"
  15665. * @returns a string containing the class name
  15666. */
  15667. getClassName(): string;
  15668. /**
  15669. * Serializes the particle system to a JSON object.
  15670. * @returns the JSON object
  15671. */
  15672. serialize(): any;
  15673. /**
  15674. * Parse properties from a JSON object
  15675. * @param serializationObject defines the JSON object
  15676. */
  15677. parse(serializationObject: any): void;
  15678. }
  15679. }
  15680. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15681. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15682. import { Effect } from "babylonjs/Materials/effect";
  15683. import { Particle } from "babylonjs/Particles/particle";
  15684. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15685. /**
  15686. * Particle emitter emitting particles from the inside of a sphere.
  15687. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15688. */
  15689. export class SphereParticleEmitter implements IParticleEmitterType {
  15690. /**
  15691. * The radius of the emission sphere.
  15692. */
  15693. radius: number;
  15694. /**
  15695. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15696. */
  15697. radiusRange: number;
  15698. /**
  15699. * How much to randomize the particle direction [0-1].
  15700. */
  15701. directionRandomizer: number;
  15702. /**
  15703. * Creates a new instance SphereParticleEmitter
  15704. * @param radius the radius of the emission sphere (1 by default)
  15705. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15706. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15707. */
  15708. constructor(
  15709. /**
  15710. * The radius of the emission sphere.
  15711. */
  15712. radius?: number,
  15713. /**
  15714. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15715. */
  15716. radiusRange?: number,
  15717. /**
  15718. * How much to randomize the particle direction [0-1].
  15719. */
  15720. directionRandomizer?: number);
  15721. /**
  15722. * Called by the particle System when the direction is computed for the created particle.
  15723. * @param worldMatrix is the world matrix of the particle system
  15724. * @param directionToUpdate is the direction vector to update with the result
  15725. * @param particle is the particle we are computed the direction for
  15726. */
  15727. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15728. /**
  15729. * Called by the particle System when the position is computed for the created particle.
  15730. * @param worldMatrix is the world matrix of the particle system
  15731. * @param positionToUpdate is the position vector to update with the result
  15732. * @param particle is the particle we are computed the position for
  15733. */
  15734. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15735. /**
  15736. * Clones the current emitter and returns a copy of it
  15737. * @returns the new emitter
  15738. */
  15739. clone(): SphereParticleEmitter;
  15740. /**
  15741. * Called by the GPUParticleSystem to setup the update shader
  15742. * @param effect defines the update shader
  15743. */
  15744. applyToShader(effect: Effect): void;
  15745. /**
  15746. * Returns a string to use to update the GPU particles update shader
  15747. * @returns a string containng the defines string
  15748. */
  15749. getEffectDefines(): string;
  15750. /**
  15751. * Returns the string "SphereParticleEmitter"
  15752. * @returns a string containing the class name
  15753. */
  15754. getClassName(): string;
  15755. /**
  15756. * Serializes the particle system to a JSON object.
  15757. * @returns the JSON object
  15758. */
  15759. serialize(): any;
  15760. /**
  15761. * Parse properties from a JSON object
  15762. * @param serializationObject defines the JSON object
  15763. */
  15764. parse(serializationObject: any): void;
  15765. }
  15766. /**
  15767. * Particle emitter emitting particles from the inside of a sphere.
  15768. * It emits the particles randomly between two vectors.
  15769. */
  15770. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15771. /**
  15772. * The min limit of the emission direction.
  15773. */
  15774. direction1: Vector3;
  15775. /**
  15776. * The max limit of the emission direction.
  15777. */
  15778. direction2: Vector3;
  15779. /**
  15780. * Creates a new instance SphereDirectedParticleEmitter
  15781. * @param radius the radius of the emission sphere (1 by default)
  15782. * @param direction1 the min limit of the emission direction (up vector by default)
  15783. * @param direction2 the max limit of the emission direction (up vector by default)
  15784. */
  15785. constructor(radius?: number,
  15786. /**
  15787. * The min limit of the emission direction.
  15788. */
  15789. direction1?: Vector3,
  15790. /**
  15791. * The max limit of the emission direction.
  15792. */
  15793. direction2?: Vector3);
  15794. /**
  15795. * Called by the particle System when the direction is computed for the created particle.
  15796. * @param worldMatrix is the world matrix of the particle system
  15797. * @param directionToUpdate is the direction vector to update with the result
  15798. * @param particle is the particle we are computed the direction for
  15799. */
  15800. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15801. /**
  15802. * Clones the current emitter and returns a copy of it
  15803. * @returns the new emitter
  15804. */
  15805. clone(): SphereDirectedParticleEmitter;
  15806. /**
  15807. * Called by the GPUParticleSystem to setup the update shader
  15808. * @param effect defines the update shader
  15809. */
  15810. applyToShader(effect: Effect): void;
  15811. /**
  15812. * Returns a string to use to update the GPU particles update shader
  15813. * @returns a string containng the defines string
  15814. */
  15815. getEffectDefines(): string;
  15816. /**
  15817. * Returns the string "SphereDirectedParticleEmitter"
  15818. * @returns a string containing the class name
  15819. */
  15820. getClassName(): string;
  15821. /**
  15822. * Serializes the particle system to a JSON object.
  15823. * @returns the JSON object
  15824. */
  15825. serialize(): any;
  15826. /**
  15827. * Parse properties from a JSON object
  15828. * @param serializationObject defines the JSON object
  15829. */
  15830. parse(serializationObject: any): void;
  15831. }
  15832. }
  15833. declare module "babylonjs/Particles/EmitterTypes/index" {
  15834. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15835. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15836. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15837. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15838. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15839. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15840. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15841. }
  15842. declare module "babylonjs/Particles/IParticleSystem" {
  15843. import { Nullable } from "babylonjs/types";
  15844. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15846. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15847. import { Texture } from "babylonjs/Materials/Textures/texture";
  15848. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15849. import { Scene } from "babylonjs/scene";
  15850. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15851. import { Animation } from "babylonjs/Animations/animation";
  15852. /**
  15853. * Interface representing a particle system in Babylon.js.
  15854. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15855. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15856. */
  15857. export interface IParticleSystem {
  15858. /**
  15859. * List of animations used by the particle system.
  15860. */
  15861. animations: Animation[];
  15862. /**
  15863. * The id of the Particle system.
  15864. */
  15865. id: string;
  15866. /**
  15867. * The name of the Particle system.
  15868. */
  15869. name: string;
  15870. /**
  15871. * The emitter represents the Mesh or position we are attaching the particle system to.
  15872. */
  15873. emitter: Nullable<AbstractMesh | Vector3>;
  15874. /**
  15875. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15876. */
  15877. isBillboardBased: boolean;
  15878. /**
  15879. * The rendering group used by the Particle system to chose when to render.
  15880. */
  15881. renderingGroupId: number;
  15882. /**
  15883. * The layer mask we are rendering the particles through.
  15884. */
  15885. layerMask: number;
  15886. /**
  15887. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15888. */
  15889. updateSpeed: number;
  15890. /**
  15891. * The amount of time the particle system is running (depends of the overall update speed).
  15892. */
  15893. targetStopDuration: number;
  15894. /**
  15895. * The texture used to render each particle. (this can be a spritesheet)
  15896. */
  15897. particleTexture: Nullable<Texture>;
  15898. /**
  15899. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15900. */
  15901. blendMode: number;
  15902. /**
  15903. * Minimum life time of emitting particles.
  15904. */
  15905. minLifeTime: number;
  15906. /**
  15907. * Maximum life time of emitting particles.
  15908. */
  15909. maxLifeTime: number;
  15910. /**
  15911. * Minimum Size of emitting particles.
  15912. */
  15913. minSize: number;
  15914. /**
  15915. * Maximum Size of emitting particles.
  15916. */
  15917. maxSize: number;
  15918. /**
  15919. * Minimum scale of emitting particles on X axis.
  15920. */
  15921. minScaleX: number;
  15922. /**
  15923. * Maximum scale of emitting particles on X axis.
  15924. */
  15925. maxScaleX: number;
  15926. /**
  15927. * Minimum scale of emitting particles on Y axis.
  15928. */
  15929. minScaleY: number;
  15930. /**
  15931. * Maximum scale of emitting particles on Y axis.
  15932. */
  15933. maxScaleY: number;
  15934. /**
  15935. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15936. */
  15937. color1: Color4;
  15938. /**
  15939. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15940. */
  15941. color2: Color4;
  15942. /**
  15943. * Color the particle will have at the end of its lifetime.
  15944. */
  15945. colorDead: Color4;
  15946. /**
  15947. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15948. */
  15949. emitRate: number;
  15950. /**
  15951. * You can use gravity if you want to give an orientation to your particles.
  15952. */
  15953. gravity: Vector3;
  15954. /**
  15955. * Minimum power of emitting particles.
  15956. */
  15957. minEmitPower: number;
  15958. /**
  15959. * Maximum power of emitting particles.
  15960. */
  15961. maxEmitPower: number;
  15962. /**
  15963. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15964. */
  15965. minAngularSpeed: number;
  15966. /**
  15967. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15968. */
  15969. maxAngularSpeed: number;
  15970. /**
  15971. * Gets or sets the minimal initial rotation in radians.
  15972. */
  15973. minInitialRotation: number;
  15974. /**
  15975. * Gets or sets the maximal initial rotation in radians.
  15976. */
  15977. maxInitialRotation: number;
  15978. /**
  15979. * The particle emitter type defines the emitter used by the particle system.
  15980. * It can be for example box, sphere, or cone...
  15981. */
  15982. particleEmitterType: Nullable<IParticleEmitterType>;
  15983. /**
  15984. * Defines the delay in milliseconds before starting the system (0 by default)
  15985. */
  15986. startDelay: number;
  15987. /**
  15988. * 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
  15989. */
  15990. preWarmCycles: number;
  15991. /**
  15992. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15993. */
  15994. preWarmStepOffset: number;
  15995. /**
  15996. * 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)
  15997. */
  15998. spriteCellChangeSpeed: number;
  15999. /**
  16000. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16001. */
  16002. startSpriteCellID: number;
  16003. /**
  16004. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16005. */
  16006. endSpriteCellID: number;
  16007. /**
  16008. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16009. */
  16010. spriteCellWidth: number;
  16011. /**
  16012. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16013. */
  16014. spriteCellHeight: number;
  16015. /**
  16016. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16017. */
  16018. spriteRandomStartCell: boolean;
  16019. /**
  16020. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16021. */
  16022. isAnimationSheetEnabled: boolean;
  16023. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16024. translationPivot: Vector2;
  16025. /**
  16026. * Gets or sets a texture used to add random noise to particle positions
  16027. */
  16028. noiseTexture: Nullable<BaseTexture>;
  16029. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16030. noiseStrength: Vector3;
  16031. /**
  16032. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16033. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16034. */
  16035. billboardMode: number;
  16036. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16037. limitVelocityDamping: number;
  16038. /**
  16039. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16040. */
  16041. beginAnimationOnStart: boolean;
  16042. /**
  16043. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16044. */
  16045. beginAnimationFrom: number;
  16046. /**
  16047. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16048. */
  16049. beginAnimationTo: number;
  16050. /**
  16051. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16052. */
  16053. beginAnimationLoop: boolean;
  16054. /**
  16055. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16056. */
  16057. disposeOnStop: boolean;
  16058. /**
  16059. * Gets the maximum number of particles active at the same time.
  16060. * @returns The max number of active particles.
  16061. */
  16062. getCapacity(): number;
  16063. /**
  16064. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16065. * @returns True if it has been started, otherwise false.
  16066. */
  16067. isStarted(): boolean;
  16068. /**
  16069. * Animates the particle system for this frame.
  16070. */
  16071. animate(): void;
  16072. /**
  16073. * Renders the particle system in its current state.
  16074. * @returns the current number of particles
  16075. */
  16076. render(): number;
  16077. /**
  16078. * Dispose the particle system and frees its associated resources.
  16079. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16080. */
  16081. dispose(disposeTexture?: boolean): void;
  16082. /**
  16083. * Clones the particle system.
  16084. * @param name The name of the cloned object
  16085. * @param newEmitter The new emitter to use
  16086. * @returns the cloned particle system
  16087. */
  16088. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16089. /**
  16090. * Serializes the particle system to a JSON object.
  16091. * @returns the JSON object
  16092. */
  16093. serialize(): any;
  16094. /**
  16095. * Rebuild the particle system
  16096. */
  16097. rebuild(): void;
  16098. /**
  16099. * Starts the particle system and begins to emit
  16100. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16101. */
  16102. start(delay?: number): void;
  16103. /**
  16104. * Stops the particle system.
  16105. */
  16106. stop(): void;
  16107. /**
  16108. * Remove all active particles
  16109. */
  16110. reset(): void;
  16111. /**
  16112. * Is this system ready to be used/rendered
  16113. * @return true if the system is ready
  16114. */
  16115. isReady(): boolean;
  16116. /**
  16117. * Adds a new color gradient
  16118. * @param gradient defines the gradient to use (between 0 and 1)
  16119. * @param color1 defines the color to affect to the specified gradient
  16120. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16121. * @returns the current particle system
  16122. */
  16123. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16124. /**
  16125. * Remove a specific color gradient
  16126. * @param gradient defines the gradient to remove
  16127. * @returns the current particle system
  16128. */
  16129. removeColorGradient(gradient: number): IParticleSystem;
  16130. /**
  16131. * Adds a new size gradient
  16132. * @param gradient defines the gradient to use (between 0 and 1)
  16133. * @param factor defines the size factor to affect to the specified gradient
  16134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16135. * @returns the current particle system
  16136. */
  16137. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16138. /**
  16139. * Remove a specific size gradient
  16140. * @param gradient defines the gradient to remove
  16141. * @returns the current particle system
  16142. */
  16143. removeSizeGradient(gradient: number): IParticleSystem;
  16144. /**
  16145. * Gets the current list of color gradients.
  16146. * You must use addColorGradient and removeColorGradient to udpate this list
  16147. * @returns the list of color gradients
  16148. */
  16149. getColorGradients(): Nullable<Array<ColorGradient>>;
  16150. /**
  16151. * Gets the current list of size gradients.
  16152. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16153. * @returns the list of size gradients
  16154. */
  16155. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16156. /**
  16157. * Gets the current list of angular speed gradients.
  16158. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16159. * @returns the list of angular speed gradients
  16160. */
  16161. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16162. /**
  16163. * Adds a new angular speed gradient
  16164. * @param gradient defines the gradient to use (between 0 and 1)
  16165. * @param factor defines the angular speed to affect to the specified gradient
  16166. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16167. * @returns the current particle system
  16168. */
  16169. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16170. /**
  16171. * Remove a specific angular speed gradient
  16172. * @param gradient defines the gradient to remove
  16173. * @returns the current particle system
  16174. */
  16175. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16176. /**
  16177. * Gets the current list of velocity gradients.
  16178. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16179. * @returns the list of velocity gradients
  16180. */
  16181. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16182. /**
  16183. * Adds a new velocity gradient
  16184. * @param gradient defines the gradient to use (between 0 and 1)
  16185. * @param factor defines the velocity to affect to the specified gradient
  16186. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16187. * @returns the current particle system
  16188. */
  16189. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16190. /**
  16191. * Remove a specific velocity gradient
  16192. * @param gradient defines the gradient to remove
  16193. * @returns the current particle system
  16194. */
  16195. removeVelocityGradient(gradient: number): IParticleSystem;
  16196. /**
  16197. * Gets the current list of limit velocity gradients.
  16198. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16199. * @returns the list of limit velocity gradients
  16200. */
  16201. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16202. /**
  16203. * Adds a new limit velocity gradient
  16204. * @param gradient defines the gradient to use (between 0 and 1)
  16205. * @param factor defines the limit velocity to affect to the specified gradient
  16206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16207. * @returns the current particle system
  16208. */
  16209. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16210. /**
  16211. * Remove a specific limit velocity gradient
  16212. * @param gradient defines the gradient to remove
  16213. * @returns the current particle system
  16214. */
  16215. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16216. /**
  16217. * Adds a new drag gradient
  16218. * @param gradient defines the gradient to use (between 0 and 1)
  16219. * @param factor defines the drag to affect to the specified gradient
  16220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16221. * @returns the current particle system
  16222. */
  16223. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16224. /**
  16225. * Remove a specific drag gradient
  16226. * @param gradient defines the gradient to remove
  16227. * @returns the current particle system
  16228. */
  16229. removeDragGradient(gradient: number): IParticleSystem;
  16230. /**
  16231. * Gets the current list of drag gradients.
  16232. * You must use addDragGradient and removeDragGradient to udpate this list
  16233. * @returns the list of drag gradients
  16234. */
  16235. getDragGradients(): Nullable<Array<FactorGradient>>;
  16236. /**
  16237. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16238. * @param gradient defines the gradient to use (between 0 and 1)
  16239. * @param factor defines the emit rate to affect to the specified gradient
  16240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16241. * @returns the current particle system
  16242. */
  16243. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16244. /**
  16245. * Remove a specific emit rate gradient
  16246. * @param gradient defines the gradient to remove
  16247. * @returns the current particle system
  16248. */
  16249. removeEmitRateGradient(gradient: number): IParticleSystem;
  16250. /**
  16251. * Gets the current list of emit rate gradients.
  16252. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16253. * @returns the list of emit rate gradients
  16254. */
  16255. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16256. /**
  16257. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16258. * @param gradient defines the gradient to use (between 0 and 1)
  16259. * @param factor defines the start size to affect to the specified gradient
  16260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16261. * @returns the current particle system
  16262. */
  16263. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16264. /**
  16265. * Remove a specific start size gradient
  16266. * @param gradient defines the gradient to remove
  16267. * @returns the current particle system
  16268. */
  16269. removeStartSizeGradient(gradient: number): IParticleSystem;
  16270. /**
  16271. * Gets the current list of start size gradients.
  16272. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16273. * @returns the list of start size gradients
  16274. */
  16275. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16276. /**
  16277. * Adds a new life time gradient
  16278. * @param gradient defines the gradient to use (between 0 and 1)
  16279. * @param factor defines the life time factor to affect to the specified gradient
  16280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16281. * @returns the current particle system
  16282. */
  16283. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16284. /**
  16285. * Remove a specific life time gradient
  16286. * @param gradient defines the gradient to remove
  16287. * @returns the current particle system
  16288. */
  16289. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16290. /**
  16291. * Gets the current list of life time gradients.
  16292. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16293. * @returns the list of life time gradients
  16294. */
  16295. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16296. /**
  16297. * Gets the current list of color gradients.
  16298. * You must use addColorGradient and removeColorGradient to udpate this list
  16299. * @returns the list of color gradients
  16300. */
  16301. getColorGradients(): Nullable<Array<ColorGradient>>;
  16302. /**
  16303. * Adds a new ramp gradient used to remap particle colors
  16304. * @param gradient defines the gradient to use (between 0 and 1)
  16305. * @param color defines the color to affect to the specified gradient
  16306. * @returns the current particle system
  16307. */
  16308. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16309. /**
  16310. * Gets the current list of ramp gradients.
  16311. * You must use addRampGradient and removeRampGradient to udpate this list
  16312. * @returns the list of ramp gradients
  16313. */
  16314. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16315. /** Gets or sets a boolean indicating that ramp gradients must be used
  16316. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16317. */
  16318. useRampGradients: boolean;
  16319. /**
  16320. * Adds a new color remap gradient
  16321. * @param gradient defines the gradient to use (between 0 and 1)
  16322. * @param min defines the color remap minimal range
  16323. * @param max defines the color remap maximal range
  16324. * @returns the current particle system
  16325. */
  16326. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16327. /**
  16328. * Gets the current list of color remap gradients.
  16329. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16330. * @returns the list of color remap gradients
  16331. */
  16332. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16333. /**
  16334. * Adds a new alpha remap gradient
  16335. * @param gradient defines the gradient to use (between 0 and 1)
  16336. * @param min defines the alpha remap minimal range
  16337. * @param max defines the alpha remap maximal range
  16338. * @returns the current particle system
  16339. */
  16340. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16341. /**
  16342. * Gets the current list of alpha remap gradients.
  16343. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16344. * @returns the list of alpha remap gradients
  16345. */
  16346. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16347. /**
  16348. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16349. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16350. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16351. * @returns the emitter
  16352. */
  16353. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16354. /**
  16355. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16356. * @param radius The radius of the hemisphere to emit from
  16357. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16358. * @returns the emitter
  16359. */
  16360. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16361. /**
  16362. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16363. * @param radius The radius of the sphere to emit from
  16364. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16365. * @returns the emitter
  16366. */
  16367. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16368. /**
  16369. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16370. * @param radius The radius of the sphere to emit from
  16371. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16372. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16373. * @returns the emitter
  16374. */
  16375. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16376. /**
  16377. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16378. * @param radius The radius of the emission cylinder
  16379. * @param height The height of the emission cylinder
  16380. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16381. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16382. * @returns the emitter
  16383. */
  16384. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16385. /**
  16386. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16387. * @param radius The radius of the cylinder to emit from
  16388. * @param height The height of the emission cylinder
  16389. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16390. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16391. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16392. * @returns the emitter
  16393. */
  16394. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16395. /**
  16396. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16397. * @param radius The radius of the cone to emit from
  16398. * @param angle The base angle of the cone
  16399. * @returns the emitter
  16400. */
  16401. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16402. /**
  16403. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16404. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16405. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16406. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16407. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16408. * @returns the emitter
  16409. */
  16410. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16411. /**
  16412. * Get hosting scene
  16413. * @returns the scene
  16414. */
  16415. getScene(): Scene;
  16416. }
  16417. }
  16418. declare module "babylonjs/Meshes/instancedMesh" {
  16419. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16420. import { Vector3 } from "babylonjs/Maths/math";
  16421. import { Camera } from "babylonjs/Cameras/camera";
  16422. import { Node } from "babylonjs/node";
  16423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16424. import { Mesh } from "babylonjs/Meshes/mesh";
  16425. import { Material } from "babylonjs/Materials/material";
  16426. import { Skeleton } from "babylonjs/Bones/skeleton";
  16427. /**
  16428. * Creates an instance based on a source mesh.
  16429. */
  16430. export class InstancedMesh extends AbstractMesh {
  16431. private _sourceMesh;
  16432. private _currentLOD;
  16433. /** @hidden */
  16434. _indexInSourceMeshInstanceArray: number;
  16435. constructor(name: string, source: Mesh);
  16436. /**
  16437. * Returns the string "InstancedMesh".
  16438. */
  16439. getClassName(): string;
  16440. /**
  16441. * If the source mesh receives shadows
  16442. */
  16443. readonly receiveShadows: boolean;
  16444. /**
  16445. * The material of the source mesh
  16446. */
  16447. readonly material: Nullable<Material>;
  16448. /**
  16449. * Visibility of the source mesh
  16450. */
  16451. readonly visibility: number;
  16452. /**
  16453. * Skeleton of the source mesh
  16454. */
  16455. readonly skeleton: Nullable<Skeleton>;
  16456. /**
  16457. * Rendering ground id of the source mesh
  16458. */
  16459. renderingGroupId: 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. readonly sourceMesh: Mesh;
  16473. /**
  16474. * Is this node ready to be used/rendered
  16475. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16476. * @return {boolean} is it ready
  16477. */
  16478. isReady(completeCheck?: boolean): boolean;
  16479. /**
  16480. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16481. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16482. * @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.
  16483. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16484. */
  16485. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16486. /**
  16487. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16488. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16489. * The `data` are either a numeric array either a Float32Array.
  16490. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16491. * 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).
  16492. * Note that a new underlying VertexBuffer object is created each call.
  16493. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16494. *
  16495. * Possible `kind` values :
  16496. * - VertexBuffer.PositionKind
  16497. * - VertexBuffer.UVKind
  16498. * - VertexBuffer.UV2Kind
  16499. * - VertexBuffer.UV3Kind
  16500. * - VertexBuffer.UV4Kind
  16501. * - VertexBuffer.UV5Kind
  16502. * - VertexBuffer.UV6Kind
  16503. * - VertexBuffer.ColorKind
  16504. * - VertexBuffer.MatricesIndicesKind
  16505. * - VertexBuffer.MatricesIndicesExtraKind
  16506. * - VertexBuffer.MatricesWeightsKind
  16507. * - VertexBuffer.MatricesWeightsExtraKind
  16508. *
  16509. * Returns the Mesh.
  16510. */
  16511. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16512. /**
  16513. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16514. * If the mesh has no geometry, it is simply returned as it is.
  16515. * The `data` are either a numeric array either a Float32Array.
  16516. * No new underlying VertexBuffer object is created.
  16517. * 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.
  16518. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16519. *
  16520. * Possible `kind` values :
  16521. * - VertexBuffer.PositionKind
  16522. * - VertexBuffer.UVKind
  16523. * - VertexBuffer.UV2Kind
  16524. * - VertexBuffer.UV3Kind
  16525. * - VertexBuffer.UV4Kind
  16526. * - VertexBuffer.UV5Kind
  16527. * - VertexBuffer.UV6Kind
  16528. * - VertexBuffer.ColorKind
  16529. * - VertexBuffer.MatricesIndicesKind
  16530. * - VertexBuffer.MatricesIndicesExtraKind
  16531. * - VertexBuffer.MatricesWeightsKind
  16532. * - VertexBuffer.MatricesWeightsExtraKind
  16533. *
  16534. * Returns the Mesh.
  16535. */
  16536. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16537. /**
  16538. * Sets the mesh indices.
  16539. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16540. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16541. * This method creates a new index buffer each call.
  16542. * Returns the Mesh.
  16543. */
  16544. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16545. /**
  16546. * Boolean : True if the mesh owns the requested kind of data.
  16547. */
  16548. isVerticesDataPresent(kind: string): boolean;
  16549. /**
  16550. * Returns an array of indices (IndicesArray).
  16551. */
  16552. getIndices(): Nullable<IndicesArray>;
  16553. readonly _positions: Nullable<Vector3[]>;
  16554. /**
  16555. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16556. * This means the mesh underlying bounding box and sphere are recomputed.
  16557. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16558. * @returns the current mesh
  16559. */
  16560. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16561. /** @hidden */
  16562. _preActivate(): InstancedMesh;
  16563. /** @hidden */
  16564. _activate(renderId: number): InstancedMesh;
  16565. /**
  16566. * Returns the current associated LOD AbstractMesh.
  16567. */
  16568. getLOD(camera: Camera): AbstractMesh;
  16569. /** @hidden */
  16570. _syncSubMeshes(): InstancedMesh;
  16571. /** @hidden */
  16572. _generatePointsArray(): boolean;
  16573. /**
  16574. * Creates a new InstancedMesh from the current mesh.
  16575. * - name (string) : the cloned mesh name
  16576. * - newParent (optional Node) : the optional Node to parent the clone to.
  16577. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16578. *
  16579. * Returns the clone.
  16580. */
  16581. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16582. /**
  16583. * Disposes the InstancedMesh.
  16584. * Returns nothing.
  16585. */
  16586. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16587. }
  16588. }
  16589. declare module "babylonjs/Materials/shaderMaterial" {
  16590. import { Scene } from "babylonjs/scene";
  16591. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16593. import { Mesh } from "babylonjs/Meshes/mesh";
  16594. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16595. import { Texture } from "babylonjs/Materials/Textures/texture";
  16596. import { Material } from "babylonjs/Materials/material";
  16597. /**
  16598. * Defines the options associated with the creation of a shader material.
  16599. */
  16600. export interface IShaderMaterialOptions {
  16601. /**
  16602. * Does the material work in alpha blend mode
  16603. */
  16604. needAlphaBlending: boolean;
  16605. /**
  16606. * Does the material work in alpha test mode
  16607. */
  16608. needAlphaTesting: boolean;
  16609. /**
  16610. * The list of attribute names used in the shader
  16611. */
  16612. attributes: string[];
  16613. /**
  16614. * The list of unifrom names used in the shader
  16615. */
  16616. uniforms: string[];
  16617. /**
  16618. * The list of UBO names used in the shader
  16619. */
  16620. uniformBuffers: string[];
  16621. /**
  16622. * The list of sampler names used in the shader
  16623. */
  16624. samplers: string[];
  16625. /**
  16626. * The list of defines used in the shader
  16627. */
  16628. defines: string[];
  16629. }
  16630. /**
  16631. * 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.
  16632. *
  16633. * This returned material effects how the mesh will look based on the code in the shaders.
  16634. *
  16635. * @see http://doc.babylonjs.com/how_to/shader_material
  16636. */
  16637. export class ShaderMaterial extends Material {
  16638. private _shaderPath;
  16639. private _options;
  16640. private _textures;
  16641. private _textureArrays;
  16642. private _floats;
  16643. private _ints;
  16644. private _floatsArrays;
  16645. private _colors3;
  16646. private _colors3Arrays;
  16647. private _colors4;
  16648. private _vectors2;
  16649. private _vectors3;
  16650. private _vectors4;
  16651. private _matrices;
  16652. private _matrices3x3;
  16653. private _matrices2x2;
  16654. private _vectors2Arrays;
  16655. private _vectors3Arrays;
  16656. private _cachedWorldViewMatrix;
  16657. private _renderId;
  16658. /**
  16659. * Instantiate a new shader material.
  16660. * 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.
  16661. * This returned material effects how the mesh will look based on the code in the shaders.
  16662. * @see http://doc.babylonjs.com/how_to/shader_material
  16663. * @param name Define the name of the material in the scene
  16664. * @param scene Define the scene the material belongs to
  16665. * @param shaderPath Defines the route to the shader code in one of three ways:
  16666. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16667. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16668. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16669. * @param options Define the options used to create the shader
  16670. */
  16671. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16672. /**
  16673. * Gets the current class name of the material e.g. "ShaderMaterial"
  16674. * Mainly use in serialization.
  16675. * @returns the class name
  16676. */
  16677. getClassName(): string;
  16678. /**
  16679. * Specifies if the material will require alpha blending
  16680. * @returns a boolean specifying if alpha blending is needed
  16681. */
  16682. needAlphaBlending(): boolean;
  16683. /**
  16684. * Specifies if this material should be rendered in alpha test mode
  16685. * @returns a boolean specifying if an alpha test is needed.
  16686. */
  16687. needAlphaTesting(): boolean;
  16688. private _checkUniform;
  16689. /**
  16690. * Set a texture in the shader.
  16691. * @param name Define the name of the uniform samplers as defined in the shader
  16692. * @param texture Define the texture to bind to this sampler
  16693. * @return the material itself allowing "fluent" like uniform updates
  16694. */
  16695. setTexture(name: string, texture: Texture): ShaderMaterial;
  16696. /**
  16697. * Set a texture array in the shader.
  16698. * @param name Define the name of the uniform sampler array as defined in the shader
  16699. * @param textures Define the list of textures to bind to this sampler
  16700. * @return the material itself allowing "fluent" like uniform updates
  16701. */
  16702. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16703. /**
  16704. * Set a float in the shader.
  16705. * @param name Define the name of the uniform as defined in the shader
  16706. * @param value Define the value to give to the uniform
  16707. * @return the material itself allowing "fluent" like uniform updates
  16708. */
  16709. setFloat(name: string, value: number): ShaderMaterial;
  16710. /**
  16711. * Set a int in the shader.
  16712. * @param name Define the name of the uniform as defined in the shader
  16713. * @param value Define the value to give to the uniform
  16714. * @return the material itself allowing "fluent" like uniform updates
  16715. */
  16716. setInt(name: string, value: number): ShaderMaterial;
  16717. /**
  16718. * Set an array of floats in the shader.
  16719. * @param name Define the name of the uniform as defined in the shader
  16720. * @param value Define the value to give to the uniform
  16721. * @return the material itself allowing "fluent" like uniform updates
  16722. */
  16723. setFloats(name: string, value: number[]): ShaderMaterial;
  16724. /**
  16725. * Set a vec3 in the shader from a Color3.
  16726. * @param name Define the name of the uniform as defined in the shader
  16727. * @param value Define the value to give to the uniform
  16728. * @return the material itself allowing "fluent" like uniform updates
  16729. */
  16730. setColor3(name: string, value: Color3): ShaderMaterial;
  16731. /**
  16732. * Set a vec3 array in the shader from a Color3 array.
  16733. * @param name Define the name of the uniform as defined in the shader
  16734. * @param value Define the value to give to the uniform
  16735. * @return the material itself allowing "fluent" like uniform updates
  16736. */
  16737. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16738. /**
  16739. * Set a vec4 in the shader from a Color4.
  16740. * @param name Define the name of the uniform as defined in the shader
  16741. * @param value Define the value to give to the uniform
  16742. * @return the material itself allowing "fluent" like uniform updates
  16743. */
  16744. setColor4(name: string, value: Color4): ShaderMaterial;
  16745. /**
  16746. * Set a vec2 in the shader from a Vector2.
  16747. * @param name Define the name of the uniform as defined in the shader
  16748. * @param value Define the value to give to the uniform
  16749. * @return the material itself allowing "fluent" like uniform updates
  16750. */
  16751. setVector2(name: string, value: Vector2): ShaderMaterial;
  16752. /**
  16753. * Set a vec3 in the shader from a Vector3.
  16754. * @param name Define the name of the uniform as defined in the shader
  16755. * @param value Define the value to give to the uniform
  16756. * @return the material itself allowing "fluent" like uniform updates
  16757. */
  16758. setVector3(name: string, value: Vector3): ShaderMaterial;
  16759. /**
  16760. * Set a vec4 in the shader from a Vector4.
  16761. * @param name Define the name of the uniform as defined in the shader
  16762. * @param value Define the value to give to the uniform
  16763. * @return the material itself allowing "fluent" like uniform updates
  16764. */
  16765. setVector4(name: string, value: Vector4): ShaderMaterial;
  16766. /**
  16767. * Set a mat4 in the shader from a Matrix.
  16768. * @param name Define the name of the uniform as defined in the shader
  16769. * @param value Define the value to give to the uniform
  16770. * @return the material itself allowing "fluent" like uniform updates
  16771. */
  16772. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16773. /**
  16774. * Set a mat3 in the shader from a Float32Array.
  16775. * @param name Define the name of the uniform as defined in the shader
  16776. * @param value Define the value to give to the uniform
  16777. * @return the material itself allowing "fluent" like uniform updates
  16778. */
  16779. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16780. /**
  16781. * Set a mat2 in the shader from a Float32Array.
  16782. * @param name Define the name of the uniform as defined in the shader
  16783. * @param value Define the value to give to the uniform
  16784. * @return the material itself allowing "fluent" like uniform updates
  16785. */
  16786. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16787. /**
  16788. * Set a vec2 array in the shader from a number array.
  16789. * @param name Define the name of the uniform as defined in the shader
  16790. * @param value Define the value to give to the uniform
  16791. * @return the material itself allowing "fluent" like uniform updates
  16792. */
  16793. setArray2(name: string, value: number[]): ShaderMaterial;
  16794. /**
  16795. * Set a vec3 array in the shader from a number array.
  16796. * @param name Define the name of the uniform as defined in the shader
  16797. * @param value Define the value to give to the uniform
  16798. * @return the material itself allowing "fluent" like uniform updates
  16799. */
  16800. setArray3(name: string, value: number[]): ShaderMaterial;
  16801. private _checkCache;
  16802. /**
  16803. * Checks if the material is ready to render the requested mesh
  16804. * @param mesh Define the mesh to render
  16805. * @param useInstances Define whether or not the material is used with instances
  16806. * @returns true if ready, otherwise false
  16807. */
  16808. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16809. /**
  16810. * Binds the world matrix to the material
  16811. * @param world defines the world transformation matrix
  16812. */
  16813. bindOnlyWorldMatrix(world: Matrix): void;
  16814. /**
  16815. * Binds the material to the mesh
  16816. * @param world defines the world transformation matrix
  16817. * @param mesh defines the mesh to bind the material to
  16818. */
  16819. bind(world: Matrix, mesh?: Mesh): void;
  16820. /**
  16821. * Gets the active textures from the material
  16822. * @returns an array of textures
  16823. */
  16824. getActiveTextures(): BaseTexture[];
  16825. /**
  16826. * Specifies if the material uses a texture
  16827. * @param texture defines the texture to check against the material
  16828. * @returns a boolean specifying if the material uses the texture
  16829. */
  16830. hasTexture(texture: BaseTexture): boolean;
  16831. /**
  16832. * Makes a duplicate of the material, and gives it a new name
  16833. * @param name defines the new name for the duplicated material
  16834. * @returns the cloned material
  16835. */
  16836. clone(name: string): ShaderMaterial;
  16837. /**
  16838. * Disposes the material
  16839. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16840. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16841. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16842. */
  16843. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16844. /**
  16845. * Serializes this material in a JSON representation
  16846. * @returns the serialized material object
  16847. */
  16848. serialize(): any;
  16849. /**
  16850. * Creates a shader material from parsed shader material data
  16851. * @param source defines the JSON represnetation of the material
  16852. * @param scene defines the hosting scene
  16853. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16854. * @returns a new material
  16855. */
  16856. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16857. }
  16858. }
  16859. declare module "babylonjs/Shaders/color.fragment" {
  16860. /** @hidden */
  16861. export var colorPixelShader: {
  16862. name: string;
  16863. shader: string;
  16864. };
  16865. }
  16866. declare module "babylonjs/Shaders/color.vertex" {
  16867. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16868. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16869. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16870. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16871. /** @hidden */
  16872. export var colorVertexShader: {
  16873. name: string;
  16874. shader: string;
  16875. };
  16876. }
  16877. declare module "babylonjs/Meshes/linesMesh" {
  16878. import { Nullable } from "babylonjs/types";
  16879. import { Scene } from "babylonjs/scene";
  16880. import { Color3 } from "babylonjs/Maths/math";
  16881. import { Node } from "babylonjs/node";
  16882. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16883. import { Mesh } from "babylonjs/Meshes/mesh";
  16884. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16885. import { Effect } from "babylonjs/Materials/effect";
  16886. import { Material } from "babylonjs/Materials/material";
  16887. import "babylonjs/Shaders/color.fragment";
  16888. import "babylonjs/Shaders/color.vertex";
  16889. /**
  16890. * Line mesh
  16891. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16892. */
  16893. export class LinesMesh extends Mesh {
  16894. /**
  16895. * If vertex color should be applied to the mesh
  16896. */
  16897. useVertexColor?: boolean | undefined;
  16898. /**
  16899. * If vertex alpha should be applied to the mesh
  16900. */
  16901. useVertexAlpha?: boolean | undefined;
  16902. /**
  16903. * Color of the line (Default: White)
  16904. */
  16905. color: Color3;
  16906. /**
  16907. * Alpha of the line (Default: 1)
  16908. */
  16909. alpha: number;
  16910. /**
  16911. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16912. * This margin is expressed in world space coordinates, so its value may vary.
  16913. * Default value is 0.1
  16914. */
  16915. intersectionThreshold: number;
  16916. private _colorShader;
  16917. /**
  16918. * Creates a new LinesMesh
  16919. * @param name defines the name
  16920. * @param scene defines the hosting scene
  16921. * @param parent defines the parent mesh if any
  16922. * @param source defines the optional source LinesMesh used to clone data from
  16923. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16924. * When false, achieved by calling a clone(), also passing False.
  16925. * This will make creation of children, recursive.
  16926. * @param useVertexColor defines if this LinesMesh supports vertex color
  16927. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16928. */
  16929. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16930. /**
  16931. * If vertex color should be applied to the mesh
  16932. */
  16933. useVertexColor?: boolean | undefined,
  16934. /**
  16935. * If vertex alpha should be applied to the mesh
  16936. */
  16937. useVertexAlpha?: boolean | undefined);
  16938. /**
  16939. * Returns the string "LineMesh"
  16940. */
  16941. getClassName(): string;
  16942. /**
  16943. * @hidden
  16944. */
  16945. /**
  16946. * @hidden
  16947. */
  16948. material: Material;
  16949. /**
  16950. * @hidden
  16951. */
  16952. readonly checkCollisions: boolean;
  16953. /** @hidden */
  16954. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16955. /** @hidden */
  16956. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16957. /**
  16958. * Disposes of the line mesh
  16959. * @param doNotRecurse If children should be disposed
  16960. */
  16961. dispose(doNotRecurse?: boolean): void;
  16962. /**
  16963. * Returns a new LineMesh object cloned from the current one.
  16964. */
  16965. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16966. /**
  16967. * Creates a new InstancedLinesMesh object from the mesh model.
  16968. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16969. * @param name defines the name of the new instance
  16970. * @returns a new InstancedLinesMesh
  16971. */
  16972. createInstance(name: string): InstancedLinesMesh;
  16973. }
  16974. /**
  16975. * Creates an instance based on a source LinesMesh
  16976. */
  16977. export class InstancedLinesMesh extends InstancedMesh {
  16978. /**
  16979. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16980. * This margin is expressed in world space coordinates, so its value may vary.
  16981. * Initilized with the intersectionThreshold value of the source LinesMesh
  16982. */
  16983. intersectionThreshold: number;
  16984. constructor(name: string, source: LinesMesh);
  16985. /**
  16986. * Returns the string "InstancedLinesMesh".
  16987. */
  16988. getClassName(): string;
  16989. }
  16990. }
  16991. declare module "babylonjs/Shaders/line.fragment" {
  16992. /** @hidden */
  16993. export var linePixelShader: {
  16994. name: string;
  16995. shader: string;
  16996. };
  16997. }
  16998. declare module "babylonjs/Shaders/line.vertex" {
  16999. /** @hidden */
  17000. export var lineVertexShader: {
  17001. name: string;
  17002. shader: string;
  17003. };
  17004. }
  17005. declare module "babylonjs/Rendering/edgesRenderer" {
  17006. import { Nullable } from "babylonjs/types";
  17007. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17009. import { Vector3 } from "babylonjs/Maths/math";
  17010. import { IDisposable } from "babylonjs/scene";
  17011. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17012. import "babylonjs/Shaders/line.fragment";
  17013. import "babylonjs/Shaders/line.vertex";
  17014. module "babylonjs/Meshes/abstractMesh" {
  17015. interface AbstractMesh {
  17016. /**
  17017. * Disables the mesh edge rendering mode
  17018. * @returns the currentAbstractMesh
  17019. */
  17020. disableEdgesRendering(): AbstractMesh;
  17021. /**
  17022. * Enables the edge rendering mode on the mesh.
  17023. * This mode makes the mesh edges visible
  17024. * @param epsilon defines the maximal distance between two angles to detect a face
  17025. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17026. * @returns the currentAbstractMesh
  17027. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17028. */
  17029. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17030. /**
  17031. * Gets the edgesRenderer associated with the mesh
  17032. */
  17033. edgesRenderer: Nullable<EdgesRenderer>;
  17034. }
  17035. }
  17036. module "babylonjs/Meshes/linesMesh" {
  17037. interface LinesMesh {
  17038. /**
  17039. * Enables the edge rendering mode on the mesh.
  17040. * This mode makes the mesh edges visible
  17041. * @param epsilon defines the maximal distance between two angles to detect a face
  17042. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17043. * @returns the currentAbstractMesh
  17044. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17045. */
  17046. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17047. }
  17048. }
  17049. module "babylonjs/Meshes/linesMesh" {
  17050. interface InstancedLinesMesh {
  17051. /**
  17052. * Enables the edge rendering mode on the mesh.
  17053. * This mode makes the mesh edges visible
  17054. * @param epsilon defines the maximal distance between two angles to detect a face
  17055. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17056. * @returns the current InstancedLinesMesh
  17057. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17058. */
  17059. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17060. }
  17061. }
  17062. /**
  17063. * Defines the minimum contract an Edges renderer should follow.
  17064. */
  17065. export interface IEdgesRenderer extends IDisposable {
  17066. /**
  17067. * Gets or sets a boolean indicating if the edgesRenderer is active
  17068. */
  17069. isEnabled: boolean;
  17070. /**
  17071. * Renders the edges of the attached mesh,
  17072. */
  17073. render(): void;
  17074. /**
  17075. * Checks wether or not the edges renderer is ready to render.
  17076. * @return true if ready, otherwise false.
  17077. */
  17078. isReady(): boolean;
  17079. }
  17080. /**
  17081. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17082. */
  17083. export class EdgesRenderer implements IEdgesRenderer {
  17084. /**
  17085. * Define the size of the edges with an orthographic camera
  17086. */
  17087. edgesWidthScalerForOrthographic: number;
  17088. /**
  17089. * Define the size of the edges with a perspective camera
  17090. */
  17091. edgesWidthScalerForPerspective: number;
  17092. protected _source: AbstractMesh;
  17093. protected _linesPositions: number[];
  17094. protected _linesNormals: number[];
  17095. protected _linesIndices: number[];
  17096. protected _epsilon: number;
  17097. protected _indicesCount: number;
  17098. protected _lineShader: ShaderMaterial;
  17099. protected _ib: WebGLBuffer;
  17100. protected _buffers: {
  17101. [key: string]: Nullable<VertexBuffer>;
  17102. };
  17103. protected _checkVerticesInsteadOfIndices: boolean;
  17104. private _meshRebuildObserver;
  17105. private _meshDisposeObserver;
  17106. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17107. isEnabled: boolean;
  17108. /**
  17109. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17110. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17111. * @param source Mesh used to create edges
  17112. * @param epsilon sum of angles in adjacency to check for edge
  17113. * @param checkVerticesInsteadOfIndices
  17114. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17115. */
  17116. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17117. protected _prepareRessources(): void;
  17118. /** @hidden */
  17119. _rebuild(): void;
  17120. /**
  17121. * Releases the required resources for the edges renderer
  17122. */
  17123. dispose(): void;
  17124. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17125. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17126. /**
  17127. * Checks if the pair of p0 and p1 is en edge
  17128. * @param faceIndex
  17129. * @param edge
  17130. * @param faceNormals
  17131. * @param p0
  17132. * @param p1
  17133. * @private
  17134. */
  17135. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17136. /**
  17137. * push line into the position, normal and index buffer
  17138. * @protected
  17139. */
  17140. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17141. /**
  17142. * Generates lines edges from adjacencjes
  17143. * @private
  17144. */
  17145. _generateEdgesLines(): void;
  17146. /**
  17147. * Checks wether or not the edges renderer is ready to render.
  17148. * @return true if ready, otherwise false.
  17149. */
  17150. isReady(): boolean;
  17151. /**
  17152. * Renders the edges of the attached mesh,
  17153. */
  17154. render(): void;
  17155. }
  17156. /**
  17157. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17158. */
  17159. export class LineEdgesRenderer extends EdgesRenderer {
  17160. /**
  17161. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17162. * @param source LineMesh used to generate edges
  17163. * @param epsilon not important (specified angle for edge detection)
  17164. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17165. */
  17166. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17167. /**
  17168. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17169. */
  17170. _generateEdgesLines(): void;
  17171. }
  17172. }
  17173. declare module "babylonjs/Rendering/renderingGroup" {
  17174. import { SmartArray } from "babylonjs/Misc/smartArray";
  17175. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17177. import { Nullable } from "babylonjs/types";
  17178. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17179. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17180. import { Material } from "babylonjs/Materials/material";
  17181. import { Scene } from "babylonjs/scene";
  17182. /**
  17183. * This represents the object necessary to create a rendering group.
  17184. * This is exclusively used and created by the rendering manager.
  17185. * To modify the behavior, you use the available helpers in your scene or meshes.
  17186. * @hidden
  17187. */
  17188. export class RenderingGroup {
  17189. index: number;
  17190. private _scene;
  17191. private _opaqueSubMeshes;
  17192. private _transparentSubMeshes;
  17193. private _alphaTestSubMeshes;
  17194. private _depthOnlySubMeshes;
  17195. private _particleSystems;
  17196. private _spriteManagers;
  17197. private _opaqueSortCompareFn;
  17198. private _alphaTestSortCompareFn;
  17199. private _transparentSortCompareFn;
  17200. private _renderOpaque;
  17201. private _renderAlphaTest;
  17202. private _renderTransparent;
  17203. private _edgesRenderers;
  17204. onBeforeTransparentRendering: () => void;
  17205. /**
  17206. * Set the opaque sort comparison function.
  17207. * If null the sub meshes will be render in the order they were created
  17208. */
  17209. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17210. /**
  17211. * Set the alpha test sort comparison function.
  17212. * If null the sub meshes will be render in the order they were created
  17213. */
  17214. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17215. /**
  17216. * Set the transparent sort comparison function.
  17217. * If null the sub meshes will be render in the order they were created
  17218. */
  17219. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17220. /**
  17221. * Creates a new rendering group.
  17222. * @param index The rendering group index
  17223. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17224. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17225. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17226. */
  17227. 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>);
  17228. /**
  17229. * Render all the sub meshes contained in the group.
  17230. * @param customRenderFunction Used to override the default render behaviour of the group.
  17231. * @returns true if rendered some submeshes.
  17232. */
  17233. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17234. /**
  17235. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17236. * @param subMeshes The submeshes to render
  17237. */
  17238. private renderOpaqueSorted;
  17239. /**
  17240. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17241. * @param subMeshes The submeshes to render
  17242. */
  17243. private renderAlphaTestSorted;
  17244. /**
  17245. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17246. * @param subMeshes The submeshes to render
  17247. */
  17248. private renderTransparentSorted;
  17249. /**
  17250. * Renders the submeshes in a specified order.
  17251. * @param subMeshes The submeshes to sort before render
  17252. * @param sortCompareFn The comparison function use to sort
  17253. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17254. * @param transparent Specifies to activate blending if true
  17255. */
  17256. private static renderSorted;
  17257. /**
  17258. * Renders the submeshes in the order they were dispatched (no sort applied).
  17259. * @param subMeshes The submeshes to render
  17260. */
  17261. private static renderUnsorted;
  17262. /**
  17263. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17264. * are rendered back to front if in the same alpha index.
  17265. *
  17266. * @param a The first submesh
  17267. * @param b The second submesh
  17268. * @returns The result of the comparison
  17269. */
  17270. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17271. /**
  17272. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17273. * are rendered back to front.
  17274. *
  17275. * @param a The first submesh
  17276. * @param b The second submesh
  17277. * @returns The result of the comparison
  17278. */
  17279. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17280. /**
  17281. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17282. * are rendered front to back (prevent overdraw).
  17283. *
  17284. * @param a The first submesh
  17285. * @param b The second submesh
  17286. * @returns The result of the comparison
  17287. */
  17288. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17289. /**
  17290. * Resets the different lists of submeshes to prepare a new frame.
  17291. */
  17292. prepare(): void;
  17293. dispose(): void;
  17294. /**
  17295. * Inserts the submesh in its correct queue depending on its material.
  17296. * @param subMesh The submesh to dispatch
  17297. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17298. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17299. */
  17300. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17301. dispatchSprites(spriteManager: ISpriteManager): void;
  17302. dispatchParticles(particleSystem: IParticleSystem): void;
  17303. private _renderParticles;
  17304. private _renderSprites;
  17305. }
  17306. }
  17307. declare module "babylonjs/Rendering/renderingManager" {
  17308. import { Nullable } from "babylonjs/types";
  17309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17310. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17311. import { SmartArray } from "babylonjs/Misc/smartArray";
  17312. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17313. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17314. import { Material } from "babylonjs/Materials/material";
  17315. import { Scene } from "babylonjs/scene";
  17316. import { Camera } from "babylonjs/Cameras/camera";
  17317. /**
  17318. * Interface describing the different options available in the rendering manager
  17319. * regarding Auto Clear between groups.
  17320. */
  17321. export interface IRenderingManagerAutoClearSetup {
  17322. /**
  17323. * Defines whether or not autoclear is enable.
  17324. */
  17325. autoClear: boolean;
  17326. /**
  17327. * Defines whether or not to autoclear the depth buffer.
  17328. */
  17329. depth: boolean;
  17330. /**
  17331. * Defines whether or not to autoclear the stencil buffer.
  17332. */
  17333. stencil: boolean;
  17334. }
  17335. /**
  17336. * This class is used by the onRenderingGroupObservable
  17337. */
  17338. export class RenderingGroupInfo {
  17339. /**
  17340. * The Scene that being rendered
  17341. */
  17342. scene: Scene;
  17343. /**
  17344. * The camera currently used for the rendering pass
  17345. */
  17346. camera: Nullable<Camera>;
  17347. /**
  17348. * The ID of the renderingGroup being processed
  17349. */
  17350. renderingGroupId: number;
  17351. }
  17352. /**
  17353. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17354. * It is enable to manage the different groups as well as the different necessary sort functions.
  17355. * This should not be used directly aside of the few static configurations
  17356. */
  17357. export class RenderingManager {
  17358. /**
  17359. * The max id used for rendering groups (not included)
  17360. */
  17361. static MAX_RENDERINGGROUPS: number;
  17362. /**
  17363. * The min id used for rendering groups (included)
  17364. */
  17365. static MIN_RENDERINGGROUPS: number;
  17366. /**
  17367. * Used to globally prevent autoclearing scenes.
  17368. */
  17369. static AUTOCLEAR: boolean;
  17370. /**
  17371. * @hidden
  17372. */
  17373. _useSceneAutoClearSetup: boolean;
  17374. private _scene;
  17375. private _renderingGroups;
  17376. private _depthStencilBufferAlreadyCleaned;
  17377. private _autoClearDepthStencil;
  17378. private _customOpaqueSortCompareFn;
  17379. private _customAlphaTestSortCompareFn;
  17380. private _customTransparentSortCompareFn;
  17381. private _renderingGroupInfo;
  17382. /**
  17383. * Instantiates a new rendering group for a particular scene
  17384. * @param scene Defines the scene the groups belongs to
  17385. */
  17386. constructor(scene: Scene);
  17387. private _clearDepthStencilBuffer;
  17388. /**
  17389. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17390. * @hidden
  17391. */
  17392. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17393. /**
  17394. * Resets the different information of the group to prepare a new frame
  17395. * @hidden
  17396. */
  17397. reset(): void;
  17398. /**
  17399. * Dispose and release the group and its associated resources.
  17400. * @hidden
  17401. */
  17402. dispose(): void;
  17403. /**
  17404. * Clear the info related to rendering groups preventing retention points during dispose.
  17405. */
  17406. freeRenderingGroups(): void;
  17407. private _prepareRenderingGroup;
  17408. /**
  17409. * Add a sprite manager to the rendering manager in order to render it this frame.
  17410. * @param spriteManager Define the sprite manager to render
  17411. */
  17412. dispatchSprites(spriteManager: ISpriteManager): void;
  17413. /**
  17414. * Add a particle system to the rendering manager in order to render it this frame.
  17415. * @param particleSystem Define the particle system to render
  17416. */
  17417. dispatchParticles(particleSystem: IParticleSystem): void;
  17418. /**
  17419. * Add a submesh to the manager in order to render it this frame
  17420. * @param subMesh The submesh to dispatch
  17421. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17422. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17423. */
  17424. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17425. /**
  17426. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17427. * This allowed control for front to back rendering or reversly depending of the special needs.
  17428. *
  17429. * @param renderingGroupId The rendering group id corresponding to its index
  17430. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17431. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17432. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17433. */
  17434. 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;
  17435. /**
  17436. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17437. *
  17438. * @param renderingGroupId The rendering group id corresponding to its index
  17439. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17440. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17441. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17442. */
  17443. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17444. /**
  17445. * Gets the current auto clear configuration for one rendering group of the rendering
  17446. * manager.
  17447. * @param index the rendering group index to get the information for
  17448. * @returns The auto clear setup for the requested rendering group
  17449. */
  17450. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17451. }
  17452. }
  17453. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17454. import { Observable } from "babylonjs/Misc/observable";
  17455. import { SmartArray } from "babylonjs/Misc/smartArray";
  17456. import { Nullable } from "babylonjs/types";
  17457. import { Camera } from "babylonjs/Cameras/camera";
  17458. import { Scene } from "babylonjs/scene";
  17459. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17460. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17462. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17464. import { Texture } from "babylonjs/Materials/Textures/texture";
  17465. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17466. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17467. import { Engine } from "babylonjs/Engines/engine";
  17468. /**
  17469. * This Helps creating a texture that will be created from a camera in your scene.
  17470. * It is basically a dynamic texture that could be used to create special effects for instance.
  17471. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17472. */
  17473. export class RenderTargetTexture extends Texture {
  17474. isCube: boolean;
  17475. /**
  17476. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17477. */
  17478. static readonly REFRESHRATE_RENDER_ONCE: number;
  17479. /**
  17480. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17481. */
  17482. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17483. /**
  17484. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17485. * the central point of your effect and can save a lot of performances.
  17486. */
  17487. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17488. /**
  17489. * Use this predicate to dynamically define the list of mesh you want to render.
  17490. * If set, the renderList property will be overwritten.
  17491. */
  17492. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17493. private _renderList;
  17494. /**
  17495. * Use this list to define the list of mesh you want to render.
  17496. */
  17497. renderList: Nullable<Array<AbstractMesh>>;
  17498. private _hookArray;
  17499. /**
  17500. * Define if particles should be rendered in your texture.
  17501. */
  17502. renderParticles: boolean;
  17503. /**
  17504. * Define if sprites should be rendered in your texture.
  17505. */
  17506. renderSprites: boolean;
  17507. /**
  17508. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17509. */
  17510. coordinatesMode: number;
  17511. /**
  17512. * Define the camera used to render the texture.
  17513. */
  17514. activeCamera: Nullable<Camera>;
  17515. /**
  17516. * Override the render function of the texture with your own one.
  17517. */
  17518. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17519. /**
  17520. * Define if camera post processes should be use while rendering the texture.
  17521. */
  17522. useCameraPostProcesses: boolean;
  17523. /**
  17524. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17525. */
  17526. ignoreCameraViewport: boolean;
  17527. private _postProcessManager;
  17528. private _postProcesses;
  17529. private _resizeObserver;
  17530. /**
  17531. * An event triggered when the texture is unbind.
  17532. */
  17533. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17534. /**
  17535. * An event triggered when the texture is unbind.
  17536. */
  17537. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17538. private _onAfterUnbindObserver;
  17539. /**
  17540. * Set a after unbind callback in the texture.
  17541. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17542. */
  17543. onAfterUnbind: () => void;
  17544. /**
  17545. * An event triggered before rendering the texture
  17546. */
  17547. onBeforeRenderObservable: Observable<number>;
  17548. private _onBeforeRenderObserver;
  17549. /**
  17550. * Set a before render callback in the texture.
  17551. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17552. */
  17553. onBeforeRender: (faceIndex: number) => void;
  17554. /**
  17555. * An event triggered after rendering the texture
  17556. */
  17557. onAfterRenderObservable: Observable<number>;
  17558. private _onAfterRenderObserver;
  17559. /**
  17560. * Set a after render callback in the texture.
  17561. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17562. */
  17563. onAfterRender: (faceIndex: number) => void;
  17564. /**
  17565. * An event triggered after the texture clear
  17566. */
  17567. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17568. private _onClearObserver;
  17569. /**
  17570. * Set a clear callback in the texture.
  17571. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17572. */
  17573. onClear: (Engine: Engine) => void;
  17574. /**
  17575. * Define the clear color of the Render Target if it should be different from the scene.
  17576. */
  17577. clearColor: Color4;
  17578. protected _size: number | {
  17579. width: number;
  17580. height: number;
  17581. };
  17582. protected _initialSizeParameter: number | {
  17583. width: number;
  17584. height: number;
  17585. } | {
  17586. ratio: number;
  17587. };
  17588. protected _sizeRatio: Nullable<number>;
  17589. /** @hidden */
  17590. _generateMipMaps: boolean;
  17591. protected _renderingManager: RenderingManager;
  17592. /** @hidden */
  17593. _waitingRenderList: string[];
  17594. protected _doNotChangeAspectRatio: boolean;
  17595. protected _currentRefreshId: number;
  17596. protected _refreshRate: number;
  17597. protected _textureMatrix: Matrix;
  17598. protected _samples: number;
  17599. protected _renderTargetOptions: RenderTargetCreationOptions;
  17600. /**
  17601. * Gets render target creation options that were used.
  17602. */
  17603. readonly renderTargetOptions: RenderTargetCreationOptions;
  17604. protected _engine: Engine;
  17605. protected _onRatioRescale(): void;
  17606. /**
  17607. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17608. * It must define where the camera used to render the texture is set
  17609. */
  17610. boundingBoxPosition: Vector3;
  17611. private _boundingBoxSize;
  17612. /**
  17613. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17614. * When defined, the cubemap will switch to local mode
  17615. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17616. * @example https://www.babylonjs-playground.com/#RNASML
  17617. */
  17618. boundingBoxSize: Vector3;
  17619. /**
  17620. * In case the RTT has been created with a depth texture, get the associated
  17621. * depth texture.
  17622. * Otherwise, return null.
  17623. */
  17624. depthStencilTexture: Nullable<InternalTexture>;
  17625. /**
  17626. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17627. * or used a shadow, depth texture...
  17628. * @param name The friendly name of the texture
  17629. * @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)
  17630. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17631. * @param generateMipMaps True if mip maps need to be generated after render.
  17632. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17633. * @param type The type of the buffer in the RTT (int, half float, float...)
  17634. * @param isCube True if a cube texture needs to be created
  17635. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17636. * @param generateDepthBuffer True to generate a depth buffer
  17637. * @param generateStencilBuffer True to generate a stencil buffer
  17638. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17639. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17640. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17641. */
  17642. constructor(name: string, size: number | {
  17643. width: number;
  17644. height: number;
  17645. } | {
  17646. ratio: number;
  17647. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17648. /**
  17649. * Creates a depth stencil texture.
  17650. * This is only available in WebGL 2 or with the depth texture extension available.
  17651. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17652. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17653. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17654. */
  17655. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17656. private _processSizeParameter;
  17657. /**
  17658. * Define the number of samples to use in case of MSAA.
  17659. * It defaults to one meaning no MSAA has been enabled.
  17660. */
  17661. samples: number;
  17662. /**
  17663. * Resets the refresh counter of the texture and start bak from scratch.
  17664. * Could be useful to regenerate the texture if it is setup to render only once.
  17665. */
  17666. resetRefreshCounter(): void;
  17667. /**
  17668. * Define the refresh rate of the texture or the rendering frequency.
  17669. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17670. */
  17671. refreshRate: number;
  17672. /**
  17673. * Adds a post process to the render target rendering passes.
  17674. * @param postProcess define the post process to add
  17675. */
  17676. addPostProcess(postProcess: PostProcess): void;
  17677. /**
  17678. * Clear all the post processes attached to the render target
  17679. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17680. */
  17681. clearPostProcesses(dispose?: boolean): void;
  17682. /**
  17683. * Remove one of the post process from the list of attached post processes to the texture
  17684. * @param postProcess define the post process to remove from the list
  17685. */
  17686. removePostProcess(postProcess: PostProcess): void;
  17687. /** @hidden */
  17688. _shouldRender(): boolean;
  17689. /**
  17690. * Gets the actual render size of the texture.
  17691. * @returns the width of the render size
  17692. */
  17693. getRenderSize(): number;
  17694. /**
  17695. * Gets the actual render width of the texture.
  17696. * @returns the width of the render size
  17697. */
  17698. getRenderWidth(): number;
  17699. /**
  17700. * Gets the actual render height of the texture.
  17701. * @returns the height of the render size
  17702. */
  17703. getRenderHeight(): number;
  17704. /**
  17705. * Get if the texture can be rescaled or not.
  17706. */
  17707. readonly canRescale: boolean;
  17708. /**
  17709. * Resize the texture using a ratio.
  17710. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17711. */
  17712. scale(ratio: number): void;
  17713. /**
  17714. * Get the texture reflection matrix used to rotate/transform the reflection.
  17715. * @returns the reflection matrix
  17716. */
  17717. getReflectionTextureMatrix(): Matrix;
  17718. /**
  17719. * Resize the texture to a new desired size.
  17720. * Be carrefull as it will recreate all the data in the new texture.
  17721. * @param size Define the new size. It can be:
  17722. * - a number for squared texture,
  17723. * - an object containing { width: number, height: number }
  17724. * - or an object containing a ratio { ratio: number }
  17725. */
  17726. resize(size: number | {
  17727. width: number;
  17728. height: number;
  17729. } | {
  17730. ratio: number;
  17731. }): void;
  17732. /**
  17733. * Renders all the objects from the render list into the texture.
  17734. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17735. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17736. */
  17737. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17738. private _bestReflectionRenderTargetDimension;
  17739. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17740. private renderToTarget;
  17741. /**
  17742. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17743. * This allowed control for front to back rendering or reversly depending of the special needs.
  17744. *
  17745. * @param renderingGroupId The rendering group id corresponding to its index
  17746. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17747. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17748. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17749. */
  17750. 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;
  17751. /**
  17752. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17753. *
  17754. * @param renderingGroupId The rendering group id corresponding to its index
  17755. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17756. */
  17757. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17758. /**
  17759. * Clones the texture.
  17760. * @returns the cloned texture
  17761. */
  17762. clone(): RenderTargetTexture;
  17763. /**
  17764. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17765. * @returns The JSON representation of the texture
  17766. */
  17767. serialize(): any;
  17768. /**
  17769. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17770. */
  17771. disposeFramebufferObjects(): void;
  17772. /**
  17773. * Dispose the texture and release its associated resources.
  17774. */
  17775. dispose(): void;
  17776. /** @hidden */
  17777. _rebuild(): void;
  17778. /**
  17779. * Clear the info related to rendering groups preventing retention point in material dispose.
  17780. */
  17781. freeRenderingGroups(): void;
  17782. }
  17783. }
  17784. declare module "babylonjs/Materials/material" {
  17785. import { IAnimatable } from "babylonjs/Misc/tools";
  17786. import { SmartArray } from "babylonjs/Misc/smartArray";
  17787. import { Observable } from "babylonjs/Misc/observable";
  17788. import { Nullable } from "babylonjs/types";
  17789. import { Scene } from "babylonjs/scene";
  17790. import { Matrix } from "babylonjs/Maths/math";
  17791. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  17792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17793. import { Mesh } from "babylonjs/Meshes/mesh";
  17794. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17795. import { Effect } from "babylonjs/Materials/effect";
  17796. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17797. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17798. import { Animation } from "babylonjs/Animations/animation";
  17799. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17800. /**
  17801. * Base class for the main features of a material in Babylon.js
  17802. */
  17803. export class Material implements IAnimatable {
  17804. /**
  17805. * Returns the triangle fill mode
  17806. */
  17807. static readonly TriangleFillMode: number;
  17808. /**
  17809. * Returns the wireframe mode
  17810. */
  17811. static readonly WireFrameFillMode: number;
  17812. /**
  17813. * Returns the point fill mode
  17814. */
  17815. static readonly PointFillMode: number;
  17816. /**
  17817. * Returns the point list draw mode
  17818. */
  17819. static readonly PointListDrawMode: number;
  17820. /**
  17821. * Returns the line list draw mode
  17822. */
  17823. static readonly LineListDrawMode: number;
  17824. /**
  17825. * Returns the line loop draw mode
  17826. */
  17827. static readonly LineLoopDrawMode: number;
  17828. /**
  17829. * Returns the line strip draw mode
  17830. */
  17831. static readonly LineStripDrawMode: number;
  17832. /**
  17833. * Returns the triangle strip draw mode
  17834. */
  17835. static readonly TriangleStripDrawMode: number;
  17836. /**
  17837. * Returns the triangle fan draw mode
  17838. */
  17839. static readonly TriangleFanDrawMode: number;
  17840. /**
  17841. * Stores the clock-wise side orientation
  17842. */
  17843. static readonly ClockWiseSideOrientation: number;
  17844. /**
  17845. * Stores the counter clock-wise side orientation
  17846. */
  17847. static readonly CounterClockWiseSideOrientation: number;
  17848. /**
  17849. * The dirty texture flag value
  17850. */
  17851. static readonly TextureDirtyFlag: number;
  17852. /**
  17853. * The dirty light flag value
  17854. */
  17855. static readonly LightDirtyFlag: number;
  17856. /**
  17857. * The dirty fresnel flag value
  17858. */
  17859. static readonly FresnelDirtyFlag: number;
  17860. /**
  17861. * The dirty attribute flag value
  17862. */
  17863. static readonly AttributesDirtyFlag: number;
  17864. /**
  17865. * The dirty misc flag value
  17866. */
  17867. static readonly MiscDirtyFlag: number;
  17868. /**
  17869. * The all dirty flag value
  17870. */
  17871. static readonly AllDirtyFlag: number;
  17872. /**
  17873. * The ID of the material
  17874. */
  17875. id: string;
  17876. /**
  17877. * Gets or sets the unique id of the material
  17878. */
  17879. uniqueId: number;
  17880. /**
  17881. * The name of the material
  17882. */
  17883. name: string;
  17884. /**
  17885. * Gets or sets user defined metadata
  17886. */
  17887. metadata: any;
  17888. /**
  17889. * For internal use only. Please do not use.
  17890. */
  17891. reservedDataStore: any;
  17892. /**
  17893. * Specifies if the ready state should be checked on each call
  17894. */
  17895. checkReadyOnEveryCall: boolean;
  17896. /**
  17897. * Specifies if the ready state should be checked once
  17898. */
  17899. checkReadyOnlyOnce: boolean;
  17900. /**
  17901. * The state of the material
  17902. */
  17903. state: string;
  17904. /**
  17905. * The alpha value of the material
  17906. */
  17907. protected _alpha: number;
  17908. /**
  17909. * Sets the alpha value of the material
  17910. */
  17911. /**
  17912. * Gets the alpha value of the material
  17913. */
  17914. alpha: number;
  17915. /**
  17916. * Specifies if back face culling is enabled
  17917. */
  17918. protected _backFaceCulling: boolean;
  17919. /**
  17920. * Sets the back-face culling state
  17921. */
  17922. /**
  17923. * Gets the back-face culling state
  17924. */
  17925. backFaceCulling: boolean;
  17926. /**
  17927. * Stores the value for side orientation
  17928. */
  17929. sideOrientation: number;
  17930. /**
  17931. * Callback triggered when the material is compiled
  17932. */
  17933. onCompiled: (effect: Effect) => void;
  17934. /**
  17935. * Callback triggered when an error occurs
  17936. */
  17937. onError: (effect: Effect, errors: string) => void;
  17938. /**
  17939. * Callback triggered to get the render target textures
  17940. */
  17941. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17942. /**
  17943. * Gets a boolean indicating that current material needs to register RTT
  17944. */
  17945. readonly hasRenderTargetTextures: boolean;
  17946. /**
  17947. * Specifies if the material should be serialized
  17948. */
  17949. doNotSerialize: boolean;
  17950. /**
  17951. * @hidden
  17952. */
  17953. _storeEffectOnSubMeshes: boolean;
  17954. /**
  17955. * Stores the animations for the material
  17956. */
  17957. animations: Array<Animation>;
  17958. /**
  17959. * An event triggered when the material is disposed
  17960. */
  17961. onDisposeObservable: Observable<Material>;
  17962. /**
  17963. * An observer which watches for dispose events
  17964. */
  17965. private _onDisposeObserver;
  17966. private _onUnBindObservable;
  17967. /**
  17968. * Called during a dispose event
  17969. */
  17970. onDispose: () => void;
  17971. private _onBindObservable;
  17972. /**
  17973. * An event triggered when the material is bound
  17974. */
  17975. readonly onBindObservable: Observable<AbstractMesh>;
  17976. /**
  17977. * An observer which watches for bind events
  17978. */
  17979. private _onBindObserver;
  17980. /**
  17981. * Called during a bind event
  17982. */
  17983. onBind: (Mesh: AbstractMesh) => void;
  17984. /**
  17985. * An event triggered when the material is unbound
  17986. */
  17987. readonly onUnBindObservable: Observable<Material>;
  17988. /**
  17989. * Stores the value of the alpha mode
  17990. */
  17991. private _alphaMode;
  17992. /**
  17993. * Sets the value of the alpha mode.
  17994. *
  17995. * | Value | Type | Description |
  17996. * | --- | --- | --- |
  17997. * | 0 | ALPHA_DISABLE | |
  17998. * | 1 | ALPHA_ADD | |
  17999. * | 2 | ALPHA_COMBINE | |
  18000. * | 3 | ALPHA_SUBTRACT | |
  18001. * | 4 | ALPHA_MULTIPLY | |
  18002. * | 5 | ALPHA_MAXIMIZED | |
  18003. * | 6 | ALPHA_ONEONE | |
  18004. * | 7 | ALPHA_PREMULTIPLIED | |
  18005. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18006. * | 9 | ALPHA_INTERPOLATE | |
  18007. * | 10 | ALPHA_SCREENMODE | |
  18008. *
  18009. */
  18010. /**
  18011. * Gets the value of the alpha mode
  18012. */
  18013. alphaMode: number;
  18014. /**
  18015. * Stores the state of the need depth pre-pass value
  18016. */
  18017. private _needDepthPrePass;
  18018. /**
  18019. * Sets the need depth pre-pass value
  18020. */
  18021. /**
  18022. * Gets the depth pre-pass value
  18023. */
  18024. needDepthPrePass: boolean;
  18025. /**
  18026. * Specifies if depth writing should be disabled
  18027. */
  18028. disableDepthWrite: boolean;
  18029. /**
  18030. * Specifies if depth writing should be forced
  18031. */
  18032. forceDepthWrite: boolean;
  18033. /**
  18034. * Specifies if there should be a separate pass for culling
  18035. */
  18036. separateCullingPass: boolean;
  18037. /**
  18038. * Stores the state specifing if fog should be enabled
  18039. */
  18040. private _fogEnabled;
  18041. /**
  18042. * Sets the state for enabling fog
  18043. */
  18044. /**
  18045. * Gets the value of the fog enabled state
  18046. */
  18047. fogEnabled: boolean;
  18048. /**
  18049. * Stores the size of points
  18050. */
  18051. pointSize: number;
  18052. /**
  18053. * Stores the z offset value
  18054. */
  18055. zOffset: number;
  18056. /**
  18057. * Gets a value specifying if wireframe mode is enabled
  18058. */
  18059. /**
  18060. * Sets the state of wireframe mode
  18061. */
  18062. wireframe: boolean;
  18063. /**
  18064. * Gets the value specifying if point clouds are enabled
  18065. */
  18066. /**
  18067. * Sets the state of point cloud mode
  18068. */
  18069. pointsCloud: boolean;
  18070. /**
  18071. * Gets the material fill mode
  18072. */
  18073. /**
  18074. * Sets the material fill mode
  18075. */
  18076. fillMode: number;
  18077. /**
  18078. * @hidden
  18079. * Stores the effects for the material
  18080. */
  18081. _effect: Nullable<Effect>;
  18082. /**
  18083. * @hidden
  18084. * Specifies if the material was previously ready
  18085. */
  18086. _wasPreviouslyReady: boolean;
  18087. /**
  18088. * Specifies if uniform buffers should be used
  18089. */
  18090. private _useUBO;
  18091. /**
  18092. * Stores a reference to the scene
  18093. */
  18094. private _scene;
  18095. /**
  18096. * Stores the fill mode state
  18097. */
  18098. private _fillMode;
  18099. /**
  18100. * Specifies if the depth write state should be cached
  18101. */
  18102. private _cachedDepthWriteState;
  18103. /**
  18104. * Stores the uniform buffer
  18105. */
  18106. protected _uniformBuffer: UniformBuffer;
  18107. /** @hidden */
  18108. _indexInSceneMaterialArray: number;
  18109. /** @hidden */
  18110. meshMap: Nullable<{
  18111. [id: string]: AbstractMesh | undefined;
  18112. }>;
  18113. /**
  18114. * Creates a material instance
  18115. * @param name defines the name of the material
  18116. * @param scene defines the scene to reference
  18117. * @param doNotAdd specifies if the material should be added to the scene
  18118. */
  18119. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18120. /**
  18121. * Returns a string representation of the current material
  18122. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18123. * @returns a string with material information
  18124. */
  18125. toString(fullDetails?: boolean): string;
  18126. /**
  18127. * Gets the class name of the material
  18128. * @returns a string with the class name of the material
  18129. */
  18130. getClassName(): string;
  18131. /**
  18132. * Specifies if updates for the material been locked
  18133. */
  18134. readonly isFrozen: boolean;
  18135. /**
  18136. * Locks updates for the material
  18137. */
  18138. freeze(): void;
  18139. /**
  18140. * Unlocks updates for the material
  18141. */
  18142. unfreeze(): void;
  18143. /**
  18144. * Specifies if the material is ready to be used
  18145. * @param mesh defines the mesh to check
  18146. * @param useInstances specifies if instances should be used
  18147. * @returns a boolean indicating if the material is ready to be used
  18148. */
  18149. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18150. /**
  18151. * Specifies that the submesh is ready to be used
  18152. * @param mesh defines the mesh to check
  18153. * @param subMesh defines which submesh to check
  18154. * @param useInstances specifies that instances should be used
  18155. * @returns a boolean indicating that the submesh is ready or not
  18156. */
  18157. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18158. /**
  18159. * Returns the material effect
  18160. * @returns the effect associated with the material
  18161. */
  18162. getEffect(): Nullable<Effect>;
  18163. /**
  18164. * Returns the current scene
  18165. * @returns a Scene
  18166. */
  18167. getScene(): Scene;
  18168. /**
  18169. * Specifies if the material will require alpha blending
  18170. * @returns a boolean specifying if alpha blending is needed
  18171. */
  18172. needAlphaBlending(): boolean;
  18173. /**
  18174. * Specifies if the mesh will require alpha blending
  18175. * @param mesh defines the mesh to check
  18176. * @returns a boolean specifying if alpha blending is needed for the mesh
  18177. */
  18178. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18179. /**
  18180. * Specifies if this material should be rendered in alpha test mode
  18181. * @returns a boolean specifying if an alpha test is needed.
  18182. */
  18183. needAlphaTesting(): boolean;
  18184. /**
  18185. * Gets the texture used for the alpha test
  18186. * @returns the texture to use for alpha testing
  18187. */
  18188. getAlphaTestTexture(): Nullable<BaseTexture>;
  18189. /**
  18190. * Marks the material to indicate that it needs to be re-calculated
  18191. */
  18192. markDirty(): void;
  18193. /** @hidden */
  18194. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18195. /**
  18196. * Binds the material to the mesh
  18197. * @param world defines the world transformation matrix
  18198. * @param mesh defines the mesh to bind the material to
  18199. */
  18200. bind(world: Matrix, mesh?: Mesh): void;
  18201. /**
  18202. * Binds the submesh to the material
  18203. * @param world defines the world transformation matrix
  18204. * @param mesh defines the mesh containing the submesh
  18205. * @param subMesh defines the submesh to bind the material to
  18206. */
  18207. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18208. /**
  18209. * Binds the world matrix to the material
  18210. * @param world defines the world transformation matrix
  18211. */
  18212. bindOnlyWorldMatrix(world: Matrix): void;
  18213. /**
  18214. * Binds the scene's uniform buffer to the effect.
  18215. * @param effect defines the effect to bind to the scene uniform buffer
  18216. * @param sceneUbo defines the uniform buffer storing scene data
  18217. */
  18218. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18219. /**
  18220. * Binds the view matrix to the effect
  18221. * @param effect defines the effect to bind the view matrix to
  18222. */
  18223. bindView(effect: Effect): void;
  18224. /**
  18225. * Binds the view projection matrix to the effect
  18226. * @param effect defines the effect to bind the view projection matrix to
  18227. */
  18228. bindViewProjection(effect: Effect): void;
  18229. /**
  18230. * Specifies if material alpha testing should be turned on for the mesh
  18231. * @param mesh defines the mesh to check
  18232. */
  18233. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18234. /**
  18235. * Processes to execute after binding the material to a mesh
  18236. * @param mesh defines the rendered mesh
  18237. */
  18238. protected _afterBind(mesh?: Mesh): void;
  18239. /**
  18240. * Unbinds the material from the mesh
  18241. */
  18242. unbind(): void;
  18243. /**
  18244. * Gets the active textures from the material
  18245. * @returns an array of textures
  18246. */
  18247. getActiveTextures(): BaseTexture[];
  18248. /**
  18249. * Specifies if the material uses a texture
  18250. * @param texture defines the texture to check against the material
  18251. * @returns a boolean specifying if the material uses the texture
  18252. */
  18253. hasTexture(texture: BaseTexture): boolean;
  18254. /**
  18255. * Makes a duplicate of the material, and gives it a new name
  18256. * @param name defines the new name for the duplicated material
  18257. * @returns the cloned material
  18258. */
  18259. clone(name: string): Nullable<Material>;
  18260. /**
  18261. * Gets the meshes bound to the material
  18262. * @returns an array of meshes bound to the material
  18263. */
  18264. getBindedMeshes(): AbstractMesh[];
  18265. /**
  18266. * Force shader compilation
  18267. * @param mesh defines the mesh associated with this material
  18268. * @param onCompiled defines a function to execute once the material is compiled
  18269. * @param options defines the options to configure the compilation
  18270. */
  18271. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18272. clipPlane: boolean;
  18273. }>): void;
  18274. /**
  18275. * Force shader compilation
  18276. * @param mesh defines the mesh that will use this material
  18277. * @param options defines additional options for compiling the shaders
  18278. * @returns a promise that resolves when the compilation completes
  18279. */
  18280. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18281. clipPlane: boolean;
  18282. }>): Promise<void>;
  18283. private static readonly _ImageProcessingDirtyCallBack;
  18284. private static readonly _TextureDirtyCallBack;
  18285. private static readonly _FresnelDirtyCallBack;
  18286. private static readonly _MiscDirtyCallBack;
  18287. private static readonly _LightsDirtyCallBack;
  18288. private static readonly _AttributeDirtyCallBack;
  18289. private static _FresnelAndMiscDirtyCallBack;
  18290. private static _TextureAndMiscDirtyCallBack;
  18291. private static readonly _DirtyCallbackArray;
  18292. private static readonly _RunDirtyCallBacks;
  18293. /**
  18294. * Marks a define in the material to indicate that it needs to be re-computed
  18295. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18296. */
  18297. markAsDirty(flag: number): void;
  18298. /**
  18299. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18300. * @param func defines a function which checks material defines against the submeshes
  18301. */
  18302. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18303. /**
  18304. * Indicates that image processing needs to be re-calculated for all submeshes
  18305. */
  18306. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18307. /**
  18308. * Indicates that textures need to be re-calculated for all submeshes
  18309. */
  18310. protected _markAllSubMeshesAsTexturesDirty(): void;
  18311. /**
  18312. * Indicates that fresnel needs to be re-calculated for all submeshes
  18313. */
  18314. protected _markAllSubMeshesAsFresnelDirty(): void;
  18315. /**
  18316. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18317. */
  18318. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18319. /**
  18320. * Indicates that lights need to be re-calculated for all submeshes
  18321. */
  18322. protected _markAllSubMeshesAsLightsDirty(): void;
  18323. /**
  18324. * Indicates that attributes need to be re-calculated for all submeshes
  18325. */
  18326. protected _markAllSubMeshesAsAttributesDirty(): void;
  18327. /**
  18328. * Indicates that misc needs to be re-calculated for all submeshes
  18329. */
  18330. protected _markAllSubMeshesAsMiscDirty(): void;
  18331. /**
  18332. * Indicates that textures and misc need to be re-calculated for all submeshes
  18333. */
  18334. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18335. /**
  18336. * Disposes the material
  18337. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18338. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18339. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18340. */
  18341. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18342. /** @hidden */
  18343. private releaseVertexArrayObject;
  18344. /**
  18345. * Serializes this material
  18346. * @returns the serialized material object
  18347. */
  18348. serialize(): any;
  18349. /**
  18350. * Creates a material from parsed material data
  18351. * @param parsedMaterial defines parsed material data
  18352. * @param scene defines the hosting scene
  18353. * @param rootUrl defines the root URL to use to load textures
  18354. * @returns a new material
  18355. */
  18356. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18357. }
  18358. }
  18359. declare module "babylonjs/Loading/sceneLoaderFlags" {
  18360. /**
  18361. * Class used to represent data loading progression
  18362. */
  18363. export class SceneLoaderFlags {
  18364. private static _ForceFullSceneLoadingForIncremental;
  18365. private static _ShowLoadingScreen;
  18366. private static _CleanBoneMatrixWeights;
  18367. private static _loggingLevel;
  18368. /**
  18369. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  18370. */
  18371. static ForceFullSceneLoadingForIncremental: boolean;
  18372. /**
  18373. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  18374. */
  18375. static ShowLoadingScreen: boolean;
  18376. /**
  18377. * Defines the current logging level (while loading the scene)
  18378. * @ignorenaming
  18379. */
  18380. static loggingLevel: number;
  18381. /**
  18382. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  18383. */
  18384. static CleanBoneMatrixWeights: boolean;
  18385. }
  18386. }
  18387. declare module "babylonjs/Morph/morphTarget" {
  18388. import { IAnimatable } from "babylonjs/Misc/tools";
  18389. import { Observable } from "babylonjs/Misc/observable";
  18390. import { Nullable, FloatArray } from "babylonjs/types";
  18391. import { Scene } from "babylonjs/scene";
  18392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18393. import { Animation } from "babylonjs/Animations/animation";
  18394. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18395. /**
  18396. * Defines a target to use with MorphTargetManager
  18397. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18398. */
  18399. export class MorphTarget implements IAnimatable {
  18400. /** defines the name of the target */
  18401. name: string;
  18402. /**
  18403. * Gets or sets the list of animations
  18404. */
  18405. animations: Animation[];
  18406. private _scene;
  18407. private _positions;
  18408. private _normals;
  18409. private _tangents;
  18410. private _influence;
  18411. /**
  18412. * Observable raised when the influence changes
  18413. */
  18414. onInfluenceChanged: Observable<boolean>;
  18415. /** @hidden */
  18416. _onDataLayoutChanged: Observable<void>;
  18417. /**
  18418. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18419. */
  18420. influence: number;
  18421. /**
  18422. * Gets or sets the id of the morph Target
  18423. */
  18424. id: string;
  18425. private _animationPropertiesOverride;
  18426. /**
  18427. * Gets or sets the animation properties override
  18428. */
  18429. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18430. /**
  18431. * Creates a new MorphTarget
  18432. * @param name defines the name of the target
  18433. * @param influence defines the influence to use
  18434. */
  18435. constructor(
  18436. /** defines the name of the target */
  18437. name: string, influence?: number, scene?: Nullable<Scene>);
  18438. /**
  18439. * Gets a boolean defining if the target contains position data
  18440. */
  18441. readonly hasPositions: boolean;
  18442. /**
  18443. * Gets a boolean defining if the target contains normal data
  18444. */
  18445. readonly hasNormals: boolean;
  18446. /**
  18447. * Gets a boolean defining if the target contains tangent data
  18448. */
  18449. readonly hasTangents: boolean;
  18450. /**
  18451. * Affects position data to this target
  18452. * @param data defines the position data to use
  18453. */
  18454. setPositions(data: Nullable<FloatArray>): void;
  18455. /**
  18456. * Gets the position data stored in this target
  18457. * @returns a FloatArray containing the position data (or null if not present)
  18458. */
  18459. getPositions(): Nullable<FloatArray>;
  18460. /**
  18461. * Affects normal data to this target
  18462. * @param data defines the normal data to use
  18463. */
  18464. setNormals(data: Nullable<FloatArray>): void;
  18465. /**
  18466. * Gets the normal data stored in this target
  18467. * @returns a FloatArray containing the normal data (or null if not present)
  18468. */
  18469. getNormals(): Nullable<FloatArray>;
  18470. /**
  18471. * Affects tangent data to this target
  18472. * @param data defines the tangent data to use
  18473. */
  18474. setTangents(data: Nullable<FloatArray>): void;
  18475. /**
  18476. * Gets the tangent data stored in this target
  18477. * @returns a FloatArray containing the tangent data (or null if not present)
  18478. */
  18479. getTangents(): Nullable<FloatArray>;
  18480. /**
  18481. * Serializes the current target into a Serialization object
  18482. * @returns the serialized object
  18483. */
  18484. serialize(): any;
  18485. /**
  18486. * Returns the string "MorphTarget"
  18487. * @returns "MorphTarget"
  18488. */
  18489. getClassName(): string;
  18490. /**
  18491. * Creates a new target from serialized data
  18492. * @param serializationObject defines the serialized data to use
  18493. * @returns a new MorphTarget
  18494. */
  18495. static Parse(serializationObject: any): MorphTarget;
  18496. /**
  18497. * Creates a MorphTarget from mesh data
  18498. * @param mesh defines the source mesh
  18499. * @param name defines the name to use for the new target
  18500. * @param influence defines the influence to attach to the target
  18501. * @returns a new MorphTarget
  18502. */
  18503. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18504. }
  18505. }
  18506. declare module "babylonjs/Morph/morphTargetManager" {
  18507. import { Nullable } from "babylonjs/types";
  18508. import { Scene } from "babylonjs/scene";
  18509. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  18510. /**
  18511. * This class is used to deform meshes using morphing between different targets
  18512. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18513. */
  18514. export class MorphTargetManager {
  18515. private _targets;
  18516. private _targetInfluenceChangedObservers;
  18517. private _targetDataLayoutChangedObservers;
  18518. private _activeTargets;
  18519. private _scene;
  18520. private _influences;
  18521. private _supportsNormals;
  18522. private _supportsTangents;
  18523. private _vertexCount;
  18524. private _uniqueId;
  18525. private _tempInfluences;
  18526. /**
  18527. * Creates a new MorphTargetManager
  18528. * @param scene defines the current scene
  18529. */
  18530. constructor(scene?: Nullable<Scene>);
  18531. /**
  18532. * Gets the unique ID of this manager
  18533. */
  18534. readonly uniqueId: number;
  18535. /**
  18536. * Gets the number of vertices handled by this manager
  18537. */
  18538. readonly vertexCount: number;
  18539. /**
  18540. * Gets a boolean indicating if this manager supports morphing of normals
  18541. */
  18542. readonly supportsNormals: boolean;
  18543. /**
  18544. * Gets a boolean indicating if this manager supports morphing of tangents
  18545. */
  18546. readonly supportsTangents: boolean;
  18547. /**
  18548. * Gets the number of targets stored in this manager
  18549. */
  18550. readonly numTargets: number;
  18551. /**
  18552. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18553. */
  18554. readonly numInfluencers: number;
  18555. /**
  18556. * Gets the list of influences (one per target)
  18557. */
  18558. readonly influences: Float32Array;
  18559. /**
  18560. * Gets the active target at specified index. An active target is a target with an influence > 0
  18561. * @param index defines the index to check
  18562. * @returns the requested target
  18563. */
  18564. getActiveTarget(index: number): MorphTarget;
  18565. /**
  18566. * Gets the target at specified index
  18567. * @param index defines the index to check
  18568. * @returns the requested target
  18569. */
  18570. getTarget(index: number): MorphTarget;
  18571. /**
  18572. * Add a new target to this manager
  18573. * @param target defines the target to add
  18574. */
  18575. addTarget(target: MorphTarget): void;
  18576. /**
  18577. * Removes a target from the manager
  18578. * @param target defines the target to remove
  18579. */
  18580. removeTarget(target: MorphTarget): void;
  18581. /**
  18582. * Serializes the current manager into a Serialization object
  18583. * @returns the serialized object
  18584. */
  18585. serialize(): any;
  18586. private _syncActiveTargets;
  18587. /**
  18588. * Syncrhonize the targets with all the meshes using this morph target manager
  18589. */
  18590. synchronize(): void;
  18591. /**
  18592. * Creates a new MorphTargetManager from serialized data
  18593. * @param serializationObject defines the serialized data
  18594. * @param scene defines the hosting scene
  18595. * @returns the new MorphTargetManager
  18596. */
  18597. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18598. }
  18599. }
  18600. declare module "babylonjs/Physics/physicsJoint" {
  18601. import { Vector3 } from "babylonjs/Maths/math";
  18602. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  18603. /**
  18604. * Interface for Physics-Joint data
  18605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18606. */
  18607. export interface PhysicsJointData {
  18608. /**
  18609. * The main pivot of the joint
  18610. */
  18611. mainPivot?: Vector3;
  18612. /**
  18613. * The connected pivot of the joint
  18614. */
  18615. connectedPivot?: Vector3;
  18616. /**
  18617. * The main axis of the joint
  18618. */
  18619. mainAxis?: Vector3;
  18620. /**
  18621. * The connected axis of the joint
  18622. */
  18623. connectedAxis?: Vector3;
  18624. /**
  18625. * The collision of the joint
  18626. */
  18627. collision?: boolean;
  18628. /**
  18629. * Native Oimo/Cannon/Energy data
  18630. */
  18631. nativeParams?: any;
  18632. }
  18633. /**
  18634. * This is a holder class for the physics joint created by the physics plugin
  18635. * It holds a set of functions to control the underlying joint
  18636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18637. */
  18638. export class PhysicsJoint {
  18639. /**
  18640. * The type of the physics joint
  18641. */
  18642. type: number;
  18643. /**
  18644. * The data for the physics joint
  18645. */
  18646. jointData: PhysicsJointData;
  18647. private _physicsJoint;
  18648. protected _physicsPlugin: IPhysicsEnginePlugin;
  18649. /**
  18650. * Initializes the physics joint
  18651. * @param type The type of the physics joint
  18652. * @param jointData The data for the physics joint
  18653. */
  18654. constructor(
  18655. /**
  18656. * The type of the physics joint
  18657. */
  18658. type: number,
  18659. /**
  18660. * The data for the physics joint
  18661. */
  18662. jointData: PhysicsJointData);
  18663. /**
  18664. * Gets the physics joint
  18665. */
  18666. /**
  18667. * Sets the physics joint
  18668. */
  18669. physicsJoint: any;
  18670. /**
  18671. * Sets the physics plugin
  18672. */
  18673. physicsPlugin: IPhysicsEnginePlugin;
  18674. /**
  18675. * Execute a function that is physics-plugin specific.
  18676. * @param {Function} func the function that will be executed.
  18677. * It accepts two parameters: the physics world and the physics joint
  18678. */
  18679. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18680. /**
  18681. * Distance-Joint type
  18682. */
  18683. static DistanceJoint: number;
  18684. /**
  18685. * Hinge-Joint type
  18686. */
  18687. static HingeJoint: number;
  18688. /**
  18689. * Ball-and-Socket joint type
  18690. */
  18691. static BallAndSocketJoint: number;
  18692. /**
  18693. * Wheel-Joint type
  18694. */
  18695. static WheelJoint: number;
  18696. /**
  18697. * Slider-Joint type
  18698. */
  18699. static SliderJoint: number;
  18700. /**
  18701. * Prismatic-Joint type
  18702. */
  18703. static PrismaticJoint: number;
  18704. /**
  18705. * Universal-Joint type
  18706. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18707. */
  18708. static UniversalJoint: number;
  18709. /**
  18710. * Hinge-Joint 2 type
  18711. */
  18712. static Hinge2Joint: number;
  18713. /**
  18714. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18715. */
  18716. static PointToPointJoint: number;
  18717. /**
  18718. * Spring-Joint type
  18719. */
  18720. static SpringJoint: number;
  18721. /**
  18722. * Lock-Joint type
  18723. */
  18724. static LockJoint: number;
  18725. }
  18726. /**
  18727. * A class representing a physics distance joint
  18728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18729. */
  18730. export class DistanceJoint extends PhysicsJoint {
  18731. /**
  18732. *
  18733. * @param jointData The data for the Distance-Joint
  18734. */
  18735. constructor(jointData: DistanceJointData);
  18736. /**
  18737. * Update the predefined distance.
  18738. * @param maxDistance The maximum preferred distance
  18739. * @param minDistance The minimum preferred distance
  18740. */
  18741. updateDistance(maxDistance: number, minDistance?: number): void;
  18742. }
  18743. /**
  18744. * Represents a Motor-Enabled Joint
  18745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18746. */
  18747. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18748. /**
  18749. * Initializes the Motor-Enabled Joint
  18750. * @param type The type of the joint
  18751. * @param jointData The physica joint data for the joint
  18752. */
  18753. constructor(type: number, jointData: PhysicsJointData);
  18754. /**
  18755. * Set the motor values.
  18756. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18757. * @param force the force to apply
  18758. * @param maxForce max force for this motor.
  18759. */
  18760. setMotor(force?: number, maxForce?: number): void;
  18761. /**
  18762. * Set the motor's limits.
  18763. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18764. * @param upperLimit The upper limit of the motor
  18765. * @param lowerLimit The lower limit of the motor
  18766. */
  18767. setLimit(upperLimit: number, lowerLimit?: number): void;
  18768. }
  18769. /**
  18770. * This class represents a single physics Hinge-Joint
  18771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18772. */
  18773. export class HingeJoint extends MotorEnabledJoint {
  18774. /**
  18775. * Initializes the Hinge-Joint
  18776. * @param jointData The joint data for the Hinge-Joint
  18777. */
  18778. constructor(jointData: PhysicsJointData);
  18779. /**
  18780. * Set the motor values.
  18781. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18782. * @param {number} force the force to apply
  18783. * @param {number} maxForce max force for this motor.
  18784. */
  18785. setMotor(force?: number, maxForce?: number): void;
  18786. /**
  18787. * Set the motor's limits.
  18788. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18789. * @param upperLimit The upper limit of the motor
  18790. * @param lowerLimit The lower limit of the motor
  18791. */
  18792. setLimit(upperLimit: number, lowerLimit?: number): void;
  18793. }
  18794. /**
  18795. * This class represents a dual hinge physics joint (same as wheel joint)
  18796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18797. */
  18798. export class Hinge2Joint extends MotorEnabledJoint {
  18799. /**
  18800. * Initializes the Hinge2-Joint
  18801. * @param jointData The joint data for the Hinge2-Joint
  18802. */
  18803. constructor(jointData: PhysicsJointData);
  18804. /**
  18805. * Set the motor values.
  18806. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18807. * @param {number} force the force to apply
  18808. * @param {number} maxForce max force for this motor.
  18809. * @param {motorIndex} the motor's index, 0 or 1.
  18810. */
  18811. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18812. /**
  18813. * Set the motor limits.
  18814. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18815. * @param {number} upperLimit the upper limit
  18816. * @param {number} lowerLimit lower limit
  18817. * @param {motorIndex} the motor's index, 0 or 1.
  18818. */
  18819. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18820. }
  18821. /**
  18822. * Interface for a motor enabled joint
  18823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18824. */
  18825. export interface IMotorEnabledJoint {
  18826. /**
  18827. * Physics joint
  18828. */
  18829. physicsJoint: any;
  18830. /**
  18831. * Sets the motor of the motor-enabled joint
  18832. * @param force The force of the motor
  18833. * @param maxForce The maximum force of the motor
  18834. * @param motorIndex The index of the motor
  18835. */
  18836. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18837. /**
  18838. * Sets the limit of the motor
  18839. * @param upperLimit The upper limit of the motor
  18840. * @param lowerLimit The lower limit of the motor
  18841. * @param motorIndex The index of the motor
  18842. */
  18843. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18844. }
  18845. /**
  18846. * Joint data for a Distance-Joint
  18847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18848. */
  18849. export interface DistanceJointData extends PhysicsJointData {
  18850. /**
  18851. * Max distance the 2 joint objects can be apart
  18852. */
  18853. maxDistance: number;
  18854. }
  18855. /**
  18856. * Joint data from a spring joint
  18857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18858. */
  18859. export interface SpringJointData extends PhysicsJointData {
  18860. /**
  18861. * Length of the spring
  18862. */
  18863. length: number;
  18864. /**
  18865. * Stiffness of the spring
  18866. */
  18867. stiffness: number;
  18868. /**
  18869. * Damping of the spring
  18870. */
  18871. damping: number;
  18872. /** this callback will be called when applying the force to the impostors. */
  18873. forceApplicationCallback: () => void;
  18874. }
  18875. }
  18876. declare module "babylonjs/Physics/IPhysicsEngine" {
  18877. import { Nullable } from "babylonjs/types";
  18878. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  18879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18880. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  18881. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  18882. /**
  18883. * Interface used to describe a physics joint
  18884. */
  18885. export interface PhysicsImpostorJoint {
  18886. /** Defines the main impostor to which the joint is linked */
  18887. mainImpostor: PhysicsImpostor;
  18888. /** Defines the impostor that is connected to the main impostor using this joint */
  18889. connectedImpostor: PhysicsImpostor;
  18890. /** Defines the joint itself */
  18891. joint: PhysicsJoint;
  18892. }
  18893. /** @hidden */
  18894. export interface IPhysicsEnginePlugin {
  18895. world: any;
  18896. name: string;
  18897. setGravity(gravity: Vector3): void;
  18898. setTimeStep(timeStep: number): void;
  18899. getTimeStep(): number;
  18900. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18901. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18902. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18903. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18904. removePhysicsBody(impostor: PhysicsImpostor): void;
  18905. generateJoint(joint: PhysicsImpostorJoint): void;
  18906. removeJoint(joint: PhysicsImpostorJoint): void;
  18907. isSupported(): boolean;
  18908. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18909. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18910. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18911. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18912. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18913. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18914. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18915. getBodyMass(impostor: PhysicsImpostor): number;
  18916. getBodyFriction(impostor: PhysicsImpostor): number;
  18917. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18918. getBodyRestitution(impostor: PhysicsImpostor): number;
  18919. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18920. sleepBody(impostor: PhysicsImpostor): void;
  18921. wakeUpBody(impostor: PhysicsImpostor): void;
  18922. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18923. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18924. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18925. getRadius(impostor: PhysicsImpostor): number;
  18926. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18927. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18928. dispose(): void;
  18929. }
  18930. /**
  18931. * Interface used to define a physics engine
  18932. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18933. */
  18934. export interface IPhysicsEngine {
  18935. /**
  18936. * Gets the gravity vector used by the simulation
  18937. */
  18938. gravity: Vector3;
  18939. /**
  18940. * Sets the gravity vector used by the simulation
  18941. * @param gravity defines the gravity vector to use
  18942. */
  18943. setGravity(gravity: Vector3): void;
  18944. /**
  18945. * Set the time step of the physics engine.
  18946. * Default is 1/60.
  18947. * To slow it down, enter 1/600 for example.
  18948. * To speed it up, 1/30
  18949. * @param newTimeStep the new timestep to apply to this world.
  18950. */
  18951. setTimeStep(newTimeStep: number): void;
  18952. /**
  18953. * Get the time step of the physics engine.
  18954. * @returns the current time step
  18955. */
  18956. getTimeStep(): number;
  18957. /**
  18958. * Release all resources
  18959. */
  18960. dispose(): void;
  18961. /**
  18962. * Gets the name of the current physics plugin
  18963. * @returns the name of the plugin
  18964. */
  18965. getPhysicsPluginName(): string;
  18966. /**
  18967. * Adding a new impostor for the impostor tracking.
  18968. * This will be done by the impostor itself.
  18969. * @param impostor the impostor to add
  18970. */
  18971. addImpostor(impostor: PhysicsImpostor): void;
  18972. /**
  18973. * Remove an impostor from the engine.
  18974. * This impostor and its mesh will not longer be updated by the physics engine.
  18975. * @param impostor the impostor to remove
  18976. */
  18977. removeImpostor(impostor: PhysicsImpostor): void;
  18978. /**
  18979. * Add a joint to the physics engine
  18980. * @param mainImpostor defines the main impostor to which the joint is added.
  18981. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  18982. * @param joint defines the joint that will connect both impostors.
  18983. */
  18984. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18985. /**
  18986. * Removes a joint from the simulation
  18987. * @param mainImpostor defines the impostor used with the joint
  18988. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  18989. * @param joint defines the joint to remove
  18990. */
  18991. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18992. /**
  18993. * Gets the current plugin used to run the simulation
  18994. * @returns current plugin
  18995. */
  18996. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18997. /**
  18998. * Gets the list of physic impostors
  18999. * @returns an array of PhysicsImpostor
  19000. */
  19001. getImpostors(): Array<PhysicsImpostor>;
  19002. /**
  19003. * Gets the impostor for a physics enabled object
  19004. * @param object defines the object impersonated by the impostor
  19005. * @returns the PhysicsImpostor or null if not found
  19006. */
  19007. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19008. /**
  19009. * Gets the impostor for a physics body object
  19010. * @param body defines physics body used by the impostor
  19011. * @returns the PhysicsImpostor or null if not found
  19012. */
  19013. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19014. /**
  19015. * Called by the scene. No need to call it.
  19016. * @param delta defines the timespam between frames
  19017. */
  19018. _step(delta: number): void;
  19019. }
  19020. }
  19021. declare module "babylonjs/Physics/physicsImpostor" {
  19022. import { Nullable, IndicesArray } from "babylonjs/types";
  19023. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19024. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19026. import { Scene } from "babylonjs/scene";
  19027. import { Bone } from "babylonjs/Bones/bone";
  19028. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19029. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19030. /**
  19031. * The interface for the physics imposter parameters
  19032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19033. */
  19034. export interface PhysicsImpostorParameters {
  19035. /**
  19036. * The mass of the physics imposter
  19037. */
  19038. mass: number;
  19039. /**
  19040. * The friction of the physics imposter
  19041. */
  19042. friction?: number;
  19043. /**
  19044. * The coefficient of restitution of the physics imposter
  19045. */
  19046. restitution?: number;
  19047. /**
  19048. * The native options of the physics imposter
  19049. */
  19050. nativeOptions?: any;
  19051. /**
  19052. * Specifies if the parent should be ignored
  19053. */
  19054. ignoreParent?: boolean;
  19055. /**
  19056. * Specifies if bi-directional transformations should be disabled
  19057. */
  19058. disableBidirectionalTransformation?: boolean;
  19059. }
  19060. /**
  19061. * Interface for a physics-enabled object
  19062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19063. */
  19064. export interface IPhysicsEnabledObject {
  19065. /**
  19066. * The position of the physics-enabled object
  19067. */
  19068. position: Vector3;
  19069. /**
  19070. * The rotation of the physics-enabled object
  19071. */
  19072. rotationQuaternion: Nullable<Quaternion>;
  19073. /**
  19074. * The scale of the physics-enabled object
  19075. */
  19076. scaling: Vector3;
  19077. /**
  19078. * The rotation of the physics-enabled object
  19079. */
  19080. rotation?: Vector3;
  19081. /**
  19082. * The parent of the physics-enabled object
  19083. */
  19084. parent?: any;
  19085. /**
  19086. * The bounding info of the physics-enabled object
  19087. * @returns The bounding info of the physics-enabled object
  19088. */
  19089. getBoundingInfo(): BoundingInfo;
  19090. /**
  19091. * Computes the world matrix
  19092. * @param force Specifies if the world matrix should be computed by force
  19093. * @returns A world matrix
  19094. */
  19095. computeWorldMatrix(force: boolean): Matrix;
  19096. /**
  19097. * Gets the world matrix
  19098. * @returns A world matrix
  19099. */
  19100. getWorldMatrix?(): Matrix;
  19101. /**
  19102. * Gets the child meshes
  19103. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19104. * @returns An array of abstract meshes
  19105. */
  19106. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19107. /**
  19108. * Gets the vertex data
  19109. * @param kind The type of vertex data
  19110. * @returns A nullable array of numbers, or a float32 array
  19111. */
  19112. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19113. /**
  19114. * Gets the indices from the mesh
  19115. * @returns A nullable array of index arrays
  19116. */
  19117. getIndices?(): Nullable<IndicesArray>;
  19118. /**
  19119. * Gets the scene from the mesh
  19120. * @returns the indices array or null
  19121. */
  19122. getScene?(): Scene;
  19123. /**
  19124. * Gets the absolute position from the mesh
  19125. * @returns the absolute position
  19126. */
  19127. getAbsolutePosition(): Vector3;
  19128. /**
  19129. * Gets the absolute pivot point from the mesh
  19130. * @returns the absolute pivot point
  19131. */
  19132. getAbsolutePivotPoint(): Vector3;
  19133. /**
  19134. * Rotates the mesh
  19135. * @param axis The axis of rotation
  19136. * @param amount The amount of rotation
  19137. * @param space The space of the rotation
  19138. * @returns The rotation transform node
  19139. */
  19140. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19141. /**
  19142. * Translates the mesh
  19143. * @param axis The axis of translation
  19144. * @param distance The distance of translation
  19145. * @param space The space of the translation
  19146. * @returns The transform node
  19147. */
  19148. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19149. /**
  19150. * Sets the absolute position of the mesh
  19151. * @param absolutePosition The absolute position of the mesh
  19152. * @returns The transform node
  19153. */
  19154. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19155. /**
  19156. * Gets the class name of the mesh
  19157. * @returns The class name
  19158. */
  19159. getClassName(): string;
  19160. }
  19161. /**
  19162. * Represents a physics imposter
  19163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19164. */
  19165. export class PhysicsImpostor {
  19166. /**
  19167. * The physics-enabled object used as the physics imposter
  19168. */
  19169. object: IPhysicsEnabledObject;
  19170. /**
  19171. * The type of the physics imposter
  19172. */
  19173. type: number;
  19174. private _options;
  19175. private _scene?;
  19176. /**
  19177. * The default object size of the imposter
  19178. */
  19179. static DEFAULT_OBJECT_SIZE: Vector3;
  19180. /**
  19181. * The identity quaternion of the imposter
  19182. */
  19183. static IDENTITY_QUATERNION: Quaternion;
  19184. /** @hidden */
  19185. _pluginData: any;
  19186. private _physicsEngine;
  19187. private _physicsBody;
  19188. private _bodyUpdateRequired;
  19189. private _onBeforePhysicsStepCallbacks;
  19190. private _onAfterPhysicsStepCallbacks;
  19191. /** @hidden */
  19192. _onPhysicsCollideCallbacks: Array<{
  19193. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19194. otherImpostors: Array<PhysicsImpostor>;
  19195. }>;
  19196. private _deltaPosition;
  19197. private _deltaRotation;
  19198. private _deltaRotationConjugated;
  19199. private _parent;
  19200. private _isDisposed;
  19201. private static _tmpVecs;
  19202. private static _tmpQuat;
  19203. /**
  19204. * Specifies if the physics imposter is disposed
  19205. */
  19206. readonly isDisposed: boolean;
  19207. /**
  19208. * Gets the mass of the physics imposter
  19209. */
  19210. mass: number;
  19211. /**
  19212. * Gets the coefficient of friction
  19213. */
  19214. /**
  19215. * Sets the coefficient of friction
  19216. */
  19217. friction: number;
  19218. /**
  19219. * Gets the coefficient of restitution
  19220. */
  19221. /**
  19222. * Sets the coefficient of restitution
  19223. */
  19224. restitution: number;
  19225. /**
  19226. * The unique id of the physics imposter
  19227. * set by the physics engine when adding this impostor to the array
  19228. */
  19229. uniqueId: number;
  19230. private _joints;
  19231. /**
  19232. * Initializes the physics imposter
  19233. * @param object The physics-enabled object used as the physics imposter
  19234. * @param type The type of the physics imposter
  19235. * @param _options The options for the physics imposter
  19236. * @param _scene The Babylon scene
  19237. */
  19238. constructor(
  19239. /**
  19240. * The physics-enabled object used as the physics imposter
  19241. */
  19242. object: IPhysicsEnabledObject,
  19243. /**
  19244. * The type of the physics imposter
  19245. */
  19246. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19247. /**
  19248. * This function will completly initialize this impostor.
  19249. * It will create a new body - but only if this mesh has no parent.
  19250. * If it has, this impostor will not be used other than to define the impostor
  19251. * of the child mesh.
  19252. * @hidden
  19253. */
  19254. _init(): void;
  19255. private _getPhysicsParent;
  19256. /**
  19257. * Should a new body be generated.
  19258. * @returns boolean specifying if body initialization is required
  19259. */
  19260. isBodyInitRequired(): boolean;
  19261. /**
  19262. * Sets the updated scaling
  19263. * @param updated Specifies if the scaling is updated
  19264. */
  19265. setScalingUpdated(): void;
  19266. /**
  19267. * Force a regeneration of this or the parent's impostor's body.
  19268. * Use under cautious - This will remove all joints already implemented.
  19269. */
  19270. forceUpdate(): void;
  19271. /**
  19272. * Gets the body that holds this impostor. Either its own, or its parent.
  19273. */
  19274. /**
  19275. * Set the physics body. Used mainly by the physics engine/plugin
  19276. */
  19277. physicsBody: any;
  19278. /**
  19279. * Get the parent of the physics imposter
  19280. * @returns Physics imposter or null
  19281. */
  19282. /**
  19283. * Sets the parent of the physics imposter
  19284. */
  19285. parent: Nullable<PhysicsImpostor>;
  19286. /**
  19287. * Resets the update flags
  19288. */
  19289. resetUpdateFlags(): void;
  19290. /**
  19291. * Gets the object extend size
  19292. * @returns the object extend size
  19293. */
  19294. getObjectExtendSize(): Vector3;
  19295. /**
  19296. * Gets the object center
  19297. * @returns The object center
  19298. */
  19299. getObjectCenter(): Vector3;
  19300. /**
  19301. * Get a specific parametes from the options parameter
  19302. * @param paramName The object parameter name
  19303. * @returns The object parameter
  19304. */
  19305. getParam(paramName: string): any;
  19306. /**
  19307. * Sets a specific parameter in the options given to the physics plugin
  19308. * @param paramName The parameter name
  19309. * @param value The value of the parameter
  19310. */
  19311. setParam(paramName: string, value: number): void;
  19312. /**
  19313. * Specifically change the body's mass option. Won't recreate the physics body object
  19314. * @param mass The mass of the physics imposter
  19315. */
  19316. setMass(mass: number): void;
  19317. /**
  19318. * Gets the linear velocity
  19319. * @returns linear velocity or null
  19320. */
  19321. getLinearVelocity(): Nullable<Vector3>;
  19322. /**
  19323. * Sets the linear velocity
  19324. * @param velocity linear velocity or null
  19325. */
  19326. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19327. /**
  19328. * Gets the angular velocity
  19329. * @returns angular velocity or null
  19330. */
  19331. getAngularVelocity(): Nullable<Vector3>;
  19332. /**
  19333. * Sets the angular velocity
  19334. * @param velocity The velocity or null
  19335. */
  19336. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19337. /**
  19338. * Execute a function with the physics plugin native code
  19339. * Provide a function the will have two variables - the world object and the physics body object
  19340. * @param func The function to execute with the physics plugin native code
  19341. */
  19342. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19343. /**
  19344. * Register a function that will be executed before the physics world is stepping forward
  19345. * @param func The function to execute before the physics world is stepped forward
  19346. */
  19347. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19348. /**
  19349. * Unregister a function that will be executed before the physics world is stepping forward
  19350. * @param func The function to execute before the physics world is stepped forward
  19351. */
  19352. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19353. /**
  19354. * Register a function that will be executed after the physics step
  19355. * @param func The function to execute after physics step
  19356. */
  19357. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19358. /**
  19359. * Unregisters a function that will be executed after the physics step
  19360. * @param func The function to execute after physics step
  19361. */
  19362. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19363. /**
  19364. * register a function that will be executed when this impostor collides against a different body
  19365. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19366. * @param func Callback that is executed on collision
  19367. */
  19368. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19369. /**
  19370. * Unregisters the physics imposter on contact
  19371. * @param collideAgainst The physics object to collide against
  19372. * @param func Callback to execute on collision
  19373. */
  19374. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19375. private _tmpQuat;
  19376. private _tmpQuat2;
  19377. /**
  19378. * Get the parent rotation
  19379. * @returns The parent rotation
  19380. */
  19381. getParentsRotation(): Quaternion;
  19382. /**
  19383. * this function is executed by the physics engine.
  19384. */
  19385. beforeStep: () => void;
  19386. /**
  19387. * this function is executed by the physics engine
  19388. */
  19389. afterStep: () => void;
  19390. /**
  19391. * Legacy collision detection event support
  19392. */
  19393. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19394. /**
  19395. * event and body object due to cannon's event-based architecture.
  19396. */
  19397. onCollide: (e: {
  19398. body: any;
  19399. }) => void;
  19400. /**
  19401. * Apply a force
  19402. * @param force The force to apply
  19403. * @param contactPoint The contact point for the force
  19404. * @returns The physics imposter
  19405. */
  19406. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19407. /**
  19408. * Apply an impulse
  19409. * @param force The impulse force
  19410. * @param contactPoint The contact point for the impulse force
  19411. * @returns The physics imposter
  19412. */
  19413. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19414. /**
  19415. * A help function to create a joint
  19416. * @param otherImpostor A physics imposter used to create a joint
  19417. * @param jointType The type of joint
  19418. * @param jointData The data for the joint
  19419. * @returns The physics imposter
  19420. */
  19421. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19422. /**
  19423. * Add a joint to this impostor with a different impostor
  19424. * @param otherImpostor A physics imposter used to add a joint
  19425. * @param joint The joint to add
  19426. * @returns The physics imposter
  19427. */
  19428. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19429. /**
  19430. * Will keep this body still, in a sleep mode.
  19431. * @returns the physics imposter
  19432. */
  19433. sleep(): PhysicsImpostor;
  19434. /**
  19435. * Wake the body up.
  19436. * @returns The physics imposter
  19437. */
  19438. wakeUp(): PhysicsImpostor;
  19439. /**
  19440. * Clones the physics imposter
  19441. * @param newObject The physics imposter clones to this physics-enabled object
  19442. * @returns A nullable physics imposter
  19443. */
  19444. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19445. /**
  19446. * Disposes the physics imposter
  19447. */
  19448. dispose(): void;
  19449. /**
  19450. * Sets the delta position
  19451. * @param position The delta position amount
  19452. */
  19453. setDeltaPosition(position: Vector3): void;
  19454. /**
  19455. * Sets the delta rotation
  19456. * @param rotation The delta rotation amount
  19457. */
  19458. setDeltaRotation(rotation: Quaternion): void;
  19459. /**
  19460. * Gets the box size of the physics imposter and stores the result in the input parameter
  19461. * @param result Stores the box size
  19462. * @returns The physics imposter
  19463. */
  19464. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19465. /**
  19466. * Gets the radius of the physics imposter
  19467. * @returns Radius of the physics imposter
  19468. */
  19469. getRadius(): number;
  19470. /**
  19471. * Sync a bone with this impostor
  19472. * @param bone The bone to sync to the impostor.
  19473. * @param boneMesh The mesh that the bone is influencing.
  19474. * @param jointPivot The pivot of the joint / bone in local space.
  19475. * @param distToJoint Optional distance from the impostor to the joint.
  19476. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19477. */
  19478. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19479. /**
  19480. * Sync impostor to a bone
  19481. * @param bone The bone that the impostor will be synced to.
  19482. * @param boneMesh The mesh that the bone is influencing.
  19483. * @param jointPivot The pivot of the joint / bone in local space.
  19484. * @param distToJoint Optional distance from the impostor to the joint.
  19485. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19486. * @param boneAxis Optional vector3 axis the bone is aligned with
  19487. */
  19488. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19489. /**
  19490. * No-Imposter type
  19491. */
  19492. static NoImpostor: number;
  19493. /**
  19494. * Sphere-Imposter type
  19495. */
  19496. static SphereImpostor: number;
  19497. /**
  19498. * Box-Imposter type
  19499. */
  19500. static BoxImpostor: number;
  19501. /**
  19502. * Plane-Imposter type
  19503. */
  19504. static PlaneImpostor: number;
  19505. /**
  19506. * Mesh-imposter type
  19507. */
  19508. static MeshImpostor: number;
  19509. /**
  19510. * Cylinder-Imposter type
  19511. */
  19512. static CylinderImpostor: number;
  19513. /**
  19514. * Particle-Imposter type
  19515. */
  19516. static ParticleImpostor: number;
  19517. /**
  19518. * Heightmap-Imposter type
  19519. */
  19520. static HeightmapImpostor: number;
  19521. }
  19522. }
  19523. declare module "babylonjs/Meshes/groundMesh" {
  19524. import { Scene } from "babylonjs/scene";
  19525. import { Vector3 } from "babylonjs/Maths/math";
  19526. import { Mesh } from "babylonjs/Meshes/mesh";
  19527. /**
  19528. * Mesh representing the gorund
  19529. */
  19530. export class GroundMesh extends Mesh {
  19531. /** If octree should be generated */
  19532. generateOctree: boolean;
  19533. private _heightQuads;
  19534. /** @hidden */
  19535. _subdivisionsX: number;
  19536. /** @hidden */
  19537. _subdivisionsY: number;
  19538. /** @hidden */
  19539. _width: number;
  19540. /** @hidden */
  19541. _height: number;
  19542. /** @hidden */
  19543. _minX: number;
  19544. /** @hidden */
  19545. _maxX: number;
  19546. /** @hidden */
  19547. _minZ: number;
  19548. /** @hidden */
  19549. _maxZ: number;
  19550. constructor(name: string, scene: Scene);
  19551. /**
  19552. * "GroundMesh"
  19553. * @returns "GroundMesh"
  19554. */
  19555. getClassName(): string;
  19556. /**
  19557. * The minimum of x and y subdivisions
  19558. */
  19559. readonly subdivisions: number;
  19560. /**
  19561. * X subdivisions
  19562. */
  19563. readonly subdivisionsX: number;
  19564. /**
  19565. * Y subdivisions
  19566. */
  19567. readonly subdivisionsY: number;
  19568. /**
  19569. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19570. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19571. * @param chunksCount the number of subdivisions for x and y
  19572. * @param octreeBlocksSize (Default: 32)
  19573. */
  19574. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19575. /**
  19576. * Returns a height (y) value in the Worl system :
  19577. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19578. * @param x x coordinate
  19579. * @param z z coordinate
  19580. * @returns the ground y position if (x, z) are outside the ground surface.
  19581. */
  19582. getHeightAtCoordinates(x: number, z: number): number;
  19583. /**
  19584. * Returns a normalized vector (Vector3) orthogonal to the ground
  19585. * at the ground coordinates (x, z) expressed in the World system.
  19586. * @param x x coordinate
  19587. * @param z z coordinate
  19588. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19589. */
  19590. getNormalAtCoordinates(x: number, z: number): Vector3;
  19591. /**
  19592. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19593. * at the ground coordinates (x, z) expressed in the World system.
  19594. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19595. * @param x x coordinate
  19596. * @param z z coordinate
  19597. * @param ref vector to store the result
  19598. * @returns the GroundMesh.
  19599. */
  19600. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19601. /**
  19602. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19603. * if the ground has been updated.
  19604. * This can be used in the render loop.
  19605. * @returns the GroundMesh.
  19606. */
  19607. updateCoordinateHeights(): GroundMesh;
  19608. private _getFacetAt;
  19609. private _initHeightQuads;
  19610. private _computeHeightQuads;
  19611. /**
  19612. * Serializes this ground mesh
  19613. * @param serializationObject object to write serialization to
  19614. */
  19615. serialize(serializationObject: any): void;
  19616. /**
  19617. * Parses a serialized ground mesh
  19618. * @param parsedMesh the serialized mesh
  19619. * @param scene the scene to create the ground mesh in
  19620. * @returns the created ground mesh
  19621. */
  19622. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19623. }
  19624. }
  19625. declare module "babylonjs/Meshes/mesh" {
  19626. import { Observable } from "babylonjs/Misc/observable";
  19627. import { IAnimatable } from "babylonjs/Misc/tools";
  19628. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19629. import { Camera } from "babylonjs/Cameras/camera";
  19630. import { Scene } from "babylonjs/scene";
  19631. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  19632. import { Engine } from "babylonjs/Engines/engine";
  19633. import { Node } from "babylonjs/node";
  19634. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19635. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  19636. import { Buffer } from "babylonjs/Meshes/buffer";
  19637. import { Geometry } from "babylonjs/Meshes/geometry";
  19638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19639. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19640. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  19641. import { Effect } from "babylonjs/Materials/effect";
  19642. import { Material } from "babylonjs/Materials/material";
  19643. import { Skeleton } from "babylonjs/Bones/skeleton";
  19644. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  19645. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  19646. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19647. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  19648. /**
  19649. * Class used to represent a specific level of detail of a mesh
  19650. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19651. */
  19652. export class MeshLODLevel {
  19653. /** Defines the distance where this level should star being displayed */
  19654. distance: number;
  19655. /** Defines the mesh to use to render this level */
  19656. mesh: Nullable<Mesh>;
  19657. /**
  19658. * Creates a new LOD level
  19659. * @param distance defines the distance where this level should star being displayed
  19660. * @param mesh defines the mesh to use to render this level
  19661. */
  19662. constructor(
  19663. /** Defines the distance where this level should star being displayed */
  19664. distance: number,
  19665. /** Defines the mesh to use to render this level */
  19666. mesh: Nullable<Mesh>);
  19667. }
  19668. /**
  19669. * @hidden
  19670. **/
  19671. export class _CreationDataStorage {
  19672. closePath?: boolean;
  19673. closeArray?: boolean;
  19674. idx: number[];
  19675. dashSize: number;
  19676. gapSize: number;
  19677. path3D: Path3D;
  19678. pathArray: Vector3[][];
  19679. arc: number;
  19680. radius: number;
  19681. cap: number;
  19682. tessellation: number;
  19683. }
  19684. /**
  19685. * @hidden
  19686. **/
  19687. class _InstanceDataStorage {
  19688. visibleInstances: any;
  19689. renderIdForInstances: number[];
  19690. batchCache: _InstancesBatch;
  19691. instancesBufferSize: number;
  19692. instancesBuffer: Nullable<Buffer>;
  19693. instancesData: Float32Array;
  19694. overridenInstanceCount: number;
  19695. }
  19696. /**
  19697. * @hidden
  19698. **/
  19699. export class _InstancesBatch {
  19700. mustReturn: boolean;
  19701. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  19702. renderSelf: boolean[];
  19703. }
  19704. /**
  19705. * Class used to represent renderable models
  19706. */
  19707. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19708. /**
  19709. * Mesh side orientation : usually the external or front surface
  19710. */
  19711. static readonly FRONTSIDE: number;
  19712. /**
  19713. * Mesh side orientation : usually the internal or back surface
  19714. */
  19715. static readonly BACKSIDE: number;
  19716. /**
  19717. * Mesh side orientation : both internal and external or front and back surfaces
  19718. */
  19719. static readonly DOUBLESIDE: number;
  19720. /**
  19721. * Mesh side orientation : by default, `FRONTSIDE`
  19722. */
  19723. static readonly DEFAULTSIDE: number;
  19724. /**
  19725. * Mesh cap setting : no cap
  19726. */
  19727. static readonly NO_CAP: number;
  19728. /**
  19729. * Mesh cap setting : one cap at the beginning of the mesh
  19730. */
  19731. static readonly CAP_START: number;
  19732. /**
  19733. * Mesh cap setting : one cap at the end of the mesh
  19734. */
  19735. static readonly CAP_END: number;
  19736. /**
  19737. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19738. */
  19739. static readonly CAP_ALL: number;
  19740. private _onBeforeRenderObservable;
  19741. private _onAfterRenderObservable;
  19742. private _onBeforeDrawObservable;
  19743. /**
  19744. * An event triggered before rendering the mesh
  19745. */
  19746. readonly onBeforeRenderObservable: Observable<Mesh>;
  19747. /**
  19748. * An event triggered after rendering the mesh
  19749. */
  19750. readonly onAfterRenderObservable: Observable<Mesh>;
  19751. /**
  19752. * An event triggered before drawing the mesh
  19753. */
  19754. readonly onBeforeDrawObservable: Observable<Mesh>;
  19755. private _onBeforeDrawObserver;
  19756. /**
  19757. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19758. */
  19759. onBeforeDraw: () => void;
  19760. /**
  19761. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19762. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19763. */
  19764. delayLoadState: number;
  19765. /**
  19766. * Gets the list of instances created from this mesh
  19767. * it is not supposed to be modified manually.
  19768. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19769. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19770. */
  19771. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  19772. /**
  19773. * Gets the file containing delay loading data for this mesh
  19774. */
  19775. delayLoadingFile: string;
  19776. /** @hidden */
  19777. _binaryInfo: any;
  19778. private _LODLevels;
  19779. /**
  19780. * User defined function used to change how LOD level selection is done
  19781. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19782. */
  19783. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19784. private _morphTargetManager;
  19785. /**
  19786. * Gets or sets the morph target manager
  19787. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19788. */
  19789. morphTargetManager: Nullable<MorphTargetManager>;
  19790. /** @hidden */
  19791. _creationDataStorage: Nullable<_CreationDataStorage>;
  19792. /** @hidden */
  19793. _geometry: Nullable<Geometry>;
  19794. /** @hidden */
  19795. _delayInfo: Array<string>;
  19796. /** @hidden */
  19797. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19798. /** @hidden */
  19799. _instanceDataStorage: _InstanceDataStorage;
  19800. private _effectiveMaterial;
  19801. /** @hidden */
  19802. _shouldGenerateFlatShading: boolean;
  19803. private _preActivateId;
  19804. /** @hidden */
  19805. _originalBuilderSideOrientation: number;
  19806. /**
  19807. * Use this property to change the original side orientation defined at construction time
  19808. */
  19809. overrideMaterialSideOrientation: Nullable<number>;
  19810. private _areNormalsFrozen;
  19811. private _sourcePositions;
  19812. private _sourceNormals;
  19813. private _source;
  19814. private meshMap;
  19815. /**
  19816. * Gets the source mesh (the one used to clone this one from)
  19817. */
  19818. readonly source: Nullable<Mesh>;
  19819. /**
  19820. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19821. */
  19822. isUnIndexed: boolean;
  19823. /**
  19824. * @constructor
  19825. * @param name The value used by scene.getMeshByName() to do a lookup.
  19826. * @param scene The scene to add this mesh to.
  19827. * @param parent The parent of this mesh, if it has one
  19828. * @param source An optional Mesh from which geometry is shared, cloned.
  19829. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19830. * When false, achieved by calling a clone(), also passing False.
  19831. * This will make creation of children, recursive.
  19832. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19833. */
  19834. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19835. /**
  19836. * Gets the class name
  19837. * @returns the string "Mesh".
  19838. */
  19839. getClassName(): string;
  19840. /** @hidden */
  19841. readonly _isMesh: boolean;
  19842. /**
  19843. * Returns a description of this mesh
  19844. * @param fullDetails define if full details about this mesh must be used
  19845. * @returns a descriptive string representing this mesh
  19846. */
  19847. toString(fullDetails?: boolean): string;
  19848. /** @hidden */
  19849. _unBindEffect(): void;
  19850. /**
  19851. * Gets a boolean indicating if this mesh has LOD
  19852. */
  19853. readonly hasLODLevels: boolean;
  19854. /**
  19855. * Gets the list of MeshLODLevel associated with the current mesh
  19856. * @returns an array of MeshLODLevel
  19857. */
  19858. getLODLevels(): MeshLODLevel[];
  19859. private _sortLODLevels;
  19860. /**
  19861. * Add a mesh as LOD level triggered at the given distance.
  19862. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19863. * @param distance The distance from the center of the object to show this level
  19864. * @param mesh The mesh to be added as LOD level (can be null)
  19865. * @return This mesh (for chaining)
  19866. */
  19867. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19868. /**
  19869. * Returns the LOD level mesh at the passed distance or null if not found.
  19870. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19871. * @param distance The distance from the center of the object to show this level
  19872. * @returns a Mesh or `null`
  19873. */
  19874. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19875. /**
  19876. * Remove a mesh from the LOD array
  19877. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19878. * @param mesh defines the mesh to be removed
  19879. * @return This mesh (for chaining)
  19880. */
  19881. removeLODLevel(mesh: Mesh): Mesh;
  19882. /**
  19883. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19884. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19885. * @param camera defines the camera to use to compute distance
  19886. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19887. * @return This mesh (for chaining)
  19888. */
  19889. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19890. /**
  19891. * Gets the mesh internal Geometry object
  19892. */
  19893. readonly geometry: Nullable<Geometry>;
  19894. /**
  19895. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19896. * @returns the total number of vertices
  19897. */
  19898. getTotalVertices(): number;
  19899. /**
  19900. * Returns the content of an associated vertex buffer
  19901. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19902. * - VertexBuffer.PositionKind
  19903. * - VertexBuffer.UVKind
  19904. * - VertexBuffer.UV2Kind
  19905. * - VertexBuffer.UV3Kind
  19906. * - VertexBuffer.UV4Kind
  19907. * - VertexBuffer.UV5Kind
  19908. * - VertexBuffer.UV6Kind
  19909. * - VertexBuffer.ColorKind
  19910. * - VertexBuffer.MatricesIndicesKind
  19911. * - VertexBuffer.MatricesIndicesExtraKind
  19912. * - VertexBuffer.MatricesWeightsKind
  19913. * - VertexBuffer.MatricesWeightsExtraKind
  19914. * @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
  19915. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19916. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19917. */
  19918. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19919. /**
  19920. * Returns the mesh VertexBuffer object from the requested `kind`
  19921. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19922. * - VertexBuffer.PositionKind
  19923. * - VertexBuffer.UVKind
  19924. * - VertexBuffer.UV2Kind
  19925. * - VertexBuffer.UV3Kind
  19926. * - VertexBuffer.UV4Kind
  19927. * - VertexBuffer.UV5Kind
  19928. * - VertexBuffer.UV6Kind
  19929. * - VertexBuffer.ColorKind
  19930. * - VertexBuffer.MatricesIndicesKind
  19931. * - VertexBuffer.MatricesIndicesExtraKind
  19932. * - VertexBuffer.MatricesWeightsKind
  19933. * - VertexBuffer.MatricesWeightsExtraKind
  19934. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19935. */
  19936. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19937. /**
  19938. * Tests if a specific vertex buffer is associated with this mesh
  19939. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19940. * - VertexBuffer.PositionKind
  19941. * - VertexBuffer.UVKind
  19942. * - VertexBuffer.UV2Kind
  19943. * - VertexBuffer.UV3Kind
  19944. * - VertexBuffer.UV4Kind
  19945. * - VertexBuffer.UV5Kind
  19946. * - VertexBuffer.UV6Kind
  19947. * - VertexBuffer.ColorKind
  19948. * - VertexBuffer.MatricesIndicesKind
  19949. * - VertexBuffer.MatricesIndicesExtraKind
  19950. * - VertexBuffer.MatricesWeightsKind
  19951. * - VertexBuffer.MatricesWeightsExtraKind
  19952. * @returns a boolean
  19953. */
  19954. isVerticesDataPresent(kind: string): boolean;
  19955. /**
  19956. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19957. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19958. * - VertexBuffer.PositionKind
  19959. * - VertexBuffer.UVKind
  19960. * - VertexBuffer.UV2Kind
  19961. * - VertexBuffer.UV3Kind
  19962. * - VertexBuffer.UV4Kind
  19963. * - VertexBuffer.UV5Kind
  19964. * - VertexBuffer.UV6Kind
  19965. * - VertexBuffer.ColorKind
  19966. * - VertexBuffer.MatricesIndicesKind
  19967. * - VertexBuffer.MatricesIndicesExtraKind
  19968. * - VertexBuffer.MatricesWeightsKind
  19969. * - VertexBuffer.MatricesWeightsExtraKind
  19970. * @returns a boolean
  19971. */
  19972. isVertexBufferUpdatable(kind: string): boolean;
  19973. /**
  19974. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19975. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19976. * - VertexBuffer.PositionKind
  19977. * - VertexBuffer.UVKind
  19978. * - VertexBuffer.UV2Kind
  19979. * - VertexBuffer.UV3Kind
  19980. * - VertexBuffer.UV4Kind
  19981. * - VertexBuffer.UV5Kind
  19982. * - VertexBuffer.UV6Kind
  19983. * - VertexBuffer.ColorKind
  19984. * - VertexBuffer.MatricesIndicesKind
  19985. * - VertexBuffer.MatricesIndicesExtraKind
  19986. * - VertexBuffer.MatricesWeightsKind
  19987. * - VertexBuffer.MatricesWeightsExtraKind
  19988. * @returns an array of strings
  19989. */
  19990. getVerticesDataKinds(): string[];
  19991. /**
  19992. * Returns a positive integer : the total number of indices in this mesh geometry.
  19993. * @returns the numner of indices or zero if the mesh has no geometry.
  19994. */
  19995. getTotalIndices(): number;
  19996. /**
  19997. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19998. * @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.
  19999. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20000. * @returns the indices array or an empty array if the mesh has no geometry
  20001. */
  20002. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20003. readonly isBlocked: boolean;
  20004. /**
  20005. * Determine if the current mesh is ready to be rendered
  20006. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20007. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20008. * @returns true if all associated assets are ready (material, textures, shaders)
  20009. */
  20010. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20011. /**
  20012. * 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.
  20013. */
  20014. readonly areNormalsFrozen: boolean;
  20015. /**
  20016. * 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.
  20017. * @returns the current mesh
  20018. */
  20019. freezeNormals(): Mesh;
  20020. /**
  20021. * 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
  20022. * @returns the current mesh
  20023. */
  20024. unfreezeNormals(): Mesh;
  20025. /**
  20026. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20027. */
  20028. overridenInstanceCount: number;
  20029. /** @hidden */
  20030. _preActivate(): Mesh;
  20031. /** @hidden */
  20032. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20033. /** @hidden */
  20034. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20035. /**
  20036. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20037. * This means the mesh underlying bounding box and sphere are recomputed.
  20038. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20039. * @returns the current mesh
  20040. */
  20041. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20042. /** @hidden */
  20043. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20044. /**
  20045. * This function will subdivide the mesh into multiple submeshes
  20046. * @param count defines the expected number of submeshes
  20047. */
  20048. subdivide(count: number): void;
  20049. /**
  20050. * Copy a FloatArray into a specific associated vertex buffer
  20051. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20052. * - VertexBuffer.PositionKind
  20053. * - VertexBuffer.UVKind
  20054. * - VertexBuffer.UV2Kind
  20055. * - VertexBuffer.UV3Kind
  20056. * - VertexBuffer.UV4Kind
  20057. * - VertexBuffer.UV5Kind
  20058. * - VertexBuffer.UV6Kind
  20059. * - VertexBuffer.ColorKind
  20060. * - VertexBuffer.MatricesIndicesKind
  20061. * - VertexBuffer.MatricesIndicesExtraKind
  20062. * - VertexBuffer.MatricesWeightsKind
  20063. * - VertexBuffer.MatricesWeightsExtraKind
  20064. * @param data defines the data source
  20065. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20066. * @param stride defines the data stride size (can be null)
  20067. * @returns the current mesh
  20068. */
  20069. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20070. /**
  20071. * Flags an associated vertex buffer as updatable
  20072. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20073. * - VertexBuffer.PositionKind
  20074. * - VertexBuffer.UVKind
  20075. * - VertexBuffer.UV2Kind
  20076. * - VertexBuffer.UV3Kind
  20077. * - VertexBuffer.UV4Kind
  20078. * - VertexBuffer.UV5Kind
  20079. * - VertexBuffer.UV6Kind
  20080. * - VertexBuffer.ColorKind
  20081. * - VertexBuffer.MatricesIndicesKind
  20082. * - VertexBuffer.MatricesIndicesExtraKind
  20083. * - VertexBuffer.MatricesWeightsKind
  20084. * - VertexBuffer.MatricesWeightsExtraKind
  20085. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20086. */
  20087. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20088. /**
  20089. * Sets the mesh global Vertex Buffer
  20090. * @param buffer defines the buffer to use
  20091. * @returns the current mesh
  20092. */
  20093. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20094. /**
  20095. * Update a specific associated vertex buffer
  20096. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20097. * - VertexBuffer.PositionKind
  20098. * - VertexBuffer.UVKind
  20099. * - VertexBuffer.UV2Kind
  20100. * - VertexBuffer.UV3Kind
  20101. * - VertexBuffer.UV4Kind
  20102. * - VertexBuffer.UV5Kind
  20103. * - VertexBuffer.UV6Kind
  20104. * - VertexBuffer.ColorKind
  20105. * - VertexBuffer.MatricesIndicesKind
  20106. * - VertexBuffer.MatricesIndicesExtraKind
  20107. * - VertexBuffer.MatricesWeightsKind
  20108. * - VertexBuffer.MatricesWeightsExtraKind
  20109. * @param data defines the data source
  20110. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20111. * @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)
  20112. * @returns the current mesh
  20113. */
  20114. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20115. /**
  20116. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20117. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20118. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20119. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20120. * @returns the current mesh
  20121. */
  20122. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20123. /**
  20124. * Creates a un-shared specific occurence of the geometry for the mesh.
  20125. * @returns the current mesh
  20126. */
  20127. makeGeometryUnique(): Mesh;
  20128. /**
  20129. * Set the index buffer of this mesh
  20130. * @param indices defines the source data
  20131. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20132. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20133. * @returns the current mesh
  20134. */
  20135. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20136. /**
  20137. * Update the current index buffer
  20138. * @param indices defines the source data
  20139. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20140. * @returns the current mesh
  20141. */
  20142. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20143. /**
  20144. * Invert the geometry to move from a right handed system to a left handed one.
  20145. * @returns the current mesh
  20146. */
  20147. toLeftHanded(): Mesh;
  20148. /** @hidden */
  20149. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20150. /** @hidden */
  20151. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20152. /**
  20153. * Registers for this mesh a javascript function called just before the rendering process
  20154. * @param func defines the function to call before rendering this mesh
  20155. * @returns the current mesh
  20156. */
  20157. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20158. /**
  20159. * Disposes a previously registered javascript function called before the rendering
  20160. * @param func defines the function to remove
  20161. * @returns the current mesh
  20162. */
  20163. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20164. /**
  20165. * Registers for this mesh a javascript function called just after the rendering is complete
  20166. * @param func defines the function to call after rendering this mesh
  20167. * @returns the current mesh
  20168. */
  20169. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20170. /**
  20171. * Disposes a previously registered javascript function called after the rendering.
  20172. * @param func defines the function to remove
  20173. * @returns the current mesh
  20174. */
  20175. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20176. /** @hidden */
  20177. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20178. /** @hidden */
  20179. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20180. /** @hidden */
  20181. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20182. /**
  20183. * 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
  20184. * @param subMesh defines the subMesh to render
  20185. * @param enableAlphaMode defines if alpha mode can be changed
  20186. * @returns the current mesh
  20187. */
  20188. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20189. private _onBeforeDraw;
  20190. /**
  20191. * Renormalize the mesh and patch it up if there are no weights
  20192. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20193. * However in the case of zero weights then we set just a single influence to 1.
  20194. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20195. */
  20196. cleanMatrixWeights(): void;
  20197. private normalizeSkinFourWeights;
  20198. private normalizeSkinWeightsAndExtra;
  20199. /**
  20200. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20201. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20202. * the user know there was an issue with importing the mesh
  20203. * @returns a validation object with skinned, valid and report string
  20204. */
  20205. validateSkinning(): {
  20206. skinned: boolean;
  20207. valid: boolean;
  20208. report: string;
  20209. };
  20210. /** @hidden */
  20211. _checkDelayState(): Mesh;
  20212. private _queueLoad;
  20213. /**
  20214. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20215. * A mesh is in the frustum if its bounding box intersects the frustum
  20216. * @param frustumPlanes defines the frustum to test
  20217. * @returns true if the mesh is in the frustum planes
  20218. */
  20219. isInFrustum(frustumPlanes: Plane[]): boolean;
  20220. /**
  20221. * Sets the mesh material by the material or multiMaterial `id` property
  20222. * @param id is a string identifying the material or the multiMaterial
  20223. * @returns the current mesh
  20224. */
  20225. setMaterialByID(id: string): Mesh;
  20226. /**
  20227. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20228. * @returns an array of IAnimatable
  20229. */
  20230. getAnimatables(): IAnimatable[];
  20231. /**
  20232. * Modifies the mesh geometry according to the passed transformation matrix.
  20233. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20234. * The mesh normals are modified using the same transformation.
  20235. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20236. * @param transform defines the transform matrix to use
  20237. * @see http://doc.babylonjs.com/resources/baking_transformations
  20238. * @returns the current mesh
  20239. */
  20240. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20241. /**
  20242. * Modifies the mesh geometry according to its own current World Matrix.
  20243. * The mesh World Matrix is then reset.
  20244. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20245. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20246. * @see http://doc.babylonjs.com/resources/baking_transformations
  20247. * @returns the current mesh
  20248. */
  20249. bakeCurrentTransformIntoVertices(): Mesh;
  20250. /** @hidden */
  20251. readonly _positions: Nullable<Vector3[]>;
  20252. /** @hidden */
  20253. _resetPointsArrayCache(): Mesh;
  20254. /** @hidden */
  20255. _generatePointsArray(): boolean;
  20256. /**
  20257. * Returns a new Mesh object generated from the current mesh properties.
  20258. * This method must not get confused with createInstance()
  20259. * @param name is a string, the name given to the new mesh
  20260. * @param newParent can be any Node object (default `null`)
  20261. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20262. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20263. * @returns a new mesh
  20264. */
  20265. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20266. /**
  20267. * Releases resources associated with this mesh.
  20268. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20269. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20270. */
  20271. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20272. /**
  20273. * Modifies the mesh geometry according to a displacement map.
  20274. * 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.
  20275. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20276. * @param url is a string, the URL from the image file is to be downloaded.
  20277. * @param minHeight is the lower limit of the displacement.
  20278. * @param maxHeight is the upper limit of the displacement.
  20279. * @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.
  20280. * @param uvOffset is an optional vector2 used to offset UV.
  20281. * @param uvScale is an optional vector2 used to scale UV.
  20282. * @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.
  20283. * @returns the Mesh.
  20284. */
  20285. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20286. /**
  20287. * Modifies the mesh geometry according to a displacementMap buffer.
  20288. * 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.
  20289. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20290. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20291. * @param heightMapWidth is the width of the buffer image.
  20292. * @param heightMapHeight is the height of the buffer image.
  20293. * @param minHeight is the lower limit of the displacement.
  20294. * @param maxHeight is the upper limit of the displacement.
  20295. * @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.
  20296. * @param uvOffset is an optional vector2 used to offset UV.
  20297. * @param uvScale is an optional vector2 used to scale UV.
  20298. * @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.
  20299. * @returns the Mesh.
  20300. */
  20301. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20302. /**
  20303. * Modify the mesh to get a flat shading rendering.
  20304. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20305. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20306. * @returns current mesh
  20307. */
  20308. convertToFlatShadedMesh(): Mesh;
  20309. /**
  20310. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20311. * In other words, more vertices, no more indices and a single bigger VBO.
  20312. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20313. * @returns current mesh
  20314. */
  20315. convertToUnIndexedMesh(): Mesh;
  20316. /**
  20317. * Inverses facet orientations.
  20318. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20319. * @param flipNormals will also inverts the normals
  20320. * @returns current mesh
  20321. */
  20322. flipFaces(flipNormals?: boolean): Mesh;
  20323. /** @hidden */
  20324. static _instancedMeshFactory: (name: string, mesh: Mesh) => import("babylonjs/Meshes/instancedMesh").InstancedMesh;
  20325. /**
  20326. * Creates a new InstancedMesh object from the mesh model.
  20327. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20328. * @param name defines the name of the new instance
  20329. * @returns a new InstancedMesh
  20330. */
  20331. createInstance(name: string): InstancedMesh;
  20332. /**
  20333. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20334. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20335. * @returns the current mesh
  20336. */
  20337. synchronizeInstances(): Mesh;
  20338. /**
  20339. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20340. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20341. * This should be used together with the simplification to avoid disappearing triangles.
  20342. * @param successCallback an optional success callback to be called after the optimization finished.
  20343. * @returns the current mesh
  20344. */
  20345. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20346. /**
  20347. * Serialize current mesh
  20348. * @param serializationObject defines the object which will receive the serialization data
  20349. */
  20350. serialize(serializationObject: any): void;
  20351. /** @hidden */
  20352. _syncGeometryWithMorphTargetManager(): void;
  20353. /** @hidden */
  20354. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20355. /**
  20356. * Returns a new Mesh object parsed from the source provided.
  20357. * @param parsedMesh is the source
  20358. * @param scene defines the hosting scene
  20359. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20360. * @returns a new Mesh
  20361. */
  20362. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20363. /**
  20364. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20365. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20366. * @param name defines the name of the mesh to create
  20367. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20368. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20369. * @param closePath creates a seam between the first and the last points of each path of the path array
  20370. * @param offset is taken in account only if the `pathArray` is containing a single path
  20371. * @param scene defines the hosting scene
  20372. * @param updatable defines if the mesh must be flagged as updatable
  20373. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20374. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  20375. * @returns a new Mesh
  20376. */
  20377. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20378. /**
  20379. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20380. * @param name defines the name of the mesh to create
  20381. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20382. * @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
  20383. * @param scene defines the hosting scene
  20384. * @param updatable defines if the mesh must be flagged as updatable
  20385. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20386. * @returns a new Mesh
  20387. */
  20388. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20389. /**
  20390. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20391. * @param name defines the name of the mesh to create
  20392. * @param size sets the size (float) of each box side (default 1)
  20393. * @param scene defines the hosting scene
  20394. * @param updatable defines if the mesh must be flagged as updatable
  20395. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20396. * @returns a new Mesh
  20397. */
  20398. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20399. /**
  20400. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20401. * @param name defines the name of the mesh to create
  20402. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20403. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20404. * @param scene defines the hosting scene
  20405. * @param updatable defines if the mesh must be flagged as updatable
  20406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20407. * @returns a new Mesh
  20408. */
  20409. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20410. /**
  20411. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  20412. * @param name defines the name of the mesh to create
  20413. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  20414. * @param diameterTop set the top cap diameter (floats, default 1)
  20415. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20416. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20417. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20418. * @param scene defines the hosting scene
  20419. * @param updatable defines if the mesh must be flagged as updatable
  20420. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20421. * @returns a new Mesh
  20422. */
  20423. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20424. /**
  20425. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20426. * @param name defines the name of the mesh to create
  20427. * @param diameter sets the diameter size (float) of the torus (default 1)
  20428. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20429. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20430. * @param scene defines the hosting scene
  20431. * @param updatable defines if the mesh must be flagged as updatable
  20432. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20433. * @returns a new Mesh
  20434. */
  20435. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20436. /**
  20437. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20438. * @param name defines the name of the mesh to create
  20439. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20440. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20441. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20442. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20443. * @param p the number of windings on X axis (positive integers, default 2)
  20444. * @param q the number of windings on Y axis (positive integers, default 3)
  20445. * @param scene defines the hosting scene
  20446. * @param updatable defines if the mesh must be flagged as updatable
  20447. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20448. * @returns a new Mesh
  20449. */
  20450. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20451. /**
  20452. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20453. * @param name defines the name of the mesh to create
  20454. * @param points is an array successive Vector3
  20455. * @param scene defines the hosting scene
  20456. * @param updatable defines if the mesh must be flagged as updatable
  20457. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  20458. * @returns a new Mesh
  20459. */
  20460. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20461. /**
  20462. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20463. * @param name defines the name of the mesh to create
  20464. * @param points is an array successive Vector3
  20465. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20466. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20467. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20468. * @param scene defines the hosting scene
  20469. * @param updatable defines if the mesh must be flagged as updatable
  20470. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  20471. * @returns a new Mesh
  20472. */
  20473. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20474. /**
  20475. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20476. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20477. * 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.
  20478. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20479. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20480. * Remember you can only change the shape positions, not their number when updating a polygon.
  20481. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20482. * @param name defines the name of the mesh to create
  20483. * @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
  20484. * @param scene defines the hosting scene
  20485. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20486. * @param updatable defines if the mesh must be flagged as updatable
  20487. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20488. * @returns a new Mesh
  20489. */
  20490. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20491. /**
  20492. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20493. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20494. * @param name defines the name of the mesh to create
  20495. * @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
  20496. * @param depth defines the height of extrusion
  20497. * @param scene defines the hosting scene
  20498. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20499. * @param updatable defines if the mesh must be flagged as updatable
  20500. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20501. * @returns a new Mesh
  20502. */
  20503. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20504. /**
  20505. * Creates an extruded shape mesh.
  20506. * 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
  20507. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20508. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20509. * @param name defines the name of the mesh to create
  20510. * @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
  20511. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20512. * @param scale is the value to scale the shape
  20513. * @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
  20514. * @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
  20515. * @param scene defines the hosting scene
  20516. * @param updatable defines if the mesh must be flagged as updatable
  20517. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20518. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  20519. * @returns a new Mesh
  20520. */
  20521. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20522. /**
  20523. * Creates an custom extruded shape mesh.
  20524. * The custom extrusion is a parametric shape.
  20525. * It has no predefined shape. Its final shape will depend on the input parameters.
  20526. * Please consider using the same method from the MeshBuilder class instead
  20527. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20528. * @param name defines the name of the mesh to create
  20529. * @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
  20530. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20531. * @param scaleFunction is a custom Javascript function called on each path point
  20532. * @param rotationFunction is a custom Javascript function called on each path point
  20533. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20534. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20535. * @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
  20536. * @param scene defines the hosting scene
  20537. * @param updatable defines if the mesh must be flagged as updatable
  20538. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20539. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  20540. * @returns a new Mesh
  20541. */
  20542. 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;
  20543. /**
  20544. * Creates lathe mesh.
  20545. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20546. * Please consider using the same method from the MeshBuilder class instead
  20547. * @param name defines the name of the mesh to create
  20548. * @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
  20549. * @param radius is the radius value of the lathe
  20550. * @param tessellation is the side number of the lathe.
  20551. * @param scene defines the hosting scene
  20552. * @param updatable defines if the mesh must be flagged as updatable
  20553. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20554. * @returns a new Mesh
  20555. */
  20556. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20557. /**
  20558. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  20559. * @param name defines the name of the mesh to create
  20560. * @param size sets the size (float) of both sides of the plane at once (default 1)
  20561. * @param scene defines the hosting scene
  20562. * @param updatable defines if the mesh must be flagged as updatable
  20563. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20564. * @returns a new Mesh
  20565. */
  20566. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20567. /**
  20568. * Creates a ground mesh.
  20569. * Please consider using the same method from the MeshBuilder class instead
  20570. * @param name defines the name of the mesh to create
  20571. * @param width set the width of the ground
  20572. * @param height set the height of the ground
  20573. * @param subdivisions sets the number of subdivisions per side
  20574. * @param scene defines the hosting scene
  20575. * @param updatable defines if the mesh must be flagged as updatable
  20576. * @returns a new Mesh
  20577. */
  20578. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20579. /**
  20580. * Creates a tiled ground mesh.
  20581. * Please consider using the same method from the MeshBuilder class instead
  20582. * @param name defines the name of the mesh to create
  20583. * @param xmin set the ground minimum X coordinate
  20584. * @param zmin set the ground minimum Y coordinate
  20585. * @param xmax set the ground maximum X coordinate
  20586. * @param zmax set the ground maximum Z coordinate
  20587. * @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
  20588. * @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
  20589. * @param scene defines the hosting scene
  20590. * @param updatable defines if the mesh must be flagged as updatable
  20591. * @returns a new Mesh
  20592. */
  20593. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20594. w: number;
  20595. h: number;
  20596. }, precision: {
  20597. w: number;
  20598. h: number;
  20599. }, scene: Scene, updatable?: boolean): Mesh;
  20600. /**
  20601. * Creates a ground mesh from a height map.
  20602. * Please consider using the same method from the MeshBuilder class instead
  20603. * @see http://doc.babylonjs.com/babylon101/height_map
  20604. * @param name defines the name of the mesh to create
  20605. * @param url sets the URL of the height map image resource
  20606. * @param width set the ground width size
  20607. * @param height set the ground height size
  20608. * @param subdivisions sets the number of subdivision per side
  20609. * @param minHeight is the minimum altitude on the ground
  20610. * @param maxHeight is the maximum altitude on the ground
  20611. * @param scene defines the hosting scene
  20612. * @param updatable defines if the mesh must be flagged as updatable
  20613. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  20614. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  20615. * @returns a new Mesh
  20616. */
  20617. 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;
  20618. /**
  20619. * Creates a tube mesh.
  20620. * The tube is a parametric shape.
  20621. * It has no predefined shape. Its final shape will depend on the input parameters.
  20622. * Please consider using the same method from the MeshBuilder class instead
  20623. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20624. * @param name defines the name of the mesh to create
  20625. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  20626. * @param radius sets the tube radius size
  20627. * @param tessellation is the number of sides on the tubular surface
  20628. * @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
  20629. * @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
  20630. * @param scene defines the hosting scene
  20631. * @param updatable defines if the mesh must be flagged as updatable
  20632. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20633. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  20634. * @returns a new Mesh
  20635. */
  20636. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20637. (i: number, distance: number): number;
  20638. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20639. /**
  20640. * Creates a polyhedron mesh.
  20641. * Please consider using the same method from the MeshBuilder class instead.
  20642. * * 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
  20643. * * The parameter `size` (positive float, default 1) sets the polygon size
  20644. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  20645. * * 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`
  20646. * * 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
  20647. * * 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)`)
  20648. * * 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
  20649. * * 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
  20650. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20653. * @param name defines the name of the mesh to create
  20654. * @param options defines the options used to create the mesh
  20655. * @param scene defines the hosting scene
  20656. * @returns a new Mesh
  20657. */
  20658. static CreatePolyhedron(name: string, options: {
  20659. type?: number;
  20660. size?: number;
  20661. sizeX?: number;
  20662. sizeY?: number;
  20663. sizeZ?: number;
  20664. custom?: any;
  20665. faceUV?: Vector4[];
  20666. faceColors?: Color4[];
  20667. updatable?: boolean;
  20668. sideOrientation?: number;
  20669. }, scene: Scene): Mesh;
  20670. /**
  20671. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  20672. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  20673. * * 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`)
  20674. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  20675. * * 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
  20676. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20679. * @param name defines the name of the mesh
  20680. * @param options defines the options used to create the mesh
  20681. * @param scene defines the hosting scene
  20682. * @returns a new Mesh
  20683. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20684. */
  20685. static CreateIcoSphere(name: string, options: {
  20686. radius?: number;
  20687. flat?: boolean;
  20688. subdivisions?: number;
  20689. sideOrientation?: number;
  20690. updatable?: boolean;
  20691. }, scene: Scene): Mesh;
  20692. /**
  20693. * Creates a decal mesh.
  20694. * Please consider using the same method from the MeshBuilder class instead.
  20695. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20696. * @param name defines the name of the mesh
  20697. * @param sourceMesh defines the mesh receiving the decal
  20698. * @param position sets the position of the decal in world coordinates
  20699. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20700. * @param size sets the decal scaling
  20701. * @param angle sets the angle to rotate the decal
  20702. * @returns a new Mesh
  20703. */
  20704. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20705. /**
  20706. * Prepare internal position array for software CPU skinning
  20707. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20708. */
  20709. setPositionsForCPUSkinning(): Float32Array;
  20710. /**
  20711. * Prepare internal normal array for software CPU skinning
  20712. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20713. */
  20714. setNormalsForCPUSkinning(): Float32Array;
  20715. /**
  20716. * Updates the vertex buffer by applying transformation from the bones
  20717. * @param skeleton defines the skeleton to apply to current mesh
  20718. * @returns the current mesh
  20719. */
  20720. applySkeleton(skeleton: Skeleton): Mesh;
  20721. /**
  20722. * 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
  20723. * @param meshes defines the list of meshes to scan
  20724. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20725. */
  20726. static MinMax(meshes: AbstractMesh[]): {
  20727. min: Vector3;
  20728. max: Vector3;
  20729. };
  20730. /**
  20731. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20732. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20733. * @returns a vector3
  20734. */
  20735. static Center(meshesOrMinMaxVector: {
  20736. min: Vector3;
  20737. max: Vector3;
  20738. } | AbstractMesh[]): Vector3;
  20739. /**
  20740. * Merge the array of meshes into a single mesh for performance reasons.
  20741. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20742. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20743. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20744. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20745. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20746. * @returns a new mesh
  20747. */
  20748. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  20749. /** @hidden */
  20750. addInstance(instance: InstancedMesh): void;
  20751. /** @hidden */
  20752. removeInstance(instance: InstancedMesh): void;
  20753. }
  20754. }
  20755. declare module "babylonjs/Actions/action" {
  20756. import { Observable } from "babylonjs/Misc/observable";
  20757. import { Condition } from "babylonjs/Actions/condition";
  20758. import { ActionManager } from "babylonjs/Actions/actionManager";
  20759. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  20760. /**
  20761. * The action to be carried out following a trigger
  20762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  20763. */
  20764. export class Action {
  20765. /** the trigger, with or without parameters, for the action */
  20766. triggerOptions: any;
  20767. /**
  20768. * Trigger for the action
  20769. */
  20770. trigger: number;
  20771. /**
  20772. * Internal only - manager for action
  20773. * @hidden
  20774. */
  20775. _actionManager: ActionManager;
  20776. private _nextActiveAction;
  20777. private _child;
  20778. private _condition?;
  20779. private _triggerParameter;
  20780. /**
  20781. * An event triggered prior to action being executed.
  20782. */
  20783. onBeforeExecuteObservable: Observable<Action>;
  20784. /**
  20785. * Creates a new Action
  20786. * @param triggerOptions the trigger, with or without parameters, for the action
  20787. * @param condition an optional determinant of action
  20788. */
  20789. constructor(
  20790. /** the trigger, with or without parameters, for the action */
  20791. triggerOptions: any, condition?: Condition);
  20792. /**
  20793. * Internal only
  20794. * @hidden
  20795. */
  20796. _prepare(): void;
  20797. /**
  20798. * Gets the trigger parameters
  20799. * @returns the trigger parameters
  20800. */
  20801. getTriggerParameter(): any;
  20802. /**
  20803. * Internal only - executes current action event
  20804. * @hidden
  20805. */
  20806. _executeCurrent(evt?: ActionEvent): void;
  20807. /**
  20808. * Execute placeholder for child classes
  20809. * @param evt optional action event
  20810. */
  20811. execute(evt?: ActionEvent): void;
  20812. /**
  20813. * Skips to next active action
  20814. */
  20815. skipToNextActiveAction(): void;
  20816. /**
  20817. * Adds action to chain of actions, may be a DoNothingAction
  20818. * @param action defines the next action to execute
  20819. * @returns The action passed in
  20820. * @see https://www.babylonjs-playground.com/#1T30HR#0
  20821. */
  20822. then(action: Action): Action;
  20823. /**
  20824. * Internal only
  20825. * @hidden
  20826. */
  20827. _getProperty(propertyPath: string): string;
  20828. /**
  20829. * Internal only
  20830. * @hidden
  20831. */
  20832. _getEffectiveTarget(target: any, propertyPath: string): any;
  20833. /**
  20834. * Serialize placeholder for child classes
  20835. * @param parent of child
  20836. * @returns the serialized object
  20837. */
  20838. serialize(parent: any): any;
  20839. /**
  20840. * Internal only called by serialize
  20841. * @hidden
  20842. */
  20843. protected _serialize(serializedAction: any, parent?: any): any;
  20844. /**
  20845. * Internal only
  20846. * @hidden
  20847. */
  20848. static _SerializeValueAsString: (value: any) => string;
  20849. /**
  20850. * Internal only
  20851. * @hidden
  20852. */
  20853. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  20854. name: string;
  20855. targetType: string;
  20856. value: string;
  20857. };
  20858. }
  20859. }
  20860. declare module "babylonjs/Actions/condition" {
  20861. import { ActionManager } from "babylonjs/Actions/actionManager";
  20862. /**
  20863. * A Condition applied to an Action
  20864. */
  20865. export class Condition {
  20866. /**
  20867. * Internal only - manager for action
  20868. * @hidden
  20869. */
  20870. _actionManager: ActionManager;
  20871. /**
  20872. * Internal only
  20873. * @hidden
  20874. */
  20875. _evaluationId: number;
  20876. /**
  20877. * Internal only
  20878. * @hidden
  20879. */
  20880. _currentResult: boolean;
  20881. /**
  20882. * Creates a new Condition
  20883. * @param actionManager the manager of the action the condition is applied to
  20884. */
  20885. constructor(actionManager: ActionManager);
  20886. /**
  20887. * Check if the current condition is valid
  20888. * @returns a boolean
  20889. */
  20890. isValid(): boolean;
  20891. /**
  20892. * Internal only
  20893. * @hidden
  20894. */
  20895. _getProperty(propertyPath: string): string;
  20896. /**
  20897. * Internal only
  20898. * @hidden
  20899. */
  20900. _getEffectiveTarget(target: any, propertyPath: string): any;
  20901. /**
  20902. * Serialize placeholder for child classes
  20903. * @returns the serialized object
  20904. */
  20905. serialize(): any;
  20906. /**
  20907. * Internal only
  20908. * @hidden
  20909. */
  20910. protected _serialize(serializedCondition: any): any;
  20911. }
  20912. /**
  20913. * Defines specific conditional operators as extensions of Condition
  20914. */
  20915. export class ValueCondition extends Condition {
  20916. /** path to specify the property of the target the conditional operator uses */
  20917. propertyPath: string;
  20918. /** the value compared by the conditional operator against the current value of the property */
  20919. value: any;
  20920. /** the conditional operator, default ValueCondition.IsEqual */
  20921. operator: number;
  20922. /**
  20923. * Internal only
  20924. * @hidden
  20925. */
  20926. private static _IsEqual;
  20927. /**
  20928. * Internal only
  20929. * @hidden
  20930. */
  20931. private static _IsDifferent;
  20932. /**
  20933. * Internal only
  20934. * @hidden
  20935. */
  20936. private static _IsGreater;
  20937. /**
  20938. * Internal only
  20939. * @hidden
  20940. */
  20941. private static _IsLesser;
  20942. /**
  20943. * returns the number for IsEqual
  20944. */
  20945. static readonly IsEqual: number;
  20946. /**
  20947. * Returns the number for IsDifferent
  20948. */
  20949. static readonly IsDifferent: number;
  20950. /**
  20951. * Returns the number for IsGreater
  20952. */
  20953. static readonly IsGreater: number;
  20954. /**
  20955. * Returns the number for IsLesser
  20956. */
  20957. static readonly IsLesser: number;
  20958. /**
  20959. * Internal only The action manager for the condition
  20960. * @hidden
  20961. */
  20962. _actionManager: ActionManager;
  20963. /**
  20964. * Internal only
  20965. * @hidden
  20966. */
  20967. private _target;
  20968. /**
  20969. * Internal only
  20970. * @hidden
  20971. */
  20972. private _effectiveTarget;
  20973. /**
  20974. * Internal only
  20975. * @hidden
  20976. */
  20977. private _property;
  20978. /**
  20979. * Creates a new ValueCondition
  20980. * @param actionManager manager for the action the condition applies to
  20981. * @param target for the action
  20982. * @param propertyPath path to specify the property of the target the conditional operator uses
  20983. * @param value the value compared by the conditional operator against the current value of the property
  20984. * @param operator the conditional operator, default ValueCondition.IsEqual
  20985. */
  20986. constructor(actionManager: ActionManager, target: any,
  20987. /** path to specify the property of the target the conditional operator uses */
  20988. propertyPath: string,
  20989. /** the value compared by the conditional operator against the current value of the property */
  20990. value: any,
  20991. /** the conditional operator, default ValueCondition.IsEqual */
  20992. operator?: number);
  20993. /**
  20994. * Compares the given value with the property value for the specified conditional operator
  20995. * @returns the result of the comparison
  20996. */
  20997. isValid(): boolean;
  20998. /**
  20999. * Serialize the ValueCondition into a JSON compatible object
  21000. * @returns serialization object
  21001. */
  21002. serialize(): any;
  21003. /**
  21004. * Gets the name of the conditional operator for the ValueCondition
  21005. * @param operator the conditional operator
  21006. * @returns the name
  21007. */
  21008. static GetOperatorName(operator: number): string;
  21009. }
  21010. /**
  21011. * Defines a predicate condition as an extension of Condition
  21012. */
  21013. export class PredicateCondition extends Condition {
  21014. /** defines the predicate function used to validate the condition */
  21015. predicate: () => boolean;
  21016. /**
  21017. * Internal only - manager for action
  21018. * @hidden
  21019. */
  21020. _actionManager: ActionManager;
  21021. /**
  21022. * Creates a new PredicateCondition
  21023. * @param actionManager manager for the action the condition applies to
  21024. * @param predicate defines the predicate function used to validate the condition
  21025. */
  21026. constructor(actionManager: ActionManager,
  21027. /** defines the predicate function used to validate the condition */
  21028. predicate: () => boolean);
  21029. /**
  21030. * @returns the validity of the predicate condition
  21031. */
  21032. isValid(): boolean;
  21033. }
  21034. /**
  21035. * Defines a state condition as an extension of Condition
  21036. */
  21037. export class StateCondition extends Condition {
  21038. /** Value to compare with target state */
  21039. value: string;
  21040. /**
  21041. * Internal only - manager for action
  21042. * @hidden
  21043. */
  21044. _actionManager: ActionManager;
  21045. /**
  21046. * Internal only
  21047. * @hidden
  21048. */
  21049. private _target;
  21050. /**
  21051. * Creates a new StateCondition
  21052. * @param actionManager manager for the action the condition applies to
  21053. * @param target of the condition
  21054. * @param value to compare with target state
  21055. */
  21056. constructor(actionManager: ActionManager, target: any,
  21057. /** Value to compare with target state */
  21058. value: string);
  21059. /**
  21060. * Gets a boolean indicating if the current condition is met
  21061. * @returns the validity of the state
  21062. */
  21063. isValid(): boolean;
  21064. /**
  21065. * Serialize the StateCondition into a JSON compatible object
  21066. * @returns serialization object
  21067. */
  21068. serialize(): any;
  21069. }
  21070. }
  21071. declare module "babylonjs/Actions/directActions" {
  21072. import { Action } from "babylonjs/Actions/action";
  21073. import { Condition } from "babylonjs/Actions/condition";
  21074. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  21075. /**
  21076. * This defines an action responsible to toggle a boolean once triggered.
  21077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21078. */
  21079. export class SwitchBooleanAction extends Action {
  21080. /**
  21081. * The path to the boolean property in the target object
  21082. */
  21083. propertyPath: string;
  21084. private _target;
  21085. private _effectiveTarget;
  21086. private _property;
  21087. /**
  21088. * Instantiate the action
  21089. * @param triggerOptions defines the trigger options
  21090. * @param target defines the object containing the boolean
  21091. * @param propertyPath defines the path to the boolean property in the target object
  21092. * @param condition defines the trigger related conditions
  21093. */
  21094. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  21095. /** @hidden */
  21096. _prepare(): void;
  21097. /**
  21098. * Execute the action toggle the boolean value.
  21099. */
  21100. execute(): void;
  21101. /**
  21102. * Serializes the actions and its related information.
  21103. * @param parent defines the object to serialize in
  21104. * @returns the serialized object
  21105. */
  21106. serialize(parent: any): any;
  21107. }
  21108. /**
  21109. * This defines an action responsible to set a the state field of the target
  21110. * to a desired value once triggered.
  21111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21112. */
  21113. export class SetStateAction extends Action {
  21114. /**
  21115. * The value to store in the state field.
  21116. */
  21117. value: string;
  21118. private _target;
  21119. /**
  21120. * Instantiate the action
  21121. * @param triggerOptions defines the trigger options
  21122. * @param target defines the object containing the state property
  21123. * @param value defines the value to store in the state field
  21124. * @param condition defines the trigger related conditions
  21125. */
  21126. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  21127. /**
  21128. * Execute the action and store the value on the target state property.
  21129. */
  21130. execute(): void;
  21131. /**
  21132. * Serializes the actions and its related information.
  21133. * @param parent defines the object to serialize in
  21134. * @returns the serialized object
  21135. */
  21136. serialize(parent: any): any;
  21137. }
  21138. /**
  21139. * This defines an action responsible to set a property of the target
  21140. * to a desired value once triggered.
  21141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21142. */
  21143. export class SetValueAction extends Action {
  21144. /**
  21145. * The path of the property to set in the target.
  21146. */
  21147. propertyPath: string;
  21148. /**
  21149. * The value to set in the property
  21150. */
  21151. value: any;
  21152. private _target;
  21153. private _effectiveTarget;
  21154. private _property;
  21155. /**
  21156. * Instantiate the action
  21157. * @param triggerOptions defines the trigger options
  21158. * @param target defines the object containing the property
  21159. * @param propertyPath defines the path of the property to set in the target
  21160. * @param value defines the value to set in the property
  21161. * @param condition defines the trigger related conditions
  21162. */
  21163. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  21164. /** @hidden */
  21165. _prepare(): void;
  21166. /**
  21167. * Execute the action and set the targetted property to the desired value.
  21168. */
  21169. execute(): void;
  21170. /**
  21171. * Serializes the actions and its related information.
  21172. * @param parent defines the object to serialize in
  21173. * @returns the serialized object
  21174. */
  21175. serialize(parent: any): any;
  21176. }
  21177. /**
  21178. * This defines an action responsible to increment the target value
  21179. * to a desired value once triggered.
  21180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21181. */
  21182. export class IncrementValueAction extends Action {
  21183. /**
  21184. * The path of the property to increment in the target.
  21185. */
  21186. propertyPath: string;
  21187. /**
  21188. * The value we should increment the property by.
  21189. */
  21190. value: any;
  21191. private _target;
  21192. private _effectiveTarget;
  21193. private _property;
  21194. /**
  21195. * Instantiate the action
  21196. * @param triggerOptions defines the trigger options
  21197. * @param target defines the object containing the property
  21198. * @param propertyPath defines the path of the property to increment in the target
  21199. * @param value defines the value value we should increment the property by
  21200. * @param condition defines the trigger related conditions
  21201. */
  21202. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  21203. /** @hidden */
  21204. _prepare(): void;
  21205. /**
  21206. * Execute the action and increment the target of the value amount.
  21207. */
  21208. execute(): void;
  21209. /**
  21210. * Serializes the actions and its related information.
  21211. * @param parent defines the object to serialize in
  21212. * @returns the serialized object
  21213. */
  21214. serialize(parent: any): any;
  21215. }
  21216. /**
  21217. * This defines an action responsible to start an animation once triggered.
  21218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21219. */
  21220. export class PlayAnimationAction extends Action {
  21221. /**
  21222. * Where the animation should start (animation frame)
  21223. */
  21224. from: number;
  21225. /**
  21226. * Where the animation should stop (animation frame)
  21227. */
  21228. to: number;
  21229. /**
  21230. * Define if the animation should loop or stop after the first play.
  21231. */
  21232. loop?: boolean;
  21233. private _target;
  21234. /**
  21235. * Instantiate the action
  21236. * @param triggerOptions defines the trigger options
  21237. * @param target defines the target animation or animation name
  21238. * @param from defines from where the animation should start (animation frame)
  21239. * @param end defines where the animation should stop (animation frame)
  21240. * @param loop defines if the animation should loop or stop after the first play
  21241. * @param condition defines the trigger related conditions
  21242. */
  21243. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  21244. /** @hidden */
  21245. _prepare(): void;
  21246. /**
  21247. * Execute the action and play the animation.
  21248. */
  21249. execute(): void;
  21250. /**
  21251. * Serializes the actions and its related information.
  21252. * @param parent defines the object to serialize in
  21253. * @returns the serialized object
  21254. */
  21255. serialize(parent: any): any;
  21256. }
  21257. /**
  21258. * This defines an action responsible to stop an animation once triggered.
  21259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21260. */
  21261. export class StopAnimationAction extends Action {
  21262. private _target;
  21263. /**
  21264. * Instantiate the action
  21265. * @param triggerOptions defines the trigger options
  21266. * @param target defines the target animation or animation name
  21267. * @param condition defines the trigger related conditions
  21268. */
  21269. constructor(triggerOptions: any, target: any, condition?: Condition);
  21270. /** @hidden */
  21271. _prepare(): void;
  21272. /**
  21273. * Execute the action and stop the animation.
  21274. */
  21275. execute(): void;
  21276. /**
  21277. * Serializes the actions and its related information.
  21278. * @param parent defines the object to serialize in
  21279. * @returns the serialized object
  21280. */
  21281. serialize(parent: any): any;
  21282. }
  21283. /**
  21284. * This defines an action responsible that does nothing once triggered.
  21285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21286. */
  21287. export class DoNothingAction extends Action {
  21288. /**
  21289. * Instantiate the action
  21290. * @param triggerOptions defines the trigger options
  21291. * @param condition defines the trigger related conditions
  21292. */
  21293. constructor(triggerOptions?: any, condition?: Condition);
  21294. /**
  21295. * Execute the action and do nothing.
  21296. */
  21297. execute(): void;
  21298. /**
  21299. * Serializes the actions and its related information.
  21300. * @param parent defines the object to serialize in
  21301. * @returns the serialized object
  21302. */
  21303. serialize(parent: any): any;
  21304. }
  21305. /**
  21306. * This defines an action responsible to trigger several actions once triggered.
  21307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21308. */
  21309. export class CombineAction extends Action {
  21310. /**
  21311. * The list of aggregated animations to run.
  21312. */
  21313. children: Action[];
  21314. /**
  21315. * Instantiate the action
  21316. * @param triggerOptions defines the trigger options
  21317. * @param children defines the list of aggregated animations to run
  21318. * @param condition defines the trigger related conditions
  21319. */
  21320. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  21321. /** @hidden */
  21322. _prepare(): void;
  21323. /**
  21324. * Execute the action and executes all the aggregated actions.
  21325. */
  21326. execute(evt: ActionEvent): void;
  21327. /**
  21328. * Serializes the actions and its related information.
  21329. * @param parent defines the object to serialize in
  21330. * @returns the serialized object
  21331. */
  21332. serialize(parent: any): any;
  21333. }
  21334. /**
  21335. * This defines an action responsible to run code (external event) once triggered.
  21336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21337. */
  21338. export class ExecuteCodeAction extends Action {
  21339. /**
  21340. * The callback function to run.
  21341. */
  21342. func: (evt: ActionEvent) => void;
  21343. /**
  21344. * Instantiate the action
  21345. * @param triggerOptions defines the trigger options
  21346. * @param func defines the callback function to run
  21347. * @param condition defines the trigger related conditions
  21348. */
  21349. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  21350. /**
  21351. * Execute the action and run the attached code.
  21352. */
  21353. execute(evt: ActionEvent): void;
  21354. }
  21355. /**
  21356. * This defines an action responsible to set the parent property of the target once triggered.
  21357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21358. */
  21359. export class SetParentAction extends Action {
  21360. private _parent;
  21361. private _target;
  21362. /**
  21363. * Instantiate the action
  21364. * @param triggerOptions defines the trigger options
  21365. * @param target defines the target containing the parent property
  21366. * @param parent defines from where the animation should start (animation frame)
  21367. * @param condition defines the trigger related conditions
  21368. */
  21369. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  21370. /** @hidden */
  21371. _prepare(): void;
  21372. /**
  21373. * Execute the action and set the parent property.
  21374. */
  21375. execute(): void;
  21376. /**
  21377. * Serializes the actions and its related information.
  21378. * @param parent defines the object to serialize in
  21379. * @returns the serialized object
  21380. */
  21381. serialize(parent: any): any;
  21382. }
  21383. }
  21384. declare module "babylonjs/Actions/actionManager" {
  21385. import { Nullable } from "babylonjs/types";
  21386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21387. import { Scene } from "babylonjs/scene";
  21388. import { Action } from "babylonjs/Actions/action";
  21389. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  21390. /**
  21391. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  21392. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  21393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21394. */
  21395. export class ActionManager {
  21396. /**
  21397. * Nothing
  21398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21399. */
  21400. static readonly NothingTrigger: number;
  21401. /**
  21402. * On pick
  21403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21404. */
  21405. static readonly OnPickTrigger: number;
  21406. /**
  21407. * On left pick
  21408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21409. */
  21410. static readonly OnLeftPickTrigger: number;
  21411. /**
  21412. * On right pick
  21413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21414. */
  21415. static readonly OnRightPickTrigger: number;
  21416. /**
  21417. * On center pick
  21418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21419. */
  21420. static readonly OnCenterPickTrigger: number;
  21421. /**
  21422. * On pick down
  21423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21424. */
  21425. static readonly OnPickDownTrigger: number;
  21426. /**
  21427. * On double pick
  21428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21429. */
  21430. static readonly OnDoublePickTrigger: number;
  21431. /**
  21432. * On pick up
  21433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21434. */
  21435. static readonly OnPickUpTrigger: number;
  21436. /**
  21437. * On pick out.
  21438. * This trigger will only be raised if you also declared a OnPickDown
  21439. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21440. */
  21441. static readonly OnPickOutTrigger: number;
  21442. /**
  21443. * On long press
  21444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21445. */
  21446. static readonly OnLongPressTrigger: number;
  21447. /**
  21448. * On pointer over
  21449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21450. */
  21451. static readonly OnPointerOverTrigger: number;
  21452. /**
  21453. * On pointer out
  21454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21455. */
  21456. static readonly OnPointerOutTrigger: number;
  21457. /**
  21458. * On every frame
  21459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21460. */
  21461. static readonly OnEveryFrameTrigger: number;
  21462. /**
  21463. * On intersection enter
  21464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21465. */
  21466. static readonly OnIntersectionEnterTrigger: number;
  21467. /**
  21468. * On intersection exit
  21469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21470. */
  21471. static readonly OnIntersectionExitTrigger: number;
  21472. /**
  21473. * On key down
  21474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21475. */
  21476. static readonly OnKeyDownTrigger: number;
  21477. /**
  21478. * On key up
  21479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21480. */
  21481. static readonly OnKeyUpTrigger: number;
  21482. /** Gets the list of active triggers */
  21483. static Triggers: {
  21484. [key: string]: number;
  21485. };
  21486. /** Gets the list of actions */
  21487. actions: Action[];
  21488. /** Gets the cursor to use when hovering items */
  21489. hoverCursor: string;
  21490. private _scene;
  21491. /**
  21492. * Creates a new action manager
  21493. * @param scene defines the hosting scene
  21494. */
  21495. constructor(scene: Scene);
  21496. /**
  21497. * Releases all associated resources
  21498. */
  21499. dispose(): void;
  21500. /**
  21501. * Gets hosting scene
  21502. * @returns the hosting scene
  21503. */
  21504. getScene(): Scene;
  21505. /**
  21506. * Does this action manager handles actions of any of the given triggers
  21507. * @param triggers defines the triggers to be tested
  21508. * @return a boolean indicating whether one (or more) of the triggers is handled
  21509. */
  21510. hasSpecificTriggers(triggers: number[]): boolean;
  21511. /**
  21512. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  21513. * speed.
  21514. * @param triggerA defines the trigger to be tested
  21515. * @param triggerB defines the trigger to be tested
  21516. * @return a boolean indicating whether one (or more) of the triggers is handled
  21517. */
  21518. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  21519. /**
  21520. * Does this action manager handles actions of a given trigger
  21521. * @param trigger defines the trigger to be tested
  21522. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  21523. * @return whether the trigger is handled
  21524. */
  21525. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  21526. /**
  21527. * Does this action manager has pointer triggers
  21528. */
  21529. readonly hasPointerTriggers: boolean;
  21530. /**
  21531. * Does this action manager has pick triggers
  21532. */
  21533. readonly hasPickTriggers: boolean;
  21534. /**
  21535. * Does exist one action manager with at least one trigger
  21536. **/
  21537. static readonly HasTriggers: boolean;
  21538. /**
  21539. * Does exist one action manager with at least one pick trigger
  21540. **/
  21541. static readonly HasPickTriggers: boolean;
  21542. /**
  21543. * Does exist one action manager that handles actions of a given trigger
  21544. * @param trigger defines the trigger to be tested
  21545. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  21546. **/
  21547. static HasSpecificTrigger(trigger: number): boolean;
  21548. /**
  21549. * Registers an action to this action manager
  21550. * @param action defines the action to be registered
  21551. * @return the action amended (prepared) after registration
  21552. */
  21553. registerAction(action: Action): Nullable<Action>;
  21554. /**
  21555. * Unregisters an action to this action manager
  21556. * @param action defines the action to be unregistered
  21557. * @return a boolean indicating whether the action has been unregistered
  21558. */
  21559. unregisterAction(action: Action): Boolean;
  21560. /**
  21561. * Process a specific trigger
  21562. * @param trigger defines the trigger to process
  21563. * @param evt defines the event details to be processed
  21564. */
  21565. processTrigger(trigger: number, evt?: ActionEvent): void;
  21566. /** @hidden */
  21567. _getEffectiveTarget(target: any, propertyPath: string): any;
  21568. /** @hidden */
  21569. _getProperty(propertyPath: string): string;
  21570. /**
  21571. * Serialize this manager to a JSON object
  21572. * @param name defines the property name to store this manager
  21573. * @returns a JSON representation of this manager
  21574. */
  21575. serialize(name: string): any;
  21576. /**
  21577. * Creates a new ActionManager from a JSON data
  21578. * @param parsedActions defines the JSON data to read from
  21579. * @param object defines the hosting mesh
  21580. * @param scene defines the hosting scene
  21581. */
  21582. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  21583. /**
  21584. * Get a trigger name by index
  21585. * @param trigger defines the trigger index
  21586. * @returns a trigger name
  21587. */
  21588. static GetTriggerName(trigger: number): string;
  21589. }
  21590. }
  21591. declare module "babylonjs/Sprites/sprite" {
  21592. import { Vector3, Color4 } from "babylonjs/Maths/math";
  21593. import { Nullable } from "babylonjs/types";
  21594. import { ActionManager } from "babylonjs/Actions/actionManager";
  21595. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  21596. /**
  21597. * Class used to represent a sprite
  21598. * @see http://doc.babylonjs.com/babylon101/sprites
  21599. */
  21600. export class Sprite {
  21601. /** defines the name */
  21602. name: string;
  21603. /** Gets or sets the current world position */
  21604. position: Vector3;
  21605. /** Gets or sets the main color */
  21606. color: Color4;
  21607. /** Gets or sets the width */
  21608. width: number;
  21609. /** Gets or sets the height */
  21610. height: number;
  21611. /** Gets or sets rotation angle */
  21612. angle: number;
  21613. /** Gets or sets the cell index in the sprite sheet */
  21614. cellIndex: number;
  21615. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  21616. invertU: number;
  21617. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  21618. invertV: number;
  21619. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  21620. disposeWhenFinishedAnimating: boolean;
  21621. /** Gets the list of attached animations */
  21622. animations: Animation[];
  21623. /** Gets or sets a boolean indicating if the sprite can be picked */
  21624. isPickable: boolean;
  21625. /**
  21626. * Gets or sets the associated action manager
  21627. */
  21628. actionManager: Nullable<ActionManager>;
  21629. private _animationStarted;
  21630. private _loopAnimation;
  21631. private _fromIndex;
  21632. private _toIndex;
  21633. private _delay;
  21634. private _direction;
  21635. private _manager;
  21636. private _time;
  21637. private _onAnimationEnd;
  21638. /**
  21639. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  21640. */
  21641. isVisible: boolean;
  21642. /**
  21643. * Gets or sets the sprite size
  21644. */
  21645. size: number;
  21646. /**
  21647. * Creates a new Sprite
  21648. * @param name defines the name
  21649. * @param manager defines the manager
  21650. */
  21651. constructor(
  21652. /** defines the name */
  21653. name: string, manager: ISpriteManager);
  21654. /**
  21655. * Starts an animation
  21656. * @param from defines the initial key
  21657. * @param to defines the end key
  21658. * @param loop defines if the animation must loop
  21659. * @param delay defines the start delay (in ms)
  21660. * @param onAnimationEnd defines a callback to call when animation ends
  21661. */
  21662. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  21663. /** Stops current animation (if any) */
  21664. stopAnimation(): void;
  21665. /** @hidden */
  21666. _animate(deltaTime: number): void;
  21667. /** Release associated resources */
  21668. dispose(): void;
  21669. }
  21670. }
  21671. declare module "babylonjs/Collisions/pickingInfo" {
  21672. import { Nullable } from "babylonjs/types";
  21673. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  21674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21675. import { Ray } from "babylonjs/Culling/ray";
  21676. import { Sprite } from "babylonjs/Sprites/sprite";
  21677. /**
  21678. * Information about the result of picking within a scene
  21679. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  21680. */
  21681. export class PickingInfo {
  21682. /**
  21683. * If the pick collided with an object
  21684. */
  21685. hit: boolean;
  21686. /**
  21687. * Distance away where the pick collided
  21688. */
  21689. distance: number;
  21690. /**
  21691. * The location of pick collision
  21692. */
  21693. pickedPoint: Nullable<Vector3>;
  21694. /**
  21695. * The mesh corresponding the the pick collision
  21696. */
  21697. pickedMesh: Nullable<AbstractMesh>;
  21698. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  21699. bu: number;
  21700. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  21701. bv: number;
  21702. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  21703. faceId: number;
  21704. /** Id of the the submesh that was picked */
  21705. subMeshId: number;
  21706. /** If a sprite was picked, this will be the sprite the pick collided with */
  21707. pickedSprite: Nullable<Sprite>;
  21708. /**
  21709. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  21710. */
  21711. originMesh: Nullable<AbstractMesh>;
  21712. /**
  21713. * The ray that was used to perform the picking.
  21714. */
  21715. ray: Nullable<Ray>;
  21716. /**
  21717. * Gets the normal correspodning to the face the pick collided with
  21718. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  21719. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  21720. * @returns The normal correspodning to the face the pick collided with
  21721. */
  21722. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  21723. /**
  21724. * Gets the texture coordinates of where the pick occured
  21725. * @returns the vector containing the coordnates of the texture
  21726. */
  21727. getTextureCoordinates(): Nullable<Vector2>;
  21728. }
  21729. }
  21730. declare module "babylonjs/Culling/ray" {
  21731. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  21732. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21734. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  21735. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21736. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  21737. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21738. /**
  21739. * Class representing a ray with position and direction
  21740. */
  21741. export class Ray {
  21742. /** origin point */
  21743. origin: Vector3;
  21744. /** direction */
  21745. direction: Vector3;
  21746. /** length of the ray */
  21747. length: number;
  21748. private static readonly TmpVector3;
  21749. private _tmpRay;
  21750. /**
  21751. * Creates a new ray
  21752. * @param origin origin point
  21753. * @param direction direction
  21754. * @param length length of the ray
  21755. */
  21756. constructor(
  21757. /** origin point */
  21758. origin: Vector3,
  21759. /** direction */
  21760. direction: Vector3,
  21761. /** length of the ray */
  21762. length?: number);
  21763. /**
  21764. * Checks if the ray intersects a box
  21765. * @param minimum bound of the box
  21766. * @param maximum bound of the box
  21767. * @param intersectionTreshold extra extend to be added to the box in all direction
  21768. * @returns if the box was hit
  21769. */
  21770. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  21771. /**
  21772. * Checks if the ray intersects a box
  21773. * @param box the bounding box to check
  21774. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  21775. * @returns if the box was hit
  21776. */
  21777. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  21778. /**
  21779. * If the ray hits a sphere
  21780. * @param sphere the bounding sphere to check
  21781. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  21782. * @returns true if it hits the sphere
  21783. */
  21784. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  21785. /**
  21786. * If the ray hits a triange
  21787. * @param vertex0 triangle vertex
  21788. * @param vertex1 triangle vertex
  21789. * @param vertex2 triangle vertex
  21790. * @returns intersection information if hit
  21791. */
  21792. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  21793. /**
  21794. * Checks if ray intersects a plane
  21795. * @param plane the plane to check
  21796. * @returns the distance away it was hit
  21797. */
  21798. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  21799. /**
  21800. * Checks if ray intersects a mesh
  21801. * @param mesh the mesh to check
  21802. * @param fastCheck if only the bounding box should checked
  21803. * @returns picking info of the intersecton
  21804. */
  21805. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  21806. /**
  21807. * Checks if ray intersects a mesh
  21808. * @param meshes the meshes to check
  21809. * @param fastCheck if only the bounding box should checked
  21810. * @param results array to store result in
  21811. * @returns Array of picking infos
  21812. */
  21813. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  21814. private _comparePickingInfo;
  21815. private static smallnum;
  21816. private static rayl;
  21817. /**
  21818. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  21819. * @param sega the first point of the segment to test the intersection against
  21820. * @param segb the second point of the segment to test the intersection against
  21821. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  21822. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  21823. */
  21824. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  21825. /**
  21826. * Update the ray from viewport position
  21827. * @param x position
  21828. * @param y y position
  21829. * @param viewportWidth viewport width
  21830. * @param viewportHeight viewport height
  21831. * @param world world matrix
  21832. * @param view view matrix
  21833. * @param projection projection matrix
  21834. * @returns this ray updated
  21835. */
  21836. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21837. /**
  21838. * Creates a ray with origin and direction of 0,0,0
  21839. * @returns the new ray
  21840. */
  21841. static Zero(): Ray;
  21842. /**
  21843. * Creates a new ray from screen space and viewport
  21844. * @param x position
  21845. * @param y y position
  21846. * @param viewportWidth viewport width
  21847. * @param viewportHeight viewport height
  21848. * @param world world matrix
  21849. * @param view view matrix
  21850. * @param projection projection matrix
  21851. * @returns new ray
  21852. */
  21853. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21854. /**
  21855. * 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
  21856. * transformed to the given world matrix.
  21857. * @param origin The origin point
  21858. * @param end The end point
  21859. * @param world a matrix to transform the ray to. Default is the identity matrix.
  21860. * @returns the new ray
  21861. */
  21862. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  21863. /**
  21864. * Transforms a ray by a matrix
  21865. * @param ray ray to transform
  21866. * @param matrix matrix to apply
  21867. * @returns the resulting new ray
  21868. */
  21869. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  21870. /**
  21871. * Transforms a ray by a matrix
  21872. * @param ray ray to transform
  21873. * @param matrix matrix to apply
  21874. * @param result ray to store result in
  21875. */
  21876. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  21877. /**
  21878. * Unproject a ray from screen space to object space
  21879. * @param sourceX defines the screen space x coordinate to use
  21880. * @param sourceY defines the screen space y coordinate to use
  21881. * @param viewportWidth defines the current width of the viewport
  21882. * @param viewportHeight defines the current height of the viewport
  21883. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21884. * @param view defines the view matrix to use
  21885. * @param projection defines the projection matrix to use
  21886. */
  21887. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  21888. }
  21889. }
  21890. declare module "babylonjs/Materials/multiMaterial" {
  21891. import { Nullable } from "babylonjs/types";
  21892. import { Scene } from "babylonjs/scene";
  21893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21894. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21895. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21896. import { Material } from "babylonjs/Materials/material";
  21897. /**
  21898. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21899. * separate meshes. This can be use to improve performances.
  21900. * @see http://doc.babylonjs.com/how_to/multi_materials
  21901. */
  21902. export class MultiMaterial extends Material {
  21903. private _subMaterials;
  21904. /**
  21905. * Gets or Sets the list of Materials used within the multi material.
  21906. * They need to be ordered according to the submeshes order in the associated mesh
  21907. */
  21908. subMaterials: Nullable<Material>[];
  21909. /**
  21910. * Function used to align with Node.getChildren()
  21911. * @returns the list of Materials used within the multi material
  21912. */
  21913. getChildren(): Nullable<Material>[];
  21914. /**
  21915. * Instantiates a new Multi Material
  21916. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21917. * separate meshes. This can be use to improve performances.
  21918. * @see http://doc.babylonjs.com/how_to/multi_materials
  21919. * @param name Define the name in the scene
  21920. * @param scene Define the scene the material belongs to
  21921. */
  21922. constructor(name: string, scene: Scene);
  21923. private _hookArray;
  21924. /**
  21925. * Get one of the submaterial by its index in the submaterials array
  21926. * @param index The index to look the sub material at
  21927. * @returns The Material if the index has been defined
  21928. */
  21929. getSubMaterial(index: number): Nullable<Material>;
  21930. /**
  21931. * Get the list of active textures for the whole sub materials list.
  21932. * @returns All the textures that will be used during the rendering
  21933. */
  21934. getActiveTextures(): BaseTexture[];
  21935. /**
  21936. * Gets the current class name of the material e.g. "MultiMaterial"
  21937. * Mainly use in serialization.
  21938. * @returns the class name
  21939. */
  21940. getClassName(): string;
  21941. /**
  21942. * Checks if the material is ready to render the requested sub mesh
  21943. * @param mesh Define the mesh the submesh belongs to
  21944. * @param subMesh Define the sub mesh to look readyness for
  21945. * @param useInstances Define whether or not the material is used with instances
  21946. * @returns true if ready, otherwise false
  21947. */
  21948. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21949. /**
  21950. * Clones the current material and its related sub materials
  21951. * @param name Define the name of the newly cloned material
  21952. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21953. * @returns the cloned material
  21954. */
  21955. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21956. /**
  21957. * Serializes the materials into a JSON representation.
  21958. * @returns the JSON representation
  21959. */
  21960. serialize(): any;
  21961. /**
  21962. * Dispose the material and release its associated resources
  21963. * @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)
  21964. * @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)
  21965. */
  21966. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  21967. /**
  21968. * Creates a MultiMaterial from parsed MultiMaterial data.
  21969. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21970. * @param scene defines the hosting scene
  21971. * @returns a new MultiMaterial
  21972. */
  21973. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21974. }
  21975. }
  21976. declare module "babylonjs/Meshes/subMesh" {
  21977. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  21978. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21979. import { Engine } from "babylonjs/Engines/engine";
  21980. import { Collider } from "babylonjs/Collisions/collider";
  21981. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21982. import { Ray } from "babylonjs/Culling/ray";
  21983. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21984. import { Effect } from "babylonjs/Materials/effect";
  21985. import { Material } from "babylonjs/Materials/material";
  21986. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21988. import { Mesh } from "babylonjs/Meshes/mesh";
  21989. /**
  21990. * Base class for submeshes
  21991. */
  21992. export class BaseSubMesh {
  21993. /** @hidden */
  21994. _materialDefines: Nullable<MaterialDefines>;
  21995. /** @hidden */
  21996. _materialEffect: Nullable<Effect>;
  21997. /**
  21998. * Gets associated effect
  21999. */
  22000. readonly effect: Nullable<Effect>;
  22001. /**
  22002. * Sets associated effect (effect used to render this submesh)
  22003. * @param effect defines the effect to associate with
  22004. * @param defines defines the set of defines used to compile this effect
  22005. */
  22006. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22007. }
  22008. /**
  22009. * Defines a subdivision inside a mesh
  22010. */
  22011. export class SubMesh extends BaseSubMesh implements ICullable {
  22012. /** the material index to use */
  22013. materialIndex: number;
  22014. /** vertex index start */
  22015. verticesStart: number;
  22016. /** vertices count */
  22017. verticesCount: number;
  22018. /** index start */
  22019. indexStart: number;
  22020. /** indices count */
  22021. indexCount: number;
  22022. /** @hidden */
  22023. _linesIndexCount: number;
  22024. private _mesh;
  22025. private _renderingMesh;
  22026. private _boundingInfo;
  22027. private _linesIndexBuffer;
  22028. /** @hidden */
  22029. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22030. /** @hidden */
  22031. _trianglePlanes: Plane[];
  22032. /** @hidden */
  22033. _lastColliderTransformMatrix: Matrix;
  22034. /** @hidden */
  22035. _renderId: number;
  22036. /** @hidden */
  22037. _alphaIndex: number;
  22038. /** @hidden */
  22039. _distanceToCamera: number;
  22040. /** @hidden */
  22041. _id: number;
  22042. private _currentMaterial;
  22043. /**
  22044. * Add a new submesh to a mesh
  22045. * @param materialIndex defines the material index to use
  22046. * @param verticesStart defines vertex index start
  22047. * @param verticesCount defines vertices count
  22048. * @param indexStart defines index start
  22049. * @param indexCount defines indices count
  22050. * @param mesh defines the parent mesh
  22051. * @param renderingMesh defines an optional rendering mesh
  22052. * @param createBoundingBox defines if bounding box should be created for this submesh
  22053. * @returns the new submesh
  22054. */
  22055. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22056. /**
  22057. * Creates a new submesh
  22058. * @param materialIndex defines the material index to use
  22059. * @param verticesStart defines vertex index start
  22060. * @param verticesCount defines vertices count
  22061. * @param indexStart defines index start
  22062. * @param indexCount defines indices count
  22063. * @param mesh defines the parent mesh
  22064. * @param renderingMesh defines an optional rendering mesh
  22065. * @param createBoundingBox defines if bounding box should be created for this submesh
  22066. */
  22067. constructor(
  22068. /** the material index to use */
  22069. materialIndex: number,
  22070. /** vertex index start */
  22071. verticesStart: number,
  22072. /** vertices count */
  22073. verticesCount: number,
  22074. /** index start */
  22075. indexStart: number,
  22076. /** indices count */
  22077. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22078. /**
  22079. * Returns true if this submesh covers the entire parent mesh
  22080. * @ignorenaming
  22081. */
  22082. readonly IsGlobal: boolean;
  22083. /**
  22084. * Returns the submesh BoudingInfo object
  22085. * @returns current bounding info (or mesh's one if the submesh is global)
  22086. */
  22087. getBoundingInfo(): BoundingInfo;
  22088. /**
  22089. * Sets the submesh BoundingInfo
  22090. * @param boundingInfo defines the new bounding info to use
  22091. * @returns the SubMesh
  22092. */
  22093. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22094. /**
  22095. * Returns the mesh of the current submesh
  22096. * @return the parent mesh
  22097. */
  22098. getMesh(): AbstractMesh;
  22099. /**
  22100. * Returns the rendering mesh of the submesh
  22101. * @returns the rendering mesh (could be different from parent mesh)
  22102. */
  22103. getRenderingMesh(): Mesh;
  22104. /**
  22105. * Returns the submesh material
  22106. * @returns null or the current material
  22107. */
  22108. getMaterial(): Nullable<Material>;
  22109. /**
  22110. * Sets a new updated BoundingInfo object to the submesh
  22111. * @returns the SubMesh
  22112. */
  22113. refreshBoundingInfo(): SubMesh;
  22114. /** @hidden */
  22115. _checkCollision(collider: Collider): boolean;
  22116. /**
  22117. * Updates the submesh BoundingInfo
  22118. * @param world defines the world matrix to use to update the bounding info
  22119. * @returns the submesh
  22120. */
  22121. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22122. /**
  22123. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22124. * @param frustumPlanes defines the frustum planes
  22125. * @returns true if the submesh is intersecting with the frustum
  22126. */
  22127. isInFrustum(frustumPlanes: Plane[]): boolean;
  22128. /**
  22129. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22130. * @param frustumPlanes defines the frustum planes
  22131. * @returns true if the submesh is inside the frustum
  22132. */
  22133. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22134. /**
  22135. * Renders the submesh
  22136. * @param enableAlphaMode defines if alpha needs to be used
  22137. * @returns the submesh
  22138. */
  22139. render(enableAlphaMode: boolean): SubMesh;
  22140. /**
  22141. * @hidden
  22142. */
  22143. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22144. /**
  22145. * Checks if the submesh intersects with a ray
  22146. * @param ray defines the ray to test
  22147. * @returns true is the passed ray intersects the submesh bounding box
  22148. */
  22149. canIntersects(ray: Ray): boolean;
  22150. /**
  22151. * Intersects current submesh with a ray
  22152. * @param ray defines the ray to test
  22153. * @param positions defines mesh's positions array
  22154. * @param indices defines mesh's indices array
  22155. * @param fastCheck defines if only bounding info should be used
  22156. * @returns intersection info or null if no intersection
  22157. */
  22158. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22159. /** @hidden */
  22160. private _intersectLines;
  22161. /** @hidden */
  22162. private _intersectTriangles;
  22163. /** @hidden */
  22164. _rebuild(): void;
  22165. /**
  22166. * Creates a new submesh from the passed mesh
  22167. * @param newMesh defines the new hosting mesh
  22168. * @param newRenderingMesh defines an optional rendering mesh
  22169. * @returns the new submesh
  22170. */
  22171. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22172. /**
  22173. * Release associated resources
  22174. */
  22175. dispose(): void;
  22176. /**
  22177. * Gets the class name
  22178. * @returns the string "SubMesh".
  22179. */
  22180. getClassName(): string;
  22181. /**
  22182. * Creates a new submesh from indices data
  22183. * @param materialIndex the index of the main mesh material
  22184. * @param startIndex the index where to start the copy in the mesh indices array
  22185. * @param indexCount the number of indices to copy then from the startIndex
  22186. * @param mesh the main mesh to create the submesh from
  22187. * @param renderingMesh the optional rendering mesh
  22188. * @returns a new submesh
  22189. */
  22190. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22191. }
  22192. }
  22193. declare module "babylonjs/Meshes/geometry" {
  22194. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22195. import { Scene } from "babylonjs/scene";
  22196. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22197. import { Engine } from "babylonjs/Engines/engine";
  22198. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22199. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22200. import { Effect } from "babylonjs/Materials/effect";
  22201. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22202. import { Mesh } from "babylonjs/Meshes/mesh";
  22203. /**
  22204. * Class used to store geometry data (vertex buffers + index buffer)
  22205. */
  22206. export class Geometry implements IGetSetVerticesData {
  22207. /**
  22208. * Gets or sets the ID of the geometry
  22209. */
  22210. id: string;
  22211. /**
  22212. * Gets or sets the unique ID of the geometry
  22213. */
  22214. uniqueId: number;
  22215. /**
  22216. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22217. */
  22218. delayLoadState: number;
  22219. /**
  22220. * Gets the file containing the data to load when running in delay load state
  22221. */
  22222. delayLoadingFile: Nullable<string>;
  22223. /**
  22224. * Callback called when the geometry is updated
  22225. */
  22226. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22227. private _scene;
  22228. private _engine;
  22229. private _meshes;
  22230. private _totalVertices;
  22231. /** @hidden */
  22232. _indices: IndicesArray;
  22233. /** @hidden */
  22234. _vertexBuffers: {
  22235. [key: string]: VertexBuffer;
  22236. };
  22237. private _isDisposed;
  22238. private _extend;
  22239. private _boundingBias;
  22240. /** @hidden */
  22241. _delayInfo: Array<string>;
  22242. private _indexBuffer;
  22243. private _indexBufferIsUpdatable;
  22244. /** @hidden */
  22245. _boundingInfo: Nullable<BoundingInfo>;
  22246. /** @hidden */
  22247. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22248. /** @hidden */
  22249. _softwareSkinningFrameId: number;
  22250. private _vertexArrayObjects;
  22251. private _updatable;
  22252. /** @hidden */
  22253. _positions: Nullable<Vector3[]>;
  22254. /**
  22255. * 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
  22256. */
  22257. /**
  22258. * 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
  22259. */
  22260. boundingBias: Vector2;
  22261. /**
  22262. * Static function used to attach a new empty geometry to a mesh
  22263. * @param mesh defines the mesh to attach the geometry to
  22264. * @returns the new Geometry
  22265. */
  22266. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22267. /**
  22268. * Creates a new geometry
  22269. * @param id defines the unique ID
  22270. * @param scene defines the hosting scene
  22271. * @param vertexData defines the VertexData used to get geometry data
  22272. * @param updatable defines if geometry must be updatable (false by default)
  22273. * @param mesh defines the mesh that will be associated with the geometry
  22274. */
  22275. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22276. /**
  22277. * Gets the current extend of the geometry
  22278. */
  22279. readonly extend: {
  22280. minimum: Vector3;
  22281. maximum: Vector3;
  22282. };
  22283. /**
  22284. * Gets the hosting scene
  22285. * @returns the hosting Scene
  22286. */
  22287. getScene(): Scene;
  22288. /**
  22289. * Gets the hosting engine
  22290. * @returns the hosting Engine
  22291. */
  22292. getEngine(): Engine;
  22293. /**
  22294. * Defines if the geometry is ready to use
  22295. * @returns true if the geometry is ready to be used
  22296. */
  22297. isReady(): boolean;
  22298. /**
  22299. * Gets a value indicating that the geometry should not be serialized
  22300. */
  22301. readonly doNotSerialize: boolean;
  22302. /** @hidden */
  22303. _rebuild(): void;
  22304. /**
  22305. * Affects all geometry data in one call
  22306. * @param vertexData defines the geometry data
  22307. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22308. */
  22309. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22310. /**
  22311. * Set specific vertex data
  22312. * @param kind defines the data kind (Position, normal, etc...)
  22313. * @param data defines the vertex data to use
  22314. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22315. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22316. */
  22317. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22318. /**
  22319. * Removes a specific vertex data
  22320. * @param kind defines the data kind (Position, normal, etc...)
  22321. */
  22322. removeVerticesData(kind: string): void;
  22323. /**
  22324. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22325. * @param buffer defines the vertex buffer to use
  22326. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22327. */
  22328. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22329. /**
  22330. * Update a specific vertex buffer
  22331. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22332. * It will do nothing if the buffer is not updatable
  22333. * @param kind defines the data kind (Position, normal, etc...)
  22334. * @param data defines the data to use
  22335. * @param offset defines the offset in the target buffer where to store the data
  22336. * @param useBytes set to true if the offset is in bytes
  22337. */
  22338. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22339. /**
  22340. * Update a specific vertex buffer
  22341. * This function will create a new buffer if the current one is not updatable
  22342. * @param kind defines the data kind (Position, normal, etc...)
  22343. * @param data defines the data to use
  22344. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22345. */
  22346. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22347. private _updateBoundingInfo;
  22348. /** @hidden */
  22349. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22350. /**
  22351. * Gets total number of vertices
  22352. * @returns the total number of vertices
  22353. */
  22354. getTotalVertices(): number;
  22355. /**
  22356. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22357. * @param kind defines the data kind (Position, normal, etc...)
  22358. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22359. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22360. * @returns a float array containing vertex data
  22361. */
  22362. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22363. /**
  22364. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22365. * @param kind defines the data kind (Position, normal, etc...)
  22366. * @returns true if the vertex buffer with the specified kind is updatable
  22367. */
  22368. isVertexBufferUpdatable(kind: string): boolean;
  22369. /**
  22370. * Gets a specific vertex buffer
  22371. * @param kind defines the data kind (Position, normal, etc...)
  22372. * @returns a VertexBuffer
  22373. */
  22374. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22375. /**
  22376. * Returns all vertex buffers
  22377. * @return an object holding all vertex buffers indexed by kind
  22378. */
  22379. getVertexBuffers(): Nullable<{
  22380. [key: string]: VertexBuffer;
  22381. }>;
  22382. /**
  22383. * Gets a boolean indicating if specific vertex buffer is present
  22384. * @param kind defines the data kind (Position, normal, etc...)
  22385. * @returns true if data is present
  22386. */
  22387. isVerticesDataPresent(kind: string): boolean;
  22388. /**
  22389. * Gets a list of all attached data kinds (Position, normal, etc...)
  22390. * @returns a list of string containing all kinds
  22391. */
  22392. getVerticesDataKinds(): string[];
  22393. /**
  22394. * Update index buffer
  22395. * @param indices defines the indices to store in the index buffer
  22396. * @param offset defines the offset in the target buffer where to store the data
  22397. */
  22398. updateIndices(indices: IndicesArray, offset?: number): void;
  22399. /**
  22400. * Creates a new index buffer
  22401. * @param indices defines the indices to store in the index buffer
  22402. * @param totalVertices defines the total number of vertices (could be null)
  22403. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22404. */
  22405. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22406. /**
  22407. * Return the total number of indices
  22408. * @returns the total number of indices
  22409. */
  22410. getTotalIndices(): number;
  22411. /**
  22412. * Gets the index buffer array
  22413. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22414. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22415. * @returns the index buffer array
  22416. */
  22417. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22418. /**
  22419. * Gets the index buffer
  22420. * @return the index buffer
  22421. */
  22422. getIndexBuffer(): Nullable<WebGLBuffer>;
  22423. /** @hidden */
  22424. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22425. /**
  22426. * Release the associated resources for a specific mesh
  22427. * @param mesh defines the source mesh
  22428. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22429. */
  22430. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22431. /**
  22432. * Apply current geometry to a given mesh
  22433. * @param mesh defines the mesh to apply geometry to
  22434. */
  22435. applyToMesh(mesh: Mesh): void;
  22436. private _updateExtend;
  22437. private _applyToMesh;
  22438. private notifyUpdate;
  22439. /**
  22440. * Load the geometry if it was flagged as delay loaded
  22441. * @param scene defines the hosting scene
  22442. * @param onLoaded defines a callback called when the geometry is loaded
  22443. */
  22444. load(scene: Scene, onLoaded?: () => void): void;
  22445. private _queueLoad;
  22446. /**
  22447. * Invert the geometry to move from a right handed system to a left handed one.
  22448. */
  22449. toLeftHanded(): void;
  22450. /** @hidden */
  22451. _resetPointsArrayCache(): void;
  22452. /** @hidden */
  22453. _generatePointsArray(): boolean;
  22454. /**
  22455. * Gets a value indicating if the geometry is disposed
  22456. * @returns true if the geometry was disposed
  22457. */
  22458. isDisposed(): boolean;
  22459. private _disposeVertexArrayObjects;
  22460. /**
  22461. * Free all associated resources
  22462. */
  22463. dispose(): void;
  22464. /**
  22465. * Clone the current geometry into a new geometry
  22466. * @param id defines the unique ID of the new geometry
  22467. * @returns a new geometry object
  22468. */
  22469. copy(id: string): Geometry;
  22470. /**
  22471. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22472. * @return a JSON representation of the current geometry data (without the vertices data)
  22473. */
  22474. serialize(): any;
  22475. private toNumberArray;
  22476. /**
  22477. * Serialize all vertices data into a JSON oject
  22478. * @returns a JSON representation of the current geometry data
  22479. */
  22480. serializeVerticeData(): any;
  22481. /**
  22482. * Extracts a clone of a mesh geometry
  22483. * @param mesh defines the source mesh
  22484. * @param id defines the unique ID of the new geometry object
  22485. * @returns the new geometry object
  22486. */
  22487. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22488. /**
  22489. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22490. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22491. * Be aware Math.random() could cause collisions, but:
  22492. * "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"
  22493. * @returns a string containing a new GUID
  22494. */
  22495. static RandomId(): string;
  22496. /** @hidden */
  22497. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22498. private static _CleanMatricesWeights;
  22499. /**
  22500. * Create a new geometry from persisted data (Using .babylon file format)
  22501. * @param parsedVertexData defines the persisted data
  22502. * @param scene defines the hosting scene
  22503. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22504. * @returns the new geometry object
  22505. */
  22506. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22507. }
  22508. /**
  22509. * Abstract class used to provide common services for all typed geometries
  22510. * @hidden
  22511. */
  22512. export class _PrimitiveGeometry extends Geometry {
  22513. private _canBeRegenerated;
  22514. private _beingRegenerated;
  22515. /**
  22516. * Creates a new typed geometry
  22517. * @param id defines the unique ID of the geometry
  22518. * @param scene defines the hosting scene
  22519. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22520. * @param mesh defines the hosting mesh (can be null)
  22521. */
  22522. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22523. /**
  22524. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  22525. * @returns true if the geometry can be regenerated
  22526. */
  22527. canBeRegenerated(): boolean;
  22528. /**
  22529. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  22530. */
  22531. regenerate(): void;
  22532. /**
  22533. * Clone the geometry
  22534. * @param id defines the unique ID of the new geometry
  22535. * @returns the new geometry
  22536. */
  22537. asNewGeometry(id: string): Geometry;
  22538. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22539. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  22540. /** @hidden */
  22541. _regenerateVertexData(): VertexData;
  22542. copy(id: string): Geometry;
  22543. serialize(): any;
  22544. }
  22545. /**
  22546. * Creates a ribbon geometry
  22547. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  22548. */
  22549. export class RibbonGeometry extends _PrimitiveGeometry {
  22550. /**
  22551. * Defines the array of paths to use
  22552. */
  22553. pathArray: Vector3[][];
  22554. /**
  22555. * Defines if the last and first points of each path in your pathArray must be joined
  22556. */
  22557. closeArray: boolean;
  22558. /**
  22559. * Defines if the last and first points of each path in your pathArray must be joined
  22560. */
  22561. closePath: boolean;
  22562. /**
  22563. * Defines the offset between points
  22564. */
  22565. offset: number;
  22566. /**
  22567. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22568. */
  22569. side: number;
  22570. /**
  22571. * Creates a ribbon geometry
  22572. * @param id defines the unique ID of the geometry
  22573. * @param scene defines the hosting scene
  22574. * @param pathArray defines the array of paths to use
  22575. * @param closeArray defines if the last path and the first path must be joined
  22576. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  22577. * @param offset defines the offset between points
  22578. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22579. * @param mesh defines the hosting mesh (can be null)
  22580. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22581. */
  22582. constructor(id: string, scene: Scene,
  22583. /**
  22584. * Defines the array of paths to use
  22585. */
  22586. pathArray: Vector3[][],
  22587. /**
  22588. * Defines if the last and first points of each path in your pathArray must be joined
  22589. */
  22590. closeArray: boolean,
  22591. /**
  22592. * Defines if the last and first points of each path in your pathArray must be joined
  22593. */
  22594. closePath: boolean,
  22595. /**
  22596. * Defines the offset between points
  22597. */
  22598. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  22599. /**
  22600. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22601. */
  22602. side?: number);
  22603. /** @hidden */
  22604. _regenerateVertexData(): VertexData;
  22605. copy(id: string): Geometry;
  22606. }
  22607. /**
  22608. * Creates a box geometry
  22609. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  22610. */
  22611. export class BoxGeometry extends _PrimitiveGeometry {
  22612. /**
  22613. * Defines the zise of the box (width, height and depth are the same)
  22614. */
  22615. size: number;
  22616. /**
  22617. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22618. */
  22619. side: number;
  22620. /**
  22621. * Creates a box geometry
  22622. * @param id defines the unique ID of the geometry
  22623. * @param scene defines the hosting scene
  22624. * @param size defines the zise of the box (width, height and depth are the same)
  22625. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22626. * @param mesh defines the hosting mesh (can be null)
  22627. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22628. */
  22629. constructor(id: string, scene: Scene,
  22630. /**
  22631. * Defines the zise of the box (width, height and depth are the same)
  22632. */
  22633. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22634. /**
  22635. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22636. */
  22637. side?: number);
  22638. /** @hidden */
  22639. _regenerateVertexData(): VertexData;
  22640. copy(id: string): Geometry;
  22641. serialize(): any;
  22642. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  22643. }
  22644. /**
  22645. * Creates a sphere geometry
  22646. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  22647. */
  22648. export class SphereGeometry extends _PrimitiveGeometry {
  22649. /**
  22650. * Defines the number of segments to use to create the sphere
  22651. */
  22652. segments: number;
  22653. /**
  22654. * Defines the diameter of the sphere
  22655. */
  22656. diameter: number;
  22657. /**
  22658. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22659. */
  22660. side: number;
  22661. /**
  22662. * Create a new sphere geometry
  22663. * @param id defines the unique ID of the geometry
  22664. * @param scene defines the hosting scene
  22665. * @param segments defines the number of segments to use to create the sphere
  22666. * @param diameter defines the diameter of the sphere
  22667. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22668. * @param mesh defines the hosting mesh (can be null)
  22669. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22670. */
  22671. constructor(id: string, scene: Scene,
  22672. /**
  22673. * Defines the number of segments to use to create the sphere
  22674. */
  22675. segments: number,
  22676. /**
  22677. * Defines the diameter of the sphere
  22678. */
  22679. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22680. /**
  22681. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22682. */
  22683. side?: number);
  22684. /** @hidden */
  22685. _regenerateVertexData(): VertexData;
  22686. copy(id: string): Geometry;
  22687. serialize(): any;
  22688. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  22689. }
  22690. /**
  22691. * Creates a disc geometry
  22692. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22693. */
  22694. export class DiscGeometry extends _PrimitiveGeometry {
  22695. /**
  22696. * Defines the radius of the disc
  22697. */
  22698. radius: number;
  22699. /**
  22700. * Defines the tesselation factor to apply to the disc
  22701. */
  22702. tessellation: number;
  22703. /**
  22704. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22705. */
  22706. side: number;
  22707. /**
  22708. * Creates a new disc geometry
  22709. * @param id defines the unique ID of the geometry
  22710. * @param scene defines the hosting scene
  22711. * @param radius defines the radius of the disc
  22712. * @param tessellation defines the tesselation factor to apply to the disc
  22713. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22714. * @param mesh defines the hosting mesh (can be null)
  22715. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22716. */
  22717. constructor(id: string, scene: Scene,
  22718. /**
  22719. * Defines the radius of the disc
  22720. */
  22721. radius: number,
  22722. /**
  22723. * Defines the tesselation factor to apply to the disc
  22724. */
  22725. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22726. /**
  22727. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22728. */
  22729. side?: number);
  22730. /** @hidden */
  22731. _regenerateVertexData(): VertexData;
  22732. copy(id: string): Geometry;
  22733. }
  22734. /**
  22735. * Creates a new cylinder geometry
  22736. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  22737. */
  22738. export class CylinderGeometry extends _PrimitiveGeometry {
  22739. /**
  22740. * Defines the height of the cylinder
  22741. */
  22742. height: number;
  22743. /**
  22744. * Defines the diameter of the cylinder's top cap
  22745. */
  22746. diameterTop: number;
  22747. /**
  22748. * Defines the diameter of the cylinder's bottom cap
  22749. */
  22750. diameterBottom: number;
  22751. /**
  22752. * Defines the tessellation factor to apply to the cylinder
  22753. */
  22754. tessellation: number;
  22755. /**
  22756. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22757. */
  22758. subdivisions: number;
  22759. /**
  22760. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22761. */
  22762. side: number;
  22763. /**
  22764. * Creates a new cylinder geometry
  22765. * @param id defines the unique ID of the geometry
  22766. * @param scene defines the hosting scene
  22767. * @param height defines the height of the cylinder
  22768. * @param diameterTop defines the diameter of the cylinder's top cap
  22769. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  22770. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  22771. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  22772. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22773. * @param mesh defines the hosting mesh (can be null)
  22774. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22775. */
  22776. constructor(id: string, scene: Scene,
  22777. /**
  22778. * Defines the height of the cylinder
  22779. */
  22780. height: number,
  22781. /**
  22782. * Defines the diameter of the cylinder's top cap
  22783. */
  22784. diameterTop: number,
  22785. /**
  22786. * Defines the diameter of the cylinder's bottom cap
  22787. */
  22788. diameterBottom: number,
  22789. /**
  22790. * Defines the tessellation factor to apply to the cylinder
  22791. */
  22792. tessellation: number,
  22793. /**
  22794. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22795. */
  22796. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22797. /**
  22798. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22799. */
  22800. side?: number);
  22801. /** @hidden */
  22802. _regenerateVertexData(): VertexData;
  22803. copy(id: string): Geometry;
  22804. serialize(): any;
  22805. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  22806. }
  22807. /**
  22808. * Creates a new torus geometry
  22809. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  22810. */
  22811. export class TorusGeometry extends _PrimitiveGeometry {
  22812. /**
  22813. * Defines the diameter of the torus
  22814. */
  22815. diameter: number;
  22816. /**
  22817. * Defines the thickness of the torus (ie. internal diameter)
  22818. */
  22819. thickness: number;
  22820. /**
  22821. * Defines the tesselation factor to apply to the torus
  22822. */
  22823. tessellation: number;
  22824. /**
  22825. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22826. */
  22827. side: number;
  22828. /**
  22829. * Creates a new torus geometry
  22830. * @param id defines the unique ID of the geometry
  22831. * @param scene defines the hosting scene
  22832. * @param diameter defines the diameter of the torus
  22833. * @param thickness defines the thickness of the torus (ie. internal diameter)
  22834. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  22835. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22836. * @param mesh defines the hosting mesh (can be null)
  22837. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22838. */
  22839. constructor(id: string, scene: Scene,
  22840. /**
  22841. * Defines the diameter of the torus
  22842. */
  22843. diameter: number,
  22844. /**
  22845. * Defines the thickness of the torus (ie. internal diameter)
  22846. */
  22847. thickness: number,
  22848. /**
  22849. * Defines the tesselation factor to apply to the torus
  22850. */
  22851. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22852. /**
  22853. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22854. */
  22855. side?: number);
  22856. /** @hidden */
  22857. _regenerateVertexData(): VertexData;
  22858. copy(id: string): Geometry;
  22859. serialize(): any;
  22860. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  22861. }
  22862. /**
  22863. * Creates a new ground geometry
  22864. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  22865. */
  22866. export class GroundGeometry extends _PrimitiveGeometry {
  22867. /**
  22868. * Defines the width of the ground
  22869. */
  22870. width: number;
  22871. /**
  22872. * Defines the height of the ground
  22873. */
  22874. height: number;
  22875. /**
  22876. * Defines the subdivisions to apply to the ground
  22877. */
  22878. subdivisions: number;
  22879. /**
  22880. * Creates a new ground geometry
  22881. * @param id defines the unique ID of the geometry
  22882. * @param scene defines the hosting scene
  22883. * @param width defines the width of the ground
  22884. * @param height defines the height of the ground
  22885. * @param subdivisions defines the subdivisions to apply to the ground
  22886. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22887. * @param mesh defines the hosting mesh (can be null)
  22888. */
  22889. constructor(id: string, scene: Scene,
  22890. /**
  22891. * Defines the width of the ground
  22892. */
  22893. width: number,
  22894. /**
  22895. * Defines the height of the ground
  22896. */
  22897. height: number,
  22898. /**
  22899. * Defines the subdivisions to apply to the ground
  22900. */
  22901. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22902. /** @hidden */
  22903. _regenerateVertexData(): VertexData;
  22904. copy(id: string): Geometry;
  22905. serialize(): any;
  22906. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  22907. }
  22908. /**
  22909. * Creates a tiled ground geometry
  22910. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  22911. */
  22912. export class TiledGroundGeometry extends _PrimitiveGeometry {
  22913. /**
  22914. * Defines the minimum value on X axis
  22915. */
  22916. xmin: number;
  22917. /**
  22918. * Defines the minimum value on Z axis
  22919. */
  22920. zmin: number;
  22921. /**
  22922. * Defines the maximum value on X axis
  22923. */
  22924. xmax: number;
  22925. /**
  22926. * Defines the maximum value on Z axis
  22927. */
  22928. zmax: number;
  22929. /**
  22930. * Defines the subdivisions to apply to the ground
  22931. */
  22932. subdivisions: {
  22933. w: number;
  22934. h: number;
  22935. };
  22936. /**
  22937. * Defines the precision to use when computing the tiles
  22938. */
  22939. precision: {
  22940. w: number;
  22941. h: number;
  22942. };
  22943. /**
  22944. * Creates a tiled ground geometry
  22945. * @param id defines the unique ID of the geometry
  22946. * @param scene defines the hosting scene
  22947. * @param xmin defines the minimum value on X axis
  22948. * @param zmin defines the minimum value on Z axis
  22949. * @param xmax defines the maximum value on X axis
  22950. * @param zmax defines the maximum value on Z axis
  22951. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  22952. * @param precision defines the precision to use when computing the tiles
  22953. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22954. * @param mesh defines the hosting mesh (can be null)
  22955. */
  22956. constructor(id: string, scene: Scene,
  22957. /**
  22958. * Defines the minimum value on X axis
  22959. */
  22960. xmin: number,
  22961. /**
  22962. * Defines the minimum value on Z axis
  22963. */
  22964. zmin: number,
  22965. /**
  22966. * Defines the maximum value on X axis
  22967. */
  22968. xmax: number,
  22969. /**
  22970. * Defines the maximum value on Z axis
  22971. */
  22972. zmax: number,
  22973. /**
  22974. * Defines the subdivisions to apply to the ground
  22975. */
  22976. subdivisions: {
  22977. w: number;
  22978. h: number;
  22979. },
  22980. /**
  22981. * Defines the precision to use when computing the tiles
  22982. */
  22983. precision: {
  22984. w: number;
  22985. h: number;
  22986. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22987. /** @hidden */
  22988. _regenerateVertexData(): VertexData;
  22989. copy(id: string): Geometry;
  22990. }
  22991. /**
  22992. * Creates a plane geometry
  22993. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  22994. */
  22995. export class PlaneGeometry extends _PrimitiveGeometry {
  22996. /**
  22997. * Defines the size of the plane (width === height)
  22998. */
  22999. size: number;
  23000. /**
  23001. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23002. */
  23003. side: number;
  23004. /**
  23005. * Creates a plane geometry
  23006. * @param id defines the unique ID of the geometry
  23007. * @param scene defines the hosting scene
  23008. * @param size defines the size of the plane (width === height)
  23009. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23010. * @param mesh defines the hosting mesh (can be null)
  23011. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23012. */
  23013. constructor(id: string, scene: Scene,
  23014. /**
  23015. * Defines the size of the plane (width === height)
  23016. */
  23017. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23018. /**
  23019. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23020. */
  23021. side?: number);
  23022. /** @hidden */
  23023. _regenerateVertexData(): VertexData;
  23024. copy(id: string): Geometry;
  23025. serialize(): any;
  23026. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  23027. }
  23028. /**
  23029. * Creates a torus knot geometry
  23030. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  23031. */
  23032. export class TorusKnotGeometry extends _PrimitiveGeometry {
  23033. /**
  23034. * Defines the radius of the torus knot
  23035. */
  23036. radius: number;
  23037. /**
  23038. * Defines the thickness of the torus knot tube
  23039. */
  23040. tube: number;
  23041. /**
  23042. * Defines the number of radial segments
  23043. */
  23044. radialSegments: number;
  23045. /**
  23046. * Defines the number of tubular segments
  23047. */
  23048. tubularSegments: number;
  23049. /**
  23050. * Defines the first number of windings
  23051. */
  23052. p: number;
  23053. /**
  23054. * Defines the second number of windings
  23055. */
  23056. q: number;
  23057. /**
  23058. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23059. */
  23060. side: number;
  23061. /**
  23062. * Creates a torus knot geometry
  23063. * @param id defines the unique ID of the geometry
  23064. * @param scene defines the hosting scene
  23065. * @param radius defines the radius of the torus knot
  23066. * @param tube defines the thickness of the torus knot tube
  23067. * @param radialSegments defines the number of radial segments
  23068. * @param tubularSegments defines the number of tubular segments
  23069. * @param p defines the first number of windings
  23070. * @param q defines the second number of windings
  23071. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23072. * @param mesh defines the hosting mesh (can be null)
  23073. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23074. */
  23075. constructor(id: string, scene: Scene,
  23076. /**
  23077. * Defines the radius of the torus knot
  23078. */
  23079. radius: number,
  23080. /**
  23081. * Defines the thickness of the torus knot tube
  23082. */
  23083. tube: number,
  23084. /**
  23085. * Defines the number of radial segments
  23086. */
  23087. radialSegments: number,
  23088. /**
  23089. * Defines the number of tubular segments
  23090. */
  23091. tubularSegments: number,
  23092. /**
  23093. * Defines the first number of windings
  23094. */
  23095. p: number,
  23096. /**
  23097. * Defines the second number of windings
  23098. */
  23099. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23100. /**
  23101. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23102. */
  23103. side?: number);
  23104. /** @hidden */
  23105. _regenerateVertexData(): VertexData;
  23106. copy(id: string): Geometry;
  23107. serialize(): any;
  23108. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  23109. }
  23110. }
  23111. declare module "babylonjs/Meshes/mesh.vertexData" {
  23112. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23113. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23114. import { Geometry } from "babylonjs/Meshes/geometry";
  23115. import { Mesh } from "babylonjs/Meshes/mesh";
  23116. /**
  23117. * Define an interface for all classes that will get and set the data on vertices
  23118. */
  23119. export interface IGetSetVerticesData {
  23120. /**
  23121. * Gets a boolean indicating if specific vertex data is present
  23122. * @param kind defines the vertex data kind to use
  23123. * @returns true is data kind is present
  23124. */
  23125. isVerticesDataPresent(kind: string): boolean;
  23126. /**
  23127. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23128. * @param kind defines the data kind (Position, normal, etc...)
  23129. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23130. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23131. * @returns a float array containing vertex data
  23132. */
  23133. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23134. /**
  23135. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23136. * @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.
  23137. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23138. * @returns the indices array or an empty array if the mesh has no geometry
  23139. */
  23140. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23141. /**
  23142. * Set specific vertex data
  23143. * @param kind defines the data kind (Position, normal, etc...)
  23144. * @param data defines the vertex data to use
  23145. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23146. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23147. */
  23148. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23149. /**
  23150. * Update a specific associated vertex buffer
  23151. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23152. * - VertexBuffer.PositionKind
  23153. * - VertexBuffer.UVKind
  23154. * - VertexBuffer.UV2Kind
  23155. * - VertexBuffer.UV3Kind
  23156. * - VertexBuffer.UV4Kind
  23157. * - VertexBuffer.UV5Kind
  23158. * - VertexBuffer.UV6Kind
  23159. * - VertexBuffer.ColorKind
  23160. * - VertexBuffer.MatricesIndicesKind
  23161. * - VertexBuffer.MatricesIndicesExtraKind
  23162. * - VertexBuffer.MatricesWeightsKind
  23163. * - VertexBuffer.MatricesWeightsExtraKind
  23164. * @param data defines the data source
  23165. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23166. * @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)
  23167. */
  23168. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23169. /**
  23170. * Creates a new index buffer
  23171. * @param indices defines the indices to store in the index buffer
  23172. * @param totalVertices defines the total number of vertices (could be null)
  23173. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23174. */
  23175. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23176. }
  23177. /**
  23178. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23179. */
  23180. export class VertexData {
  23181. /**
  23182. * Mesh side orientation : usually the external or front surface
  23183. */
  23184. static readonly FRONTSIDE: number;
  23185. /**
  23186. * Mesh side orientation : usually the internal or back surface
  23187. */
  23188. static readonly BACKSIDE: number;
  23189. /**
  23190. * Mesh side orientation : both internal and external or front and back surfaces
  23191. */
  23192. static readonly DOUBLESIDE: number;
  23193. /**
  23194. * Mesh side orientation : by default, `FRONTSIDE`
  23195. */
  23196. static readonly DEFAULTSIDE: number;
  23197. /**
  23198. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23199. */
  23200. positions: Nullable<FloatArray>;
  23201. /**
  23202. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23203. */
  23204. normals: Nullable<FloatArray>;
  23205. /**
  23206. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23207. */
  23208. tangents: Nullable<FloatArray>;
  23209. /**
  23210. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23211. */
  23212. uvs: Nullable<FloatArray>;
  23213. /**
  23214. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23215. */
  23216. uvs2: Nullable<FloatArray>;
  23217. /**
  23218. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23219. */
  23220. uvs3: Nullable<FloatArray>;
  23221. /**
  23222. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23223. */
  23224. uvs4: Nullable<FloatArray>;
  23225. /**
  23226. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23227. */
  23228. uvs5: Nullable<FloatArray>;
  23229. /**
  23230. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23231. */
  23232. uvs6: Nullable<FloatArray>;
  23233. /**
  23234. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23235. */
  23236. colors: Nullable<FloatArray>;
  23237. /**
  23238. * 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).
  23239. */
  23240. matricesIndices: Nullable<FloatArray>;
  23241. /**
  23242. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23243. */
  23244. matricesWeights: Nullable<FloatArray>;
  23245. /**
  23246. * An array extending the number of possible indices
  23247. */
  23248. matricesIndicesExtra: Nullable<FloatArray>;
  23249. /**
  23250. * An array extending the number of possible weights when the number of indices is extended
  23251. */
  23252. matricesWeightsExtra: Nullable<FloatArray>;
  23253. /**
  23254. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23255. */
  23256. indices: Nullable<IndicesArray>;
  23257. /**
  23258. * Uses the passed data array to set the set the values for the specified kind of data
  23259. * @param data a linear array of floating numbers
  23260. * @param kind the type of data that is being set, eg positions, colors etc
  23261. */
  23262. set(data: FloatArray, kind: string): void;
  23263. /**
  23264. * Associates the vertexData to the passed Mesh.
  23265. * Sets it as updatable or not (default `false`)
  23266. * @param mesh the mesh the vertexData is applied to
  23267. * @param updatable when used and having the value true allows new data to update the vertexData
  23268. * @returns the VertexData
  23269. */
  23270. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23271. /**
  23272. * Associates the vertexData to the passed Geometry.
  23273. * Sets it as updatable or not (default `false`)
  23274. * @param geometry the geometry the vertexData is applied to
  23275. * @param updatable when used and having the value true allows new data to update the vertexData
  23276. * @returns VertexData
  23277. */
  23278. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23279. /**
  23280. * Updates the associated mesh
  23281. * @param mesh the mesh to be updated
  23282. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23283. * @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
  23284. * @returns VertexData
  23285. */
  23286. updateMesh(mesh: Mesh): VertexData;
  23287. /**
  23288. * Updates the associated geometry
  23289. * @param geometry the geometry to be updated
  23290. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23291. * @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
  23292. * @returns VertexData.
  23293. */
  23294. updateGeometry(geometry: Geometry): VertexData;
  23295. private _applyTo;
  23296. private _update;
  23297. /**
  23298. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23299. * @param matrix the transforming matrix
  23300. * @returns the VertexData
  23301. */
  23302. transform(matrix: Matrix): VertexData;
  23303. /**
  23304. * Merges the passed VertexData into the current one
  23305. * @param other the VertexData to be merged into the current one
  23306. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23307. * @returns the modified VertexData
  23308. */
  23309. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23310. private _mergeElement;
  23311. private _validate;
  23312. /**
  23313. * Serializes the VertexData
  23314. * @returns a serialized object
  23315. */
  23316. serialize(): any;
  23317. /**
  23318. * Extracts the vertexData from a mesh
  23319. * @param mesh the mesh from which to extract the VertexData
  23320. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23321. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23322. * @returns the object VertexData associated to the passed mesh
  23323. */
  23324. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23325. /**
  23326. * Extracts the vertexData from the geometry
  23327. * @param geometry the geometry from which to extract the VertexData
  23328. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23329. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23330. * @returns the object VertexData associated to the passed mesh
  23331. */
  23332. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23333. private static _ExtractFrom;
  23334. /**
  23335. * Creates the VertexData for a Ribbon
  23336. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23337. * * pathArray array of paths, each of which an array of successive Vector3
  23338. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23339. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23340. * * 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
  23341. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23342. * * 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)
  23343. * * 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)
  23344. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23345. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23346. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23347. * @returns the VertexData of the ribbon
  23348. */
  23349. static CreateRibbon(options: {
  23350. pathArray: Vector3[][];
  23351. closeArray?: boolean;
  23352. closePath?: boolean;
  23353. offset?: number;
  23354. sideOrientation?: number;
  23355. frontUVs?: Vector4;
  23356. backUVs?: Vector4;
  23357. invertUV?: boolean;
  23358. uvs?: Vector2[];
  23359. colors?: Color4[];
  23360. }): VertexData;
  23361. /**
  23362. * Creates the VertexData for a box
  23363. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23364. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23365. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23366. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23367. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23368. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23369. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23371. * * 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)
  23372. * * 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)
  23373. * @returns the VertexData of the box
  23374. */
  23375. static CreateBox(options: {
  23376. size?: number;
  23377. width?: number;
  23378. height?: number;
  23379. depth?: number;
  23380. faceUV?: Vector4[];
  23381. faceColors?: Color4[];
  23382. sideOrientation?: number;
  23383. frontUVs?: Vector4;
  23384. backUVs?: Vector4;
  23385. }): VertexData;
  23386. /**
  23387. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23388. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23389. * * segments sets the number of horizontal strips optional, default 32
  23390. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23391. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23392. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23393. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23394. * * 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
  23395. * * 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
  23396. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23397. * * 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)
  23398. * * 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)
  23399. * @returns the VertexData of the ellipsoid
  23400. */
  23401. static CreateSphere(options: {
  23402. segments?: number;
  23403. diameter?: number;
  23404. diameterX?: number;
  23405. diameterY?: number;
  23406. diameterZ?: number;
  23407. arc?: number;
  23408. slice?: number;
  23409. sideOrientation?: number;
  23410. frontUVs?: Vector4;
  23411. backUVs?: Vector4;
  23412. }): VertexData;
  23413. /**
  23414. * Creates the VertexData for a cylinder, cone or prism
  23415. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23416. * * height sets the height (y direction) of the cylinder, optional, default 2
  23417. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23418. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23419. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23420. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23421. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23422. * * 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
  23423. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23424. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23425. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23426. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23427. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23428. * * 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)
  23429. * * 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)
  23430. * @returns the VertexData of the cylinder, cone or prism
  23431. */
  23432. static CreateCylinder(options: {
  23433. height?: number;
  23434. diameterTop?: number;
  23435. diameterBottom?: number;
  23436. diameter?: number;
  23437. tessellation?: number;
  23438. subdivisions?: number;
  23439. arc?: number;
  23440. faceColors?: Color4[];
  23441. faceUV?: Vector4[];
  23442. hasRings?: boolean;
  23443. enclose?: boolean;
  23444. sideOrientation?: number;
  23445. frontUVs?: Vector4;
  23446. backUVs?: Vector4;
  23447. }): VertexData;
  23448. /**
  23449. * Creates the VertexData for a torus
  23450. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23451. * * diameter the diameter of the torus, optional default 1
  23452. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23453. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23455. * * 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)
  23456. * * 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)
  23457. * @returns the VertexData of the torus
  23458. */
  23459. static CreateTorus(options: {
  23460. diameter?: number;
  23461. thickness?: number;
  23462. tessellation?: number;
  23463. sideOrientation?: number;
  23464. frontUVs?: Vector4;
  23465. backUVs?: Vector4;
  23466. }): VertexData;
  23467. /**
  23468. * Creates the VertexData of the LineSystem
  23469. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23470. * - lines an array of lines, each line being an array of successive Vector3
  23471. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23472. * @returns the VertexData of the LineSystem
  23473. */
  23474. static CreateLineSystem(options: {
  23475. lines: Vector3[][];
  23476. colors?: Nullable<Color4[][]>;
  23477. }): VertexData;
  23478. /**
  23479. * Create the VertexData for a DashedLines
  23480. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23481. * - points an array successive Vector3
  23482. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23483. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23484. * - dashNb the intended total number of dashes, optional, default 200
  23485. * @returns the VertexData for the DashedLines
  23486. */
  23487. static CreateDashedLines(options: {
  23488. points: Vector3[];
  23489. dashSize?: number;
  23490. gapSize?: number;
  23491. dashNb?: number;
  23492. }): VertexData;
  23493. /**
  23494. * Creates the VertexData for a Ground
  23495. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23496. * - width the width (x direction) of the ground, optional, default 1
  23497. * - height the height (z direction) of the ground, optional, default 1
  23498. * - subdivisions the number of subdivisions per side, optional, default 1
  23499. * @returns the VertexData of the Ground
  23500. */
  23501. static CreateGround(options: {
  23502. width?: number;
  23503. height?: number;
  23504. subdivisions?: number;
  23505. subdivisionsX?: number;
  23506. subdivisionsY?: number;
  23507. }): VertexData;
  23508. /**
  23509. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23510. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23511. * * xmin the ground minimum X coordinate, optional, default -1
  23512. * * zmin the ground minimum Z coordinate, optional, default -1
  23513. * * xmax the ground maximum X coordinate, optional, default 1
  23514. * * zmax the ground maximum Z coordinate, optional, default 1
  23515. * * 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}
  23516. * * 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}
  23517. * @returns the VertexData of the TiledGround
  23518. */
  23519. static CreateTiledGround(options: {
  23520. xmin: number;
  23521. zmin: number;
  23522. xmax: number;
  23523. zmax: number;
  23524. subdivisions?: {
  23525. w: number;
  23526. h: number;
  23527. };
  23528. precision?: {
  23529. w: number;
  23530. h: number;
  23531. };
  23532. }): VertexData;
  23533. /**
  23534. * Creates the VertexData of the Ground designed from a heightmap
  23535. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23536. * * width the width (x direction) of the ground
  23537. * * height the height (z direction) of the ground
  23538. * * subdivisions the number of subdivisions per side
  23539. * * minHeight the minimum altitude on the ground, optional, default 0
  23540. * * maxHeight the maximum altitude on the ground, optional default 1
  23541. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23542. * * buffer the array holding the image color data
  23543. * * bufferWidth the width of image
  23544. * * bufferHeight the height of image
  23545. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23546. * @returns the VertexData of the Ground designed from a heightmap
  23547. */
  23548. static CreateGroundFromHeightMap(options: {
  23549. width: number;
  23550. height: number;
  23551. subdivisions: number;
  23552. minHeight: number;
  23553. maxHeight: number;
  23554. colorFilter: Color3;
  23555. buffer: Uint8Array;
  23556. bufferWidth: number;
  23557. bufferHeight: number;
  23558. alphaFilter: number;
  23559. }): VertexData;
  23560. /**
  23561. * Creates the VertexData for a Plane
  23562. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23563. * * size sets the width and height of the plane to the value of size, optional default 1
  23564. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23565. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23566. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23567. * * 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)
  23568. * * 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)
  23569. * @returns the VertexData of the box
  23570. */
  23571. static CreatePlane(options: {
  23572. size?: number;
  23573. width?: number;
  23574. height?: number;
  23575. sideOrientation?: number;
  23576. frontUVs?: Vector4;
  23577. backUVs?: Vector4;
  23578. }): VertexData;
  23579. /**
  23580. * Creates the VertexData of the Disc or regular Polygon
  23581. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23582. * * radius the radius of the disc, optional default 0.5
  23583. * * tessellation the number of polygon sides, optional, default 64
  23584. * * 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
  23585. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23586. * * 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)
  23587. * * 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)
  23588. * @returns the VertexData of the box
  23589. */
  23590. static CreateDisc(options: {
  23591. radius?: number;
  23592. tessellation?: number;
  23593. arc?: number;
  23594. sideOrientation?: number;
  23595. frontUVs?: Vector4;
  23596. backUVs?: Vector4;
  23597. }): VertexData;
  23598. /**
  23599. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23600. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23601. * @param polygon a mesh built from polygonTriangulation.build()
  23602. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23603. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23604. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23605. * @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)
  23606. * @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)
  23607. * @returns the VertexData of the Polygon
  23608. */
  23609. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23610. /**
  23611. * Creates the VertexData of the IcoSphere
  23612. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23613. * * radius the radius of the IcoSphere, optional default 1
  23614. * * radiusX allows stretching in the x direction, optional, default radius
  23615. * * radiusY allows stretching in the y direction, optional, default radius
  23616. * * radiusZ allows stretching in the z direction, optional, default radius
  23617. * * flat when true creates a flat shaded mesh, optional, default true
  23618. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23619. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23620. * * 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)
  23621. * * 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)
  23622. * @returns the VertexData of the IcoSphere
  23623. */
  23624. static CreateIcoSphere(options: {
  23625. radius?: number;
  23626. radiusX?: number;
  23627. radiusY?: number;
  23628. radiusZ?: number;
  23629. flat?: boolean;
  23630. subdivisions?: number;
  23631. sideOrientation?: number;
  23632. frontUVs?: Vector4;
  23633. backUVs?: Vector4;
  23634. }): VertexData;
  23635. /**
  23636. * Creates the VertexData for a Polyhedron
  23637. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23638. * * type provided types are:
  23639. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23640. * * 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)
  23641. * * size the size of the IcoSphere, optional default 1
  23642. * * sizeX allows stretching in the x direction, optional, default size
  23643. * * sizeY allows stretching in the y direction, optional, default size
  23644. * * sizeZ allows stretching in the z direction, optional, default size
  23645. * * 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
  23646. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23647. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23648. * * flat when true creates a flat shaded mesh, optional, default true
  23649. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23650. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23651. * * 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)
  23652. * * 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)
  23653. * @returns the VertexData of the Polyhedron
  23654. */
  23655. static CreatePolyhedron(options: {
  23656. type?: number;
  23657. size?: number;
  23658. sizeX?: number;
  23659. sizeY?: number;
  23660. sizeZ?: number;
  23661. custom?: any;
  23662. faceUV?: Vector4[];
  23663. faceColors?: Color4[];
  23664. flat?: boolean;
  23665. sideOrientation?: number;
  23666. frontUVs?: Vector4;
  23667. backUVs?: Vector4;
  23668. }): VertexData;
  23669. /**
  23670. * Creates the VertexData for a TorusKnot
  23671. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23672. * * radius the radius of the torus knot, optional, default 2
  23673. * * tube the thickness of the tube, optional, default 0.5
  23674. * * radialSegments the number of sides on each tube segments, optional, default 32
  23675. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23676. * * p the number of windings around the z axis, optional, default 2
  23677. * * q the number of windings around the x axis, optional, default 3
  23678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23679. * * 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)
  23680. * * 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)
  23681. * @returns the VertexData of the Torus Knot
  23682. */
  23683. static CreateTorusKnot(options: {
  23684. radius?: number;
  23685. tube?: number;
  23686. radialSegments?: number;
  23687. tubularSegments?: number;
  23688. p?: number;
  23689. q?: number;
  23690. sideOrientation?: number;
  23691. frontUVs?: Vector4;
  23692. backUVs?: Vector4;
  23693. }): VertexData;
  23694. /**
  23695. * Compute normals for given positions and indices
  23696. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23697. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23698. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23699. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23700. * * facetNormals : optional array of facet normals (vector3)
  23701. * * facetPositions : optional array of facet positions (vector3)
  23702. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23703. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23704. * * bInfo : optional bounding info, required for facetPartitioning computation
  23705. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23706. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23707. * * useRightHandedSystem: optional boolean to for right handed system computation
  23708. * * depthSort : optional boolean to enable the facet depth sort computation
  23709. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23710. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23711. */
  23712. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23713. facetNormals?: any;
  23714. facetPositions?: any;
  23715. facetPartitioning?: any;
  23716. ratio?: number;
  23717. bInfo?: any;
  23718. bbSize?: Vector3;
  23719. subDiv?: any;
  23720. useRightHandedSystem?: boolean;
  23721. depthSort?: boolean;
  23722. distanceTo?: Vector3;
  23723. depthSortedFacets?: any;
  23724. }): void;
  23725. private static _ComputeSides;
  23726. /**
  23727. * Applies VertexData created from the imported parameters to the geometry
  23728. * @param parsedVertexData the parsed data from an imported file
  23729. * @param geometry the geometry to apply the VertexData to
  23730. */
  23731. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23732. }
  23733. }
  23734. declare module "babylonjs/Meshes/polygonMesh" {
  23735. import { Scene } from "babylonjs/scene";
  23736. import { Vector2, Path2 } from "babylonjs/Maths/math";
  23737. import { Mesh } from "babylonjs/Meshes/mesh";
  23738. /**
  23739. * Polygon
  23740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  23741. */
  23742. export class Polygon {
  23743. /**
  23744. * Creates a rectangle
  23745. * @param xmin bottom X coord
  23746. * @param ymin bottom Y coord
  23747. * @param xmax top X coord
  23748. * @param ymax top Y coord
  23749. * @returns points that make the resulting rectation
  23750. */
  23751. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23752. /**
  23753. * Creates a circle
  23754. * @param radius radius of circle
  23755. * @param cx scale in x
  23756. * @param cy scale in y
  23757. * @param numberOfSides number of sides that make up the circle
  23758. * @returns points that make the resulting circle
  23759. */
  23760. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23761. /**
  23762. * Creates a polygon from input string
  23763. * @param input Input polygon data
  23764. * @returns the parsed points
  23765. */
  23766. static Parse(input: string): Vector2[];
  23767. /**
  23768. * Starts building a polygon from x and y coordinates
  23769. * @param x x coordinate
  23770. * @param y y coordinate
  23771. * @returns the started path2
  23772. */
  23773. static StartingAt(x: number, y: number): Path2;
  23774. }
  23775. /**
  23776. * Builds a polygon
  23777. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  23778. */
  23779. export class PolygonMeshBuilder {
  23780. private _points;
  23781. private _outlinepoints;
  23782. private _holes;
  23783. private _name;
  23784. private _scene;
  23785. private _epoints;
  23786. private _eholes;
  23787. private _addToepoint;
  23788. /**
  23789. * Babylon reference to the earcut plugin.
  23790. */
  23791. bjsEarcut: any;
  23792. /**
  23793. * Creates a PolygonMeshBuilder
  23794. * @param name name of the builder
  23795. * @param contours Path of the polygon
  23796. * @param scene scene to add to
  23797. */
  23798. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  23799. /**
  23800. * Adds a whole within the polygon
  23801. * @param hole Array of points defining the hole
  23802. * @returns this
  23803. */
  23804. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23805. /**
  23806. * Creates the polygon
  23807. * @param updatable If the mesh should be updatable
  23808. * @param depth The depth of the mesh created
  23809. * @returns the created mesh
  23810. */
  23811. build(updatable?: boolean, depth?: number): Mesh;
  23812. /**
  23813. * Adds a side to the polygon
  23814. * @param positions points that make the polygon
  23815. * @param normals normals of the polygon
  23816. * @param uvs uvs of the polygon
  23817. * @param indices indices of the polygon
  23818. * @param bounds bounds of the polygon
  23819. * @param points points of the polygon
  23820. * @param depth depth of the polygon
  23821. * @param flip flip of the polygon
  23822. */
  23823. private addSide;
  23824. }
  23825. }
  23826. declare module "babylonjs/Meshes/meshBuilder" {
  23827. import { Nullable } from "babylonjs/types";
  23828. import { Scene } from "babylonjs/scene";
  23829. import { Vector3, Vector2, Color3, Color4, Plane, Vector4 } from "babylonjs/Maths/math";
  23830. import { Mesh } from "babylonjs/Meshes/mesh";
  23831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23832. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23833. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23834. /**
  23835. * Class containing static functions to help procedurally build meshes
  23836. */
  23837. export class MeshBuilder {
  23838. private static _UpdateSideOrientation;
  23839. /**
  23840. * Creates a box mesh
  23841. * * The parameter `size` sets the size (float) of each box side (default 1)
  23842. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  23843. * * 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)
  23844. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  23845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23848. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  23849. * @param name defines the name of the mesh
  23850. * @param options defines the options used to create the mesh
  23851. * @param scene defines the hosting scene
  23852. * @returns the box mesh
  23853. */
  23854. static CreateBox(name: string, options: {
  23855. size?: number;
  23856. width?: number;
  23857. height?: number;
  23858. depth?: number;
  23859. faceUV?: Vector4[];
  23860. faceColors?: Color4[];
  23861. sideOrientation?: number;
  23862. frontUVs?: Vector4;
  23863. backUVs?: Vector4;
  23864. updatable?: boolean;
  23865. }, scene?: Nullable<Scene>): Mesh;
  23866. /**
  23867. * Creates a sphere mesh
  23868. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  23869. * * 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`)
  23870. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  23871. * * 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
  23872. * * 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)
  23873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23876. * @param name defines the name of the mesh
  23877. * @param options defines the options used to create the mesh
  23878. * @param scene defines the hosting scene
  23879. * @returns the sphere mesh
  23880. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  23881. */
  23882. static CreateSphere(name: string, options: {
  23883. segments?: number;
  23884. diameter?: number;
  23885. diameterX?: number;
  23886. diameterY?: number;
  23887. diameterZ?: number;
  23888. arc?: number;
  23889. slice?: number;
  23890. sideOrientation?: number;
  23891. frontUVs?: Vector4;
  23892. backUVs?: Vector4;
  23893. updatable?: boolean;
  23894. }, scene: any): Mesh;
  23895. /**
  23896. * Creates a plane polygonal mesh. By default, this is a disc
  23897. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23898. * * 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
  23899. * * 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
  23900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23903. * @param name defines the name of the mesh
  23904. * @param options defines the options used to create the mesh
  23905. * @param scene defines the hosting scene
  23906. * @returns the plane polygonal mesh
  23907. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23908. */
  23909. static CreateDisc(name: string, options: {
  23910. radius?: number;
  23911. tessellation?: number;
  23912. arc?: number;
  23913. updatable?: boolean;
  23914. sideOrientation?: number;
  23915. frontUVs?: Vector4;
  23916. backUVs?: Vector4;
  23917. }, scene?: Nullable<Scene>): Mesh;
  23918. /**
  23919. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23920. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23921. * * 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`)
  23922. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23923. * * 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
  23924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23927. * @param name defines the name of the mesh
  23928. * @param options defines the options used to create the mesh
  23929. * @param scene defines the hosting scene
  23930. * @returns the icosahedron mesh
  23931. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23932. */
  23933. static CreateIcoSphere(name: string, options: {
  23934. radius?: number;
  23935. radiusX?: number;
  23936. radiusY?: number;
  23937. radiusZ?: number;
  23938. flat?: boolean;
  23939. subdivisions?: number;
  23940. sideOrientation?: number;
  23941. frontUVs?: Vector4;
  23942. backUVs?: Vector4;
  23943. updatable?: boolean;
  23944. }, scene: Scene): Mesh;
  23945. /**
  23946. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23947. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  23948. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  23949. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  23950. * * 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
  23951. * * 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
  23952. * * 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
  23953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23955. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23956. * * 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
  23957. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  23958. * * 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
  23959. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  23960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23961. * @param name defines the name of the mesh
  23962. * @param options defines the options used to create the mesh
  23963. * @param scene defines the hosting scene
  23964. * @returns the ribbon mesh
  23965. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  23966. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23967. */
  23968. static CreateRibbon(name: string, options: {
  23969. pathArray: Vector3[][];
  23970. closeArray?: boolean;
  23971. closePath?: boolean;
  23972. offset?: number;
  23973. updatable?: boolean;
  23974. sideOrientation?: number;
  23975. frontUVs?: Vector4;
  23976. backUVs?: Vector4;
  23977. instance?: Mesh;
  23978. invertUV?: boolean;
  23979. uvs?: Vector2[];
  23980. colors?: Color4[];
  23981. }, scene?: Nullable<Scene>): Mesh;
  23982. /**
  23983. * Creates a cylinder or a cone mesh
  23984. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23985. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23986. * * 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.
  23987. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23988. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23989. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  23990. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  23991. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  23992. * * 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).
  23993. * * 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
  23994. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  23995. * * 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
  23996. * * 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.
  23997. * * If `enclose` is false, a ring surface is one element.
  23998. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  23999. * * 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
  24000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24003. * @param name defines the name of the mesh
  24004. * @param options defines the options used to create the mesh
  24005. * @param scene defines the hosting scene
  24006. * @returns the cylinder mesh
  24007. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  24008. */
  24009. static CreateCylinder(name: string, options: {
  24010. height?: number;
  24011. diameterTop?: number;
  24012. diameterBottom?: number;
  24013. diameter?: number;
  24014. tessellation?: number;
  24015. subdivisions?: number;
  24016. arc?: number;
  24017. faceColors?: Color4[];
  24018. faceUV?: Vector4[];
  24019. updatable?: boolean;
  24020. hasRings?: boolean;
  24021. enclose?: boolean;
  24022. sideOrientation?: number;
  24023. frontUVs?: Vector4;
  24024. backUVs?: Vector4;
  24025. }, scene: any): Mesh;
  24026. /**
  24027. * Creates a torus mesh
  24028. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  24029. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  24030. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  24031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24034. * @param name defines the name of the mesh
  24035. * @param options defines the options used to create the mesh
  24036. * @param scene defines the hosting scene
  24037. * @returns the torus mesh
  24038. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  24039. */
  24040. static CreateTorus(name: string, options: {
  24041. diameter?: number;
  24042. thickness?: number;
  24043. tessellation?: number;
  24044. updatable?: boolean;
  24045. sideOrientation?: number;
  24046. frontUVs?: Vector4;
  24047. backUVs?: Vector4;
  24048. }, scene: any): Mesh;
  24049. /**
  24050. * Creates a torus knot mesh
  24051. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  24052. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  24053. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  24054. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  24055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24058. * @param name defines the name of the mesh
  24059. * @param options defines the options used to create the mesh
  24060. * @param scene defines the hosting scene
  24061. * @returns the torus knot mesh
  24062. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  24063. */
  24064. static CreateTorusKnot(name: string, options: {
  24065. radius?: number;
  24066. tube?: number;
  24067. radialSegments?: number;
  24068. tubularSegments?: number;
  24069. p?: number;
  24070. q?: number;
  24071. updatable?: boolean;
  24072. sideOrientation?: number;
  24073. frontUVs?: Vector4;
  24074. backUVs?: Vector4;
  24075. }, scene: any): Mesh;
  24076. /**
  24077. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  24078. * * 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
  24079. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  24080. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  24081. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  24082. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  24083. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  24084. * * 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
  24085. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  24086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24087. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  24088. * @param name defines the name of the new line system
  24089. * @param options defines the options used to create the line system
  24090. * @param scene defines the hosting scene
  24091. * @returns a new line system mesh
  24092. */
  24093. static CreateLineSystem(name: string, options: {
  24094. lines: Vector3[][];
  24095. updatable?: boolean;
  24096. instance?: Nullable<LinesMesh>;
  24097. colors?: Nullable<Color4[][]>;
  24098. useVertexAlpha?: boolean;
  24099. }, scene: Nullable<Scene>): LinesMesh;
  24100. /**
  24101. * Creates a line mesh
  24102. * 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
  24103. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  24104. * * The parameter `points` is an array successive Vector3
  24105. * * 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
  24106. * * The optional parameter `colors` is an array of successive Color4, one per line point
  24107. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  24108. * * When updating an instance, remember that only point positions can change, not the number of points
  24109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24110. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  24111. * @param name defines the name of the new line system
  24112. * @param options defines the options used to create the line system
  24113. * @param scene defines the hosting scene
  24114. * @returns a new line mesh
  24115. */
  24116. static CreateLines(name: string, options: {
  24117. points: Vector3[];
  24118. updatable?: boolean;
  24119. instance?: Nullable<LinesMesh>;
  24120. colors?: Color4[];
  24121. useVertexAlpha?: boolean;
  24122. }, scene?: Nullable<Scene>): LinesMesh;
  24123. /**
  24124. * Creates a dashed line mesh
  24125. * * 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
  24126. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  24127. * * The parameter `points` is an array successive Vector3
  24128. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  24129. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  24130. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24131. * * 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
  24132. * * When updating an instance, remember that only point positions can change, not the number of points
  24133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24134. * @param name defines the name of the mesh
  24135. * @param options defines the options used to create the mesh
  24136. * @param scene defines the hosting scene
  24137. * @returns the dashed line mesh
  24138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  24139. */
  24140. static CreateDashedLines(name: string, options: {
  24141. points: Vector3[];
  24142. dashSize?: number;
  24143. gapSize?: number;
  24144. dashNb?: number;
  24145. updatable?: boolean;
  24146. instance?: LinesMesh;
  24147. }, scene?: Nullable<Scene>): LinesMesh;
  24148. /**
  24149. * 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.
  24150. * * 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.
  24151. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  24152. * * 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.
  24153. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  24154. * * 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
  24155. * * 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
  24156. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  24157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24159. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  24160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24161. * @param name defines the name of the mesh
  24162. * @param options defines the options used to create the mesh
  24163. * @param scene defines the hosting scene
  24164. * @returns the extruded shape mesh
  24165. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  24166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24167. */
  24168. static ExtrudeShape(name: string, options: {
  24169. shape: Vector3[];
  24170. path: Vector3[];
  24171. scale?: number;
  24172. rotation?: number;
  24173. cap?: number;
  24174. updatable?: boolean;
  24175. sideOrientation?: number;
  24176. frontUVs?: Vector4;
  24177. backUVs?: Vector4;
  24178. instance?: Mesh;
  24179. invertUV?: boolean;
  24180. }, scene?: Nullable<Scene>): Mesh;
  24181. /**
  24182. * Creates an custom extruded shape mesh.
  24183. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  24184. * * 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.
  24185. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  24186. * * 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
  24187. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  24188. * * 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
  24189. * * It must returns a float value that will be the scale value applied to the shape on each path point
  24190. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24191. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  24192. * * 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
  24193. * * 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
  24194. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  24195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24197. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24199. * @param name defines the name of the mesh
  24200. * @param options defines the options used to create the mesh
  24201. * @param scene defines the hosting scene
  24202. * @returns the custom extruded shape mesh
  24203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  24204. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  24205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24206. */
  24207. static ExtrudeShapeCustom(name: string, options: {
  24208. shape: Vector3[];
  24209. path: Vector3[];
  24210. scaleFunction?: any;
  24211. rotationFunction?: any;
  24212. ribbonCloseArray?: boolean;
  24213. ribbonClosePath?: boolean;
  24214. cap?: number;
  24215. updatable?: boolean;
  24216. sideOrientation?: number;
  24217. frontUVs?: Vector4;
  24218. backUVs?: Vector4;
  24219. instance?: Mesh;
  24220. invertUV?: boolean;
  24221. }, scene: Scene): Mesh;
  24222. /**
  24223. * Creates lathe mesh.
  24224. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  24225. * * 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
  24226. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  24227. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  24228. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  24229. * * 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
  24230. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  24231. * * 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
  24232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24234. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24236. * @param name defines the name of the mesh
  24237. * @param options defines the options used to create the mesh
  24238. * @param scene defines the hosting scene
  24239. * @returns the lathe mesh
  24240. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  24241. */
  24242. static CreateLathe(name: string, options: {
  24243. shape: Vector3[];
  24244. radius?: number;
  24245. tessellation?: number;
  24246. clip?: number;
  24247. arc?: number;
  24248. closed?: boolean;
  24249. updatable?: boolean;
  24250. sideOrientation?: number;
  24251. frontUVs?: Vector4;
  24252. backUVs?: Vector4;
  24253. cap?: number;
  24254. invertUV?: boolean;
  24255. }, scene: Scene): Mesh;
  24256. /**
  24257. * Creates a plane mesh
  24258. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  24259. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  24260. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  24261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24264. * @param name defines the name of the mesh
  24265. * @param options defines the options used to create the mesh
  24266. * @param scene defines the hosting scene
  24267. * @returns the plane mesh
  24268. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  24269. */
  24270. static CreatePlane(name: string, options: {
  24271. size?: number;
  24272. width?: number;
  24273. height?: number;
  24274. sideOrientation?: number;
  24275. frontUVs?: Vector4;
  24276. backUVs?: Vector4;
  24277. updatable?: boolean;
  24278. sourcePlane?: Plane;
  24279. }, scene: Scene): Mesh;
  24280. /**
  24281. * Creates a ground mesh
  24282. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  24283. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  24284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24285. * @param name defines the name of the mesh
  24286. * @param options defines the options used to create the mesh
  24287. * @param scene defines the hosting scene
  24288. * @returns the ground mesh
  24289. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  24290. */
  24291. static CreateGround(name: string, options: {
  24292. width?: number;
  24293. height?: number;
  24294. subdivisions?: number;
  24295. subdivisionsX?: number;
  24296. subdivisionsY?: number;
  24297. updatable?: boolean;
  24298. }, scene: any): Mesh;
  24299. /**
  24300. * Creates a tiled ground mesh
  24301. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  24302. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  24303. * * 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
  24304. * * 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
  24305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24306. * @param name defines the name of the mesh
  24307. * @param options defines the options used to create the mesh
  24308. * @param scene defines the hosting scene
  24309. * @returns the tiled ground mesh
  24310. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  24311. */
  24312. static CreateTiledGround(name: string, options: {
  24313. xmin: number;
  24314. zmin: number;
  24315. xmax: number;
  24316. zmax: number;
  24317. subdivisions?: {
  24318. w: number;
  24319. h: number;
  24320. };
  24321. precision?: {
  24322. w: number;
  24323. h: number;
  24324. };
  24325. updatable?: boolean;
  24326. }, scene: Scene): Mesh;
  24327. /**
  24328. * Creates a ground mesh from a height map
  24329. * * The parameter `url` sets the URL of the height map image resource.
  24330. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  24331. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  24332. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  24333. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  24334. * * 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.
  24335. * * 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).
  24336. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24338. * @param name defines the name of the mesh
  24339. * @param url defines the url to the height map
  24340. * @param options defines the options used to create the mesh
  24341. * @param scene defines the hosting scene
  24342. * @returns the ground mesh
  24343. * @see https://doc.babylonjs.com/babylon101/height_map
  24344. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  24345. */
  24346. static CreateGroundFromHeightMap(name: string, url: string, options: {
  24347. width?: number;
  24348. height?: number;
  24349. subdivisions?: number;
  24350. minHeight?: number;
  24351. maxHeight?: number;
  24352. colorFilter?: Color3;
  24353. alphaFilter?: number;
  24354. updatable?: boolean;
  24355. onReady?: (mesh: GroundMesh) => void;
  24356. }, scene: Scene): GroundMesh;
  24357. /**
  24358. * Creates a polygon mesh
  24359. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  24360. * * 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
  24361. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  24364. * * Remember you can only change the shape positions, not their number when updating a polygon
  24365. * @param name defines the name of the mesh
  24366. * @param options defines the options used to create the mesh
  24367. * @param scene defines the hosting scene
  24368. * @returns the polygon mesh
  24369. */
  24370. static CreatePolygon(name: string, options: {
  24371. shape: Vector3[];
  24372. holes?: Vector3[][];
  24373. depth?: number;
  24374. faceUV?: Vector4[];
  24375. faceColors?: Color4[];
  24376. updatable?: boolean;
  24377. sideOrientation?: number;
  24378. frontUVs?: Vector4;
  24379. backUVs?: Vector4;
  24380. }, scene: Scene): Mesh;
  24381. /**
  24382. * Creates an extruded polygon mesh, with depth in the Y direction.
  24383. * * 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)
  24384. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  24385. * @param name defines the name of the mesh
  24386. * @param options defines the options used to create the mesh
  24387. * @param scene defines the hosting scene
  24388. * @returns the polygon mesh
  24389. */
  24390. static ExtrudePolygon(name: string, options: {
  24391. shape: Vector3[];
  24392. holes?: Vector3[][];
  24393. depth?: number;
  24394. faceUV?: Vector4[];
  24395. faceColors?: Color4[];
  24396. updatable?: boolean;
  24397. sideOrientation?: number;
  24398. frontUVs?: Vector4;
  24399. backUVs?: Vector4;
  24400. }, scene: Scene): Mesh;
  24401. /**
  24402. * Creates a tube mesh.
  24403. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  24404. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  24405. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  24406. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  24407. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  24408. * * 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)
  24409. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  24410. * * 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
  24411. * * 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
  24412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24414. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24416. * @param name defines the name of the mesh
  24417. * @param options defines the options used to create the mesh
  24418. * @param scene defines the hosting scene
  24419. * @returns the tube mesh
  24420. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  24421. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  24422. */
  24423. static CreateTube(name: string, options: {
  24424. path: Vector3[];
  24425. radius?: number;
  24426. tessellation?: number;
  24427. radiusFunction?: {
  24428. (i: number, distance: number): number;
  24429. };
  24430. cap?: number;
  24431. arc?: number;
  24432. updatable?: boolean;
  24433. sideOrientation?: number;
  24434. frontUVs?: Vector4;
  24435. backUVs?: Vector4;
  24436. instance?: Mesh;
  24437. invertUV?: boolean;
  24438. }, scene: Scene): Mesh;
  24439. /**
  24440. * Creates a polyhedron mesh
  24441. * * 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
  24442. * * The parameter `size` (positive float, default 1) sets the polygon size
  24443. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24444. * * 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`
  24445. * * 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
  24446. * * 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)`)
  24447. * * 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
  24448. * * 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
  24449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24452. * @param name defines the name of the mesh
  24453. * @param options defines the options used to create the mesh
  24454. * @param scene defines the hosting scene
  24455. * @returns the polyhedron mesh
  24456. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  24457. */
  24458. static CreatePolyhedron(name: string, options: {
  24459. type?: number;
  24460. size?: number;
  24461. sizeX?: number;
  24462. sizeY?: number;
  24463. sizeZ?: number;
  24464. custom?: any;
  24465. faceUV?: Vector4[];
  24466. faceColors?: Color4[];
  24467. flat?: boolean;
  24468. updatable?: boolean;
  24469. sideOrientation?: number;
  24470. frontUVs?: Vector4;
  24471. backUVs?: Vector4;
  24472. }, scene: Scene): Mesh;
  24473. /**
  24474. * Creates a decal mesh.
  24475. * 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
  24476. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  24477. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  24478. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  24479. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  24480. * @param name defines the name of the mesh
  24481. * @param sourceMesh defines the mesh where the decal must be applied
  24482. * @param options defines the options used to create the mesh
  24483. * @param scene defines the hosting scene
  24484. * @returns the decal mesh
  24485. * @see https://doc.babylonjs.com/how_to/decals
  24486. */
  24487. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  24488. position?: Vector3;
  24489. normal?: Vector3;
  24490. size?: Vector3;
  24491. angle?: number;
  24492. }): Mesh;
  24493. private static _ExtrudeShapeGeneric;
  24494. }
  24495. }
  24496. declare module "babylonjs/Particles/solidParticleSystem" {
  24497. import { Vector3 } from "babylonjs/Maths/math";
  24498. import { Mesh } from "babylonjs/Meshes/mesh";
  24499. import { Scene, IDisposable } from "babylonjs/scene";
  24500. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24501. /**
  24502. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24503. *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.
  24504. * The SPS is also a particle system. It provides some methods to manage the particles.
  24505. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24506. *
  24507. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24508. */
  24509. export class SolidParticleSystem implements IDisposable {
  24510. /**
  24511. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24512. * Example : var p = SPS.particles[i];
  24513. */
  24514. particles: SolidParticle[];
  24515. /**
  24516. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24517. */
  24518. nbParticles: number;
  24519. /**
  24520. * If the particles must ever face the camera (default false). Useful for planar particles.
  24521. */
  24522. billboard: boolean;
  24523. /**
  24524. * Recompute normals when adding a shape
  24525. */
  24526. recomputeNormals: boolean;
  24527. /**
  24528. * This a counter ofr your own usage. It's not set by any SPS functions.
  24529. */
  24530. counter: number;
  24531. /**
  24532. * The SPS name. This name is also given to the underlying mesh.
  24533. */
  24534. name: string;
  24535. /**
  24536. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24537. */
  24538. mesh: Mesh;
  24539. /**
  24540. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24541. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24542. */
  24543. vars: any;
  24544. /**
  24545. * This array is populated when the SPS is set as 'pickable'.
  24546. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24547. * Each element of this array is an object `{idx: int, faceId: int}`.
  24548. * `idx` is the picked particle index in the `SPS.particles` array
  24549. * `faceId` is the picked face index counted within this particle.
  24550. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24551. */
  24552. pickedParticles: {
  24553. idx: number;
  24554. faceId: number;
  24555. }[];
  24556. /**
  24557. * This array is populated when `enableDepthSort` is set to true.
  24558. * Each element of this array is an instance of the class DepthSortedParticle.
  24559. */
  24560. depthSortedParticles: DepthSortedParticle[];
  24561. /**
  24562. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24563. * @hidden
  24564. */
  24565. _bSphereOnly: boolean;
  24566. /**
  24567. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24568. * @hidden
  24569. */
  24570. _bSphereRadiusFactor: number;
  24571. private _scene;
  24572. private _positions;
  24573. private _indices;
  24574. private _normals;
  24575. private _colors;
  24576. private _uvs;
  24577. private _indices32;
  24578. private _positions32;
  24579. private _normals32;
  24580. private _fixedNormal32;
  24581. private _colors32;
  24582. private _uvs32;
  24583. private _index;
  24584. private _updatable;
  24585. private _pickable;
  24586. private _isVisibilityBoxLocked;
  24587. private _alwaysVisible;
  24588. private _depthSort;
  24589. private _shapeCounter;
  24590. private _copy;
  24591. private _color;
  24592. private _computeParticleColor;
  24593. private _computeParticleTexture;
  24594. private _computeParticleRotation;
  24595. private _computeParticleVertex;
  24596. private _computeBoundingBox;
  24597. private _depthSortParticles;
  24598. private _camera;
  24599. private _mustUnrotateFixedNormals;
  24600. private _particlesIntersect;
  24601. private _needs32Bits;
  24602. /**
  24603. * Creates a SPS (Solid Particle System) object.
  24604. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24605. * @param scene (Scene) is the scene in which the SPS is added.
  24606. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24607. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24608. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24609. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24610. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24611. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24612. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24613. */
  24614. constructor(name: string, scene: Scene, options?: {
  24615. updatable?: boolean;
  24616. isPickable?: boolean;
  24617. enableDepthSort?: boolean;
  24618. particleIntersection?: boolean;
  24619. boundingSphereOnly?: boolean;
  24620. bSphereRadiusFactor?: number;
  24621. });
  24622. /**
  24623. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24624. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24625. * @returns the created mesh
  24626. */
  24627. buildMesh(): Mesh;
  24628. /**
  24629. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24630. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24631. * Thus the particles generated from `digest()` have their property `position` set yet.
  24632. * @param mesh ( Mesh ) is the mesh to be digested
  24633. * @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
  24634. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24635. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24636. * @returns the current SPS
  24637. */
  24638. digest(mesh: Mesh, options?: {
  24639. facetNb?: number;
  24640. number?: number;
  24641. delta?: number;
  24642. }): SolidParticleSystem;
  24643. private _unrotateFixedNormals;
  24644. private _resetCopy;
  24645. private _meshBuilder;
  24646. private _posToShape;
  24647. private _uvsToShapeUV;
  24648. private _addParticle;
  24649. /**
  24650. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24651. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24652. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24653. * @param nb (positive integer) the number of particles to be created from this model
  24654. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24655. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24656. * @returns the number of shapes in the system
  24657. */
  24658. addShape(mesh: Mesh, nb: number, options?: {
  24659. positionFunction?: any;
  24660. vertexFunction?: any;
  24661. }): number;
  24662. private _rebuildParticle;
  24663. /**
  24664. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24665. * @returns the SPS.
  24666. */
  24667. rebuildMesh(): SolidParticleSystem;
  24668. /**
  24669. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24670. * This method calls `updateParticle()` for each particle of the SPS.
  24671. * For an animated SPS, it is usually called within the render loop.
  24672. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24673. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24674. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24675. * @returns the SPS.
  24676. */
  24677. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24678. /**
  24679. * Disposes the SPS.
  24680. */
  24681. dispose(): void;
  24682. /**
  24683. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24684. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24685. * @returns the SPS.
  24686. */
  24687. refreshVisibleSize(): SolidParticleSystem;
  24688. /**
  24689. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24690. * @param size the size (float) of the visibility box
  24691. * note : this doesn't lock the SPS mesh bounding box.
  24692. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24693. */
  24694. setVisibilityBox(size: number): void;
  24695. /**
  24696. * Gets whether the SPS as always visible or not
  24697. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24698. */
  24699. /**
  24700. * Sets the SPS as always visible or not
  24701. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24702. */
  24703. isAlwaysVisible: boolean;
  24704. /**
  24705. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24706. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24707. */
  24708. /**
  24709. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24710. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24711. */
  24712. isVisibilityBoxLocked: boolean;
  24713. /**
  24714. * Tells to `setParticles()` to compute the particle rotations or not.
  24715. * Default value : true. The SPS is faster when it's set to false.
  24716. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24717. */
  24718. /**
  24719. * Gets if `setParticles()` computes the particle rotations or not.
  24720. * Default value : true. The SPS is faster when it's set to false.
  24721. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24722. */
  24723. computeParticleRotation: boolean;
  24724. /**
  24725. * Tells to `setParticles()` to compute the particle colors or not.
  24726. * Default value : true. The SPS is faster when it's set to false.
  24727. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24728. */
  24729. /**
  24730. * Gets if `setParticles()` computes the particle colors or not.
  24731. * Default value : true. The SPS is faster when it's set to false.
  24732. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24733. */
  24734. computeParticleColor: boolean;
  24735. /**
  24736. * Gets if `setParticles()` computes the particle textures or not.
  24737. * Default value : true. The SPS is faster when it's set to false.
  24738. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24739. */
  24740. computeParticleTexture: boolean;
  24741. /**
  24742. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24743. * Default value : false. The SPS is faster when it's set to false.
  24744. * Note : the particle custom vertex positions aren't stored values.
  24745. */
  24746. /**
  24747. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24748. * Default value : false. The SPS is faster when it's set to false.
  24749. * Note : the particle custom vertex positions aren't stored values.
  24750. */
  24751. computeParticleVertex: boolean;
  24752. /**
  24753. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24754. */
  24755. /**
  24756. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24757. */
  24758. computeBoundingBox: boolean;
  24759. /**
  24760. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24761. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24762. * Default : `true`
  24763. */
  24764. /**
  24765. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24766. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24767. * Default : `true`
  24768. */
  24769. depthSortParticles: boolean;
  24770. /**
  24771. * This function does nothing. It may be overwritten to set all the particle first values.
  24772. * The SPS doesn't call this function, you may have to call it by your own.
  24773. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24774. */
  24775. initParticles(): void;
  24776. /**
  24777. * This function does nothing. It may be overwritten to recycle a particle.
  24778. * The SPS doesn't call this function, you may have to call it by your own.
  24779. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24780. * @param particle The particle to recycle
  24781. * @returns the recycled particle
  24782. */
  24783. recycleParticle(particle: SolidParticle): SolidParticle;
  24784. /**
  24785. * Updates a particle : this function should be overwritten by the user.
  24786. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24787. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24788. * @example : just set a particle position or velocity and recycle conditions
  24789. * @param particle The particle to update
  24790. * @returns the updated particle
  24791. */
  24792. updateParticle(particle: SolidParticle): SolidParticle;
  24793. /**
  24794. * Updates a vertex of a particle : it can be overwritten by the user.
  24795. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24796. * @param particle the current particle
  24797. * @param vertex the current index of the current particle
  24798. * @param pt the index of the current vertex in the particle shape
  24799. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24800. * @example : just set a vertex particle position
  24801. * @returns the updated vertex
  24802. */
  24803. updateParticleVertex(vertex: Vector3): Vector3;
  24804. /**
  24805. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24806. * This does nothing and may be overwritten by the user.
  24807. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24808. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24809. * @param update the boolean update value actually passed to setParticles()
  24810. */
  24811. beforeUpdateParticles(): void;
  24812. /**
  24813. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24814. * This will be passed three parameters.
  24815. * This does nothing and may be overwritten by the user.
  24816. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24817. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24818. * @param update the boolean update value actually passed to setParticles()
  24819. */
  24820. afterUpdateParticles(): void;
  24821. }
  24822. }
  24823. declare module "babylonjs/Particles/solidParticle" {
  24824. import { Nullable } from "babylonjs/types";
  24825. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24826. import { Mesh } from "babylonjs/Meshes/mesh";
  24827. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24828. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24829. /**
  24830. * Represents one particle of a solid particle system.
  24831. */
  24832. export class SolidParticle {
  24833. /**
  24834. * particle global index
  24835. */
  24836. idx: number;
  24837. /**
  24838. * The color of the particle
  24839. */
  24840. color: Nullable<Color4>;
  24841. /**
  24842. * The world space position of the particle.
  24843. */
  24844. position: Vector3;
  24845. /**
  24846. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24847. */
  24848. rotation: Vector3;
  24849. /**
  24850. * The world space rotation quaternion of the particle.
  24851. */
  24852. rotationQuaternion: Nullable<Quaternion>;
  24853. /**
  24854. * The scaling of the particle.
  24855. */
  24856. scaling: Vector3;
  24857. /**
  24858. * The uvs of the particle.
  24859. */
  24860. uvs: Vector4;
  24861. /**
  24862. * The current speed of the particle.
  24863. */
  24864. velocity: Vector3;
  24865. /**
  24866. * The pivot point in the particle local space.
  24867. */
  24868. pivot: Vector3;
  24869. /**
  24870. * Must the particle be translated from its pivot point in its local space ?
  24871. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24872. * Default : false
  24873. */
  24874. translateFromPivot: boolean;
  24875. /**
  24876. * Is the particle active or not ?
  24877. */
  24878. alive: boolean;
  24879. /**
  24880. * Is the particle visible or not ?
  24881. */
  24882. isVisible: boolean;
  24883. /**
  24884. * Index of this particle in the global "positions" array (Internal use)
  24885. * @hidden
  24886. */
  24887. _pos: number;
  24888. /**
  24889. * @hidden Index of this particle in the global "indices" array (Internal use)
  24890. */
  24891. _ind: number;
  24892. /**
  24893. * @hidden ModelShape of this particle (Internal use)
  24894. */
  24895. _model: ModelShape;
  24896. /**
  24897. * ModelShape id of this particle
  24898. */
  24899. shapeId: number;
  24900. /**
  24901. * Index of the particle in its shape id (Internal use)
  24902. */
  24903. idxInShape: number;
  24904. /**
  24905. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24906. */
  24907. _modelBoundingInfo: BoundingInfo;
  24908. /**
  24909. * @hidden Particle BoundingInfo object (Internal use)
  24910. */
  24911. _boundingInfo: BoundingInfo;
  24912. /**
  24913. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24914. */
  24915. _sps: SolidParticleSystem;
  24916. /**
  24917. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24918. */
  24919. _stillInvisible: boolean;
  24920. /**
  24921. * @hidden Last computed particle rotation matrix
  24922. */
  24923. _rotationMatrix: number[];
  24924. /**
  24925. * Parent particle Id, if any.
  24926. * Default null.
  24927. */
  24928. parentId: Nullable<number>;
  24929. /**
  24930. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24931. * The possible values are :
  24932. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24933. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24934. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24935. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24936. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24937. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24938. * */
  24939. cullingStrategy: number;
  24940. /**
  24941. * @hidden Internal global position in the SPS.
  24942. */
  24943. _globalPosition: Vector3;
  24944. /**
  24945. * Creates a Solid Particle object.
  24946. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24947. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24948. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24949. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24950. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24951. * @param shapeId (integer) is the model shape identifier in the SPS.
  24952. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24953. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24954. */
  24955. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24956. /**
  24957. * Legacy support, changed scale to scaling
  24958. */
  24959. /**
  24960. * Legacy support, changed scale to scaling
  24961. */
  24962. scale: Vector3;
  24963. /**
  24964. * Legacy support, changed quaternion to rotationQuaternion
  24965. */
  24966. /**
  24967. * Legacy support, changed quaternion to rotationQuaternion
  24968. */
  24969. quaternion: Nullable<Quaternion>;
  24970. /**
  24971. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24972. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24973. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24974. * @returns true if it intersects
  24975. */
  24976. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24977. /**
  24978. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24979. * A particle is in the frustum if its bounding box intersects the frustum
  24980. * @param frustumPlanes defines the frustum to test
  24981. * @returns true if the particle is in the frustum planes
  24982. */
  24983. isInFrustum(frustumPlanes: Plane[]): boolean;
  24984. /**
  24985. * get the rotation matrix of the particle
  24986. * @hidden
  24987. */
  24988. getRotationMatrix(m: Matrix): void;
  24989. }
  24990. /**
  24991. * Represents the shape of the model used by one particle of a solid particle system.
  24992. * SPS internal tool, don't use it manually.
  24993. */
  24994. export class ModelShape {
  24995. /**
  24996. * The shape id
  24997. * @hidden
  24998. */
  24999. shapeID: number;
  25000. /**
  25001. * flat array of model positions (internal use)
  25002. * @hidden
  25003. */
  25004. _shape: Vector3[];
  25005. /**
  25006. * flat array of model UVs (internal use)
  25007. * @hidden
  25008. */
  25009. _shapeUV: number[];
  25010. /**
  25011. * length of the shape in the model indices array (internal use)
  25012. * @hidden
  25013. */
  25014. _indicesLength: number;
  25015. /**
  25016. * Custom position function (internal use)
  25017. * @hidden
  25018. */
  25019. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25020. /**
  25021. * Custom vertex function (internal use)
  25022. * @hidden
  25023. */
  25024. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25025. /**
  25026. * 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.
  25027. * SPS internal tool, don't use it manually.
  25028. * @hidden
  25029. */
  25030. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25031. }
  25032. /**
  25033. * Represents a Depth Sorted Particle in the solid particle system.
  25034. */
  25035. export class DepthSortedParticle {
  25036. /**
  25037. * Index of the particle in the "indices" array
  25038. */
  25039. ind: number;
  25040. /**
  25041. * Length of the particle shape in the "indices" array
  25042. */
  25043. indicesLength: number;
  25044. /**
  25045. * Squared distance from the particle to the camera
  25046. */
  25047. sqDistance: number;
  25048. }
  25049. }
  25050. declare module "babylonjs/Meshes/abstractMesh" {
  25051. import { Observable } from "babylonjs/Misc/observable";
  25052. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25053. import { Camera } from "babylonjs/Cameras/camera";
  25054. import { Scene, IDisposable } from "babylonjs/scene";
  25055. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25056. import { Node } from "babylonjs/node";
  25057. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25058. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25059. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25060. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25061. import { Collider } from "babylonjs/Collisions/collider";
  25062. import { Ray } from "babylonjs/Culling/ray";
  25063. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25064. import { Material } from "babylonjs/Materials/material";
  25065. import { Light } from "babylonjs/Lights/light";
  25066. import { ActionManager } from "babylonjs/Actions/actionManager";
  25067. import { Skeleton } from "babylonjs/Bones/skeleton";
  25068. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25069. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25070. /**
  25071. * Class used to store all common mesh properties
  25072. */
  25073. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25074. /** No occlusion */
  25075. static OCCLUSION_TYPE_NONE: number;
  25076. /** Occlusion set to optimisitic */
  25077. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25078. /** Occlusion set to strict */
  25079. static OCCLUSION_TYPE_STRICT: number;
  25080. /** Use an accurante occlusion algorithm */
  25081. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25082. /** Use a conservative occlusion algorithm */
  25083. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25084. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25085. * Test order :
  25086. * Is the bounding sphere outside the frustum ?
  25087. * If not, are the bounding box vertices outside the frustum ?
  25088. * It not, then the cullable object is in the frustum.
  25089. */
  25090. static readonly CULLINGSTRATEGY_STANDARD: number;
  25091. /** Culling strategy : Bounding Sphere Only.
  25092. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25093. * It's also less accurate than the standard because some not visible objects can still be selected.
  25094. * Test : is the bounding sphere outside the frustum ?
  25095. * If not, then the cullable object is in the frustum.
  25096. */
  25097. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25098. /** Culling strategy : Optimistic Inclusion.
  25099. * This in an inclusion test first, then the standard exclusion test.
  25100. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25101. * 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.
  25102. * Anyway, it's as accurate as the standard strategy.
  25103. * Test :
  25104. * Is the cullable object bounding sphere center in the frustum ?
  25105. * If not, apply the default culling strategy.
  25106. */
  25107. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25108. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25109. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25110. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25111. * 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.
  25112. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25113. * Test :
  25114. * Is the cullable object bounding sphere center in the frustum ?
  25115. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25116. */
  25117. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25118. /**
  25119. * No billboard
  25120. */
  25121. static readonly BILLBOARDMODE_NONE: number;
  25122. /** Billboard on X axis */
  25123. static readonly BILLBOARDMODE_X: number;
  25124. /** Billboard on Y axis */
  25125. static readonly BILLBOARDMODE_Y: number;
  25126. /** Billboard on Z axis */
  25127. static readonly BILLBOARDMODE_Z: number;
  25128. /** Billboard on all axes */
  25129. static readonly BILLBOARDMODE_ALL: number;
  25130. private _facetData;
  25131. /**
  25132. * The culling strategy to use to check whether the mesh must be rendered or not.
  25133. * This value can be changed at any time and will be used on the next render mesh selection.
  25134. * The possible values are :
  25135. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25136. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25137. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25138. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25139. * Please read each static variable documentation to get details about the culling process.
  25140. * */
  25141. cullingStrategy: number;
  25142. /**
  25143. * Gets the number of facets in the mesh
  25144. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25145. */
  25146. readonly facetNb: number;
  25147. /**
  25148. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25150. */
  25151. partitioningSubdivisions: number;
  25152. /**
  25153. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25154. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25155. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25156. */
  25157. partitioningBBoxRatio: number;
  25158. /**
  25159. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25160. * Works only for updatable meshes.
  25161. * Doesn't work with multi-materials
  25162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25163. */
  25164. mustDepthSortFacets: boolean;
  25165. /**
  25166. * The location (Vector3) where the facet depth sort must be computed from.
  25167. * By default, the active camera position.
  25168. * Used only when facet depth sort is enabled
  25169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25170. */
  25171. facetDepthSortFrom: Vector3;
  25172. /**
  25173. * gets a boolean indicating if facetData is enabled
  25174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25175. */
  25176. readonly isFacetDataEnabled: boolean;
  25177. /** @hidden */
  25178. _updateNonUniformScalingState(value: boolean): boolean;
  25179. /**
  25180. * An event triggered when this mesh collides with another one
  25181. */
  25182. onCollideObservable: Observable<AbstractMesh>;
  25183. private _onCollideObserver;
  25184. /** Set a function to call when this mesh collides with another one */
  25185. onCollide: () => void;
  25186. /**
  25187. * An event triggered when the collision's position changes
  25188. */
  25189. onCollisionPositionChangeObservable: Observable<Vector3>;
  25190. private _onCollisionPositionChangeObserver;
  25191. /** Set a function to call when the collision's position changes */
  25192. onCollisionPositionChange: () => void;
  25193. /**
  25194. * An event triggered when material is changed
  25195. */
  25196. onMaterialChangedObservable: Observable<AbstractMesh>;
  25197. /**
  25198. * Gets or sets the orientation for POV movement & rotation
  25199. */
  25200. definedFacingForward: boolean;
  25201. /** @hidden */
  25202. _occlusionQuery: Nullable<WebGLQuery>;
  25203. private _visibility;
  25204. /**
  25205. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25206. */
  25207. /**
  25208. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25209. */
  25210. visibility: number;
  25211. /** Gets or sets the alpha index used to sort transparent meshes
  25212. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25213. */
  25214. alphaIndex: number;
  25215. /**
  25216. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25217. */
  25218. isVisible: boolean;
  25219. /**
  25220. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25221. */
  25222. isPickable: boolean;
  25223. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25224. showSubMeshesBoundingBox: boolean;
  25225. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25226. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25227. */
  25228. isBlocker: boolean;
  25229. /**
  25230. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25231. */
  25232. enablePointerMoveEvents: boolean;
  25233. /**
  25234. * Specifies the rendering group id for this mesh (0 by default)
  25235. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25236. */
  25237. renderingGroupId: number;
  25238. private _material;
  25239. /** Gets or sets current material */
  25240. material: Nullable<Material>;
  25241. private _receiveShadows;
  25242. /**
  25243. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25244. * @see http://doc.babylonjs.com/babylon101/shadows
  25245. */
  25246. receiveShadows: boolean;
  25247. /** Defines color to use when rendering outline */
  25248. outlineColor: Color3;
  25249. /** Define width to use when rendering outline */
  25250. outlineWidth: number;
  25251. /** Defines color to use when rendering overlay */
  25252. overlayColor: Color3;
  25253. /** Defines alpha to use when rendering overlay */
  25254. overlayAlpha: number;
  25255. private _hasVertexAlpha;
  25256. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25257. hasVertexAlpha: boolean;
  25258. private _useVertexColors;
  25259. /** 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) */
  25260. useVertexColors: boolean;
  25261. private _computeBonesUsingShaders;
  25262. /**
  25263. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25264. */
  25265. computeBonesUsingShaders: boolean;
  25266. private _numBoneInfluencers;
  25267. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25268. numBoneInfluencers: number;
  25269. private _applyFog;
  25270. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25271. applyFog: boolean;
  25272. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25273. useOctreeForRenderingSelection: boolean;
  25274. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25275. useOctreeForPicking: boolean;
  25276. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25277. useOctreeForCollisions: boolean;
  25278. private _layerMask;
  25279. /**
  25280. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25281. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25282. */
  25283. layerMask: number;
  25284. /**
  25285. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25286. */
  25287. alwaysSelectAsActiveMesh: boolean;
  25288. /**
  25289. * Gets or sets the current action manager
  25290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25291. */
  25292. actionManager: Nullable<ActionManager>;
  25293. private _checkCollisions;
  25294. private _collisionMask;
  25295. private _collisionGroup;
  25296. /**
  25297. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25298. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25299. */
  25300. ellipsoid: Vector3;
  25301. /**
  25302. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25303. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25304. */
  25305. ellipsoidOffset: Vector3;
  25306. private _collider;
  25307. private _oldPositionForCollisions;
  25308. private _diffPositionForCollisions;
  25309. /**
  25310. * Gets or sets a collision mask used to mask collisions (default is -1).
  25311. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25312. */
  25313. collisionMask: number;
  25314. /**
  25315. * Gets or sets the current collision group mask (-1 by default).
  25316. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25317. */
  25318. collisionGroup: number;
  25319. /**
  25320. * Defines edge width used when edgesRenderer is enabled
  25321. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25322. */
  25323. edgesWidth: number;
  25324. /**
  25325. * Defines edge color used when edgesRenderer is enabled
  25326. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25327. */
  25328. edgesColor: Color4;
  25329. /** @hidden */
  25330. _edgesRenderer: Nullable<IEdgesRenderer>;
  25331. /** @hidden */
  25332. _masterMesh: Nullable<AbstractMesh>;
  25333. /** @hidden */
  25334. _boundingInfo: Nullable<BoundingInfo>;
  25335. /** @hidden */
  25336. _renderId: number;
  25337. /**
  25338. * Gets or sets the list of subMeshes
  25339. * @see http://doc.babylonjs.com/how_to/multi_materials
  25340. */
  25341. subMeshes: SubMesh[];
  25342. /** @hidden */
  25343. _intersectionsInProgress: AbstractMesh[];
  25344. /** @hidden */
  25345. _unIndexed: boolean;
  25346. /** @hidden */
  25347. _lightSources: Light[];
  25348. /** @hidden */
  25349. readonly _positions: Nullable<Vector3[]>;
  25350. /** @hidden */
  25351. _waitingActions: any;
  25352. /** @hidden */
  25353. _waitingFreezeWorldMatrix: Nullable<boolean>;
  25354. private _skeleton;
  25355. /** @hidden */
  25356. _bonesTransformMatrices: Nullable<Float32Array>;
  25357. /**
  25358. * Gets or sets a skeleton to apply skining transformations
  25359. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25360. */
  25361. skeleton: Nullable<Skeleton>;
  25362. /**
  25363. * An event triggered when the mesh is rebuilt.
  25364. */
  25365. onRebuildObservable: Observable<AbstractMesh>;
  25366. /**
  25367. * Creates a new AbstractMesh
  25368. * @param name defines the name of the mesh
  25369. * @param scene defines the hosting scene
  25370. */
  25371. constructor(name: string, scene?: Nullable<Scene>);
  25372. /**
  25373. * Returns the string "AbstractMesh"
  25374. * @returns "AbstractMesh"
  25375. */
  25376. getClassName(): string;
  25377. /**
  25378. * Gets a string representation of the current mesh
  25379. * @param fullDetails defines a boolean indicating if full details must be included
  25380. * @returns a string representation of the current mesh
  25381. */
  25382. toString(fullDetails?: boolean): string;
  25383. /** @hidden */
  25384. _rebuild(): void;
  25385. /** @hidden */
  25386. _resyncLightSources(): void;
  25387. /** @hidden */
  25388. _resyncLighSource(light: Light): void;
  25389. /** @hidden */
  25390. _unBindEffect(): void;
  25391. /** @hidden */
  25392. _removeLightSource(light: Light): void;
  25393. private _markSubMeshesAsDirty;
  25394. /** @hidden */
  25395. _markSubMeshesAsLightDirty(): void;
  25396. /** @hidden */
  25397. _markSubMeshesAsAttributesDirty(): void;
  25398. /** @hidden */
  25399. _markSubMeshesAsMiscDirty(): void;
  25400. /**
  25401. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25402. */
  25403. scaling: Vector3;
  25404. /**
  25405. * Returns true if the mesh is blocked. Implemented by child classes
  25406. */
  25407. readonly isBlocked: boolean;
  25408. /**
  25409. * Returns the mesh itself by default. Implemented by child classes
  25410. * @param camera defines the camera to use to pick the right LOD level
  25411. * @returns the currentAbstractMesh
  25412. */
  25413. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25414. /**
  25415. * Returns 0 by default. Implemented by child classes
  25416. * @returns an integer
  25417. */
  25418. getTotalVertices(): number;
  25419. /**
  25420. * Returns a positive integer : the total number of indices in this mesh geometry.
  25421. * @returns the numner of indices or zero if the mesh has no geometry.
  25422. */
  25423. getTotalIndices(): number;
  25424. /**
  25425. * Returns null by default. Implemented by child classes
  25426. * @returns null
  25427. */
  25428. getIndices(): Nullable<IndicesArray>;
  25429. /**
  25430. * Returns the array of the requested vertex data kind. Implemented by child classes
  25431. * @param kind defines the vertex data kind to use
  25432. * @returns null
  25433. */
  25434. getVerticesData(kind: string): Nullable<FloatArray>;
  25435. /**
  25436. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25437. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25438. * Note that a new underlying VertexBuffer object is created each call.
  25439. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25440. * @param kind defines vertex data kind:
  25441. * * VertexBuffer.PositionKind
  25442. * * VertexBuffer.UVKind
  25443. * * VertexBuffer.UV2Kind
  25444. * * VertexBuffer.UV3Kind
  25445. * * VertexBuffer.UV4Kind
  25446. * * VertexBuffer.UV5Kind
  25447. * * VertexBuffer.UV6Kind
  25448. * * VertexBuffer.ColorKind
  25449. * * VertexBuffer.MatricesIndicesKind
  25450. * * VertexBuffer.MatricesIndicesExtraKind
  25451. * * VertexBuffer.MatricesWeightsKind
  25452. * * VertexBuffer.MatricesWeightsExtraKind
  25453. * @param data defines the data source
  25454. * @param updatable defines if the data must be flagged as updatable (or static)
  25455. * @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
  25456. * @returns the current mesh
  25457. */
  25458. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25459. /**
  25460. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25461. * If the mesh has no geometry, it is simply returned as it is.
  25462. * @param kind defines vertex data kind:
  25463. * * VertexBuffer.PositionKind
  25464. * * VertexBuffer.UVKind
  25465. * * VertexBuffer.UV2Kind
  25466. * * VertexBuffer.UV3Kind
  25467. * * VertexBuffer.UV4Kind
  25468. * * VertexBuffer.UV5Kind
  25469. * * VertexBuffer.UV6Kind
  25470. * * VertexBuffer.ColorKind
  25471. * * VertexBuffer.MatricesIndicesKind
  25472. * * VertexBuffer.MatricesIndicesExtraKind
  25473. * * VertexBuffer.MatricesWeightsKind
  25474. * * VertexBuffer.MatricesWeightsExtraKind
  25475. * @param data defines the data source
  25476. * @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
  25477. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25478. * @returns the current mesh
  25479. */
  25480. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25481. /**
  25482. * Sets the mesh indices,
  25483. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25484. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25485. * @param totalVertices Defines the total number of vertices
  25486. * @returns the current mesh
  25487. */
  25488. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25489. /**
  25490. * Gets a boolean indicating if specific vertex data is present
  25491. * @param kind defines the vertex data kind to use
  25492. * @returns true is data kind is present
  25493. */
  25494. isVerticesDataPresent(kind: string): boolean;
  25495. /**
  25496. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25497. * @returns a BoundingInfo
  25498. */
  25499. getBoundingInfo(): BoundingInfo;
  25500. /**
  25501. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25502. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  25503. * @returns the current mesh
  25504. */
  25505. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  25506. /**
  25507. * Overwrite the current bounding info
  25508. * @param boundingInfo defines the new bounding info
  25509. * @returns the current mesh
  25510. */
  25511. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25512. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25513. readonly useBones: boolean;
  25514. /** @hidden */
  25515. _preActivate(): void;
  25516. /** @hidden */
  25517. _preActivateForIntermediateRendering(renderId: number): void;
  25518. /** @hidden */
  25519. _activate(renderId: number): void;
  25520. /**
  25521. * Gets the current world matrix
  25522. * @returns a Matrix
  25523. */
  25524. getWorldMatrix(): Matrix;
  25525. /** @hidden */
  25526. _getWorldMatrixDeterminant(): number;
  25527. /**
  25528. * Perform relative position change from the point of view of behind the front of the mesh.
  25529. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25530. * Supports definition of mesh facing forward or backward
  25531. * @param amountRight defines the distance on the right axis
  25532. * @param amountUp defines the distance on the up axis
  25533. * @param amountForward defines the distance on the forward axis
  25534. * @returns the current mesh
  25535. */
  25536. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25537. /**
  25538. * Calculate relative position change from the point of view of behind the front of the mesh.
  25539. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25540. * Supports definition of mesh facing forward or backward
  25541. * @param amountRight defines the distance on the right axis
  25542. * @param amountUp defines the distance on the up axis
  25543. * @param amountForward defines the distance on the forward axis
  25544. * @returns the new displacement vector
  25545. */
  25546. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25547. /**
  25548. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25549. * Supports definition of mesh facing forward or backward
  25550. * @param flipBack defines the flip
  25551. * @param twirlClockwise defines the twirl
  25552. * @param tiltRight defines the tilt
  25553. * @returns the current mesh
  25554. */
  25555. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25556. /**
  25557. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25558. * Supports definition of mesh facing forward or backward.
  25559. * @param flipBack defines the flip
  25560. * @param twirlClockwise defines the twirl
  25561. * @param tiltRight defines the tilt
  25562. * @returns the new rotation vector
  25563. */
  25564. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25565. /**
  25566. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  25567. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25568. * @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
  25569. * @returns the new bounding vectors
  25570. */
  25571. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25572. min: Vector3;
  25573. max: Vector3;
  25574. };
  25575. /**
  25576. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25577. * This means the mesh underlying bounding box and sphere are recomputed.
  25578. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25579. * @returns the current mesh
  25580. */
  25581. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25582. /** @hidden */
  25583. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25584. /** @hidden */
  25585. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25586. /** @hidden */
  25587. _updateBoundingInfo(): AbstractMesh;
  25588. /** @hidden */
  25589. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25590. /** @hidden */
  25591. protected _afterComputeWorldMatrix(): void;
  25592. /**
  25593. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25594. * A mesh is in the frustum if its bounding box intersects the frustum
  25595. * @param frustumPlanes defines the frustum to test
  25596. * @returns true if the mesh is in the frustum planes
  25597. */
  25598. isInFrustum(frustumPlanes: Plane[]): boolean;
  25599. /**
  25600. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25601. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25602. * @param frustumPlanes defines the frustum to test
  25603. * @returns true if the mesh is completely in the frustum planes
  25604. */
  25605. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25606. /**
  25607. * True if the mesh intersects another mesh or a SolidParticle object
  25608. * @param mesh defines a target mesh or SolidParticle to test
  25609. * @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)
  25610. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25611. * @returns true if there is an intersection
  25612. */
  25613. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25614. /**
  25615. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25616. * @param point defines the point to test
  25617. * @returns true if there is an intersection
  25618. */
  25619. intersectsPoint(point: Vector3): boolean;
  25620. /**
  25621. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25622. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25623. */
  25624. checkCollisions: boolean;
  25625. /**
  25626. * Gets Collider object used to compute collisions (not physics)
  25627. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25628. */
  25629. readonly collider: Collider;
  25630. /**
  25631. * Move the mesh using collision engine
  25632. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25633. * @param displacement defines the requested displacement vector
  25634. * @returns the current mesh
  25635. */
  25636. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25637. private _onCollisionPositionChange;
  25638. /** @hidden */
  25639. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25640. /** @hidden */
  25641. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25642. /** @hidden */
  25643. _checkCollision(collider: Collider): AbstractMesh;
  25644. /** @hidden */
  25645. _generatePointsArray(): boolean;
  25646. /**
  25647. * Checks if the passed Ray intersects with the mesh
  25648. * @param ray defines the ray to use
  25649. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25650. * @returns the picking info
  25651. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25652. */
  25653. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  25654. /**
  25655. * Clones the current mesh
  25656. * @param name defines the mesh name
  25657. * @param newParent defines the new mesh parent
  25658. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25659. * @returns the new mesh
  25660. */
  25661. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25662. /**
  25663. * Disposes all the submeshes of the current meshnp
  25664. * @returns the current mesh
  25665. */
  25666. releaseSubMeshes(): AbstractMesh;
  25667. /**
  25668. * Releases resources associated with this abstract mesh.
  25669. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25670. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25671. */
  25672. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25673. /**
  25674. * Adds the passed mesh as a child to the current mesh
  25675. * @param mesh defines the child mesh
  25676. * @returns the current mesh
  25677. */
  25678. addChild(mesh: AbstractMesh): AbstractMesh;
  25679. /**
  25680. * Removes the passed mesh from the current mesh children list
  25681. * @param mesh defines the child mesh
  25682. * @returns the current mesh
  25683. */
  25684. removeChild(mesh: AbstractMesh): AbstractMesh;
  25685. /** @hidden */
  25686. private _initFacetData;
  25687. /**
  25688. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25689. * This method can be called within the render loop.
  25690. * 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
  25691. * @returns the current mesh
  25692. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25693. */
  25694. updateFacetData(): AbstractMesh;
  25695. /**
  25696. * Returns the facetLocalNormals array.
  25697. * The normals are expressed in the mesh local spac
  25698. * @returns an array of Vector3
  25699. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25700. */
  25701. getFacetLocalNormals(): Vector3[];
  25702. /**
  25703. * Returns the facetLocalPositions array.
  25704. * The facet positions are expressed in the mesh local space
  25705. * @returns an array of Vector3
  25706. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25707. */
  25708. getFacetLocalPositions(): Vector3[];
  25709. /**
  25710. * Returns the facetLocalPartioning array
  25711. * @returns an array of array of numbers
  25712. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25713. */
  25714. getFacetLocalPartitioning(): number[][];
  25715. /**
  25716. * Returns the i-th facet position in the world system.
  25717. * This method allocates a new Vector3 per call
  25718. * @param i defines the facet index
  25719. * @returns a new Vector3
  25720. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25721. */
  25722. getFacetPosition(i: number): Vector3;
  25723. /**
  25724. * Sets the reference Vector3 with the i-th facet position in the world system
  25725. * @param i defines the facet index
  25726. * @param ref defines the target vector
  25727. * @returns the current mesh
  25728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25729. */
  25730. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25731. /**
  25732. * Returns the i-th facet normal in the world system.
  25733. * This method allocates a new Vector3 per call
  25734. * @param i defines the facet index
  25735. * @returns a new Vector3
  25736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25737. */
  25738. getFacetNormal(i: number): Vector3;
  25739. /**
  25740. * Sets the reference Vector3 with the i-th facet normal in the world system
  25741. * @param i defines the facet index
  25742. * @param ref defines the target vector
  25743. * @returns the current mesh
  25744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25745. */
  25746. getFacetNormalToRef(i: number, ref: Vector3): this;
  25747. /**
  25748. * 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)
  25749. * @param x defines x coordinate
  25750. * @param y defines y coordinate
  25751. * @param z defines z coordinate
  25752. * @returns the array of facet indexes
  25753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25754. */
  25755. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25756. /**
  25757. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25758. * @param projected sets as the (x,y,z) world projection on the facet
  25759. * @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
  25760. * @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
  25761. * @param x defines x coordinate
  25762. * @param y defines y coordinate
  25763. * @param z defines z coordinate
  25764. * @returns the face index if found (or null instead)
  25765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25766. */
  25767. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25768. /**
  25769. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25770. * @param projected sets as the (x,y,z) local projection on the facet
  25771. * @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
  25772. * @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
  25773. * @param x defines x coordinate
  25774. * @param y defines y coordinate
  25775. * @param z defines z coordinate
  25776. * @returns the face index if found (or null instead)
  25777. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25778. */
  25779. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25780. /**
  25781. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25782. * @returns the parameters
  25783. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25784. */
  25785. getFacetDataParameters(): any;
  25786. /**
  25787. * Disables the feature FacetData and frees the related memory
  25788. * @returns the current mesh
  25789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25790. */
  25791. disableFacetData(): AbstractMesh;
  25792. /**
  25793. * Updates the AbstractMesh indices array
  25794. * @param indices defines the data source
  25795. * @returns the current mesh
  25796. */
  25797. updateIndices(indices: IndicesArray): AbstractMesh;
  25798. /**
  25799. * Creates new normals data for the mesh
  25800. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25801. * @returns the current mesh
  25802. */
  25803. createNormals(updatable: boolean): AbstractMesh;
  25804. /**
  25805. * Align the mesh with a normal
  25806. * @param normal defines the normal to use
  25807. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25808. * @returns the current mesh
  25809. */
  25810. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25811. /** @hidden */
  25812. _checkOcclusionQuery(): boolean;
  25813. }
  25814. }
  25815. declare module "babylonjs/node" {
  25816. import { Scene } from "babylonjs/scene";
  25817. import { Nullable } from "babylonjs/types";
  25818. import { Matrix } from "babylonjs/Maths/math";
  25819. import { Engine } from "babylonjs/Engines/engine";
  25820. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25821. import { Observable } from "babylonjs/Misc/observable";
  25822. import { Animatable } from "babylonjs/Animations/animatable";
  25823. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25824. import { Animation } from "babylonjs/Animations/animation";
  25825. import { AnimationRange } from "babylonjs/Animations/animation";
  25826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25827. /**
  25828. * Defines how a node can be built from a string name.
  25829. */
  25830. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25831. /**
  25832. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25833. */
  25834. export class Node implements IBehaviorAware<Node> {
  25835. /** @hidden */
  25836. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animation").AnimationRange;
  25837. private static _NodeConstructors;
  25838. /**
  25839. * Add a new node constructor
  25840. * @param type defines the type name of the node to construct
  25841. * @param constructorFunc defines the constructor function
  25842. */
  25843. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25844. /**
  25845. * Returns a node constructor based on type name
  25846. * @param type defines the type name
  25847. * @param name defines the new node name
  25848. * @param scene defines the hosting scene
  25849. * @param options defines optional options to transmit to constructors
  25850. * @returns the new constructor or null
  25851. */
  25852. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25853. /**
  25854. * Gets or sets the name of the node
  25855. */
  25856. name: string;
  25857. /**
  25858. * Gets or sets the id of the node
  25859. */
  25860. id: string;
  25861. /**
  25862. * Gets or sets the unique id of the node
  25863. */
  25864. uniqueId: number;
  25865. /**
  25866. * Gets or sets a string used to store user defined state for the node
  25867. */
  25868. state: string;
  25869. /**
  25870. * Gets or sets an object used to store user defined information for the node
  25871. */
  25872. metadata: any;
  25873. /**
  25874. * For internal use only. Please do not use.
  25875. */
  25876. reservedDataStore: any;
  25877. /**
  25878. * Gets or sets a boolean used to define if the node must be serialized
  25879. */
  25880. doNotSerialize: boolean;
  25881. /** @hidden */
  25882. _isDisposed: boolean;
  25883. /**
  25884. * Gets a list of Animations associated with the node
  25885. */
  25886. animations: import("babylonjs/Animations/animation").Animation[];
  25887. protected _ranges: {
  25888. [name: string]: Nullable<AnimationRange>;
  25889. };
  25890. /**
  25891. * Callback raised when the node is ready to be used
  25892. */
  25893. onReady: (node: Node) => void;
  25894. private _isEnabled;
  25895. private _isParentEnabled;
  25896. private _isReady;
  25897. /** @hidden */
  25898. _currentRenderId: number;
  25899. private _parentRenderId;
  25900. protected _childRenderId: number;
  25901. /** @hidden */
  25902. _waitingParentId: Nullable<string>;
  25903. /** @hidden */
  25904. _scene: Scene;
  25905. /** @hidden */
  25906. _cache: any;
  25907. private _parentNode;
  25908. private _children;
  25909. /** @hidden */
  25910. _worldMatrix: Matrix;
  25911. /** @hidden */
  25912. _worldMatrixDeterminant: number;
  25913. /** @hidden */
  25914. private _sceneRootNodesIndex;
  25915. /**
  25916. * Gets a boolean indicating if the node has been disposed
  25917. * @returns true if the node was disposed
  25918. */
  25919. isDisposed(): boolean;
  25920. /**
  25921. * Gets or sets the parent of the node
  25922. */
  25923. parent: Nullable<Node>;
  25924. private addToSceneRootNodes;
  25925. private removeFromSceneRootNodes;
  25926. private _animationPropertiesOverride;
  25927. /**
  25928. * Gets or sets the animation properties override
  25929. */
  25930. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25931. /**
  25932. * Gets a string idenfifying the name of the class
  25933. * @returns "Node" string
  25934. */
  25935. getClassName(): string;
  25936. /** @hidden */
  25937. readonly _isNode: boolean;
  25938. /**
  25939. * An event triggered when the mesh is disposed
  25940. */
  25941. onDisposeObservable: Observable<Node>;
  25942. private _onDisposeObserver;
  25943. /**
  25944. * Sets a callback that will be raised when the node will be disposed
  25945. */
  25946. onDispose: () => void;
  25947. /**
  25948. * Creates a new Node
  25949. * @param name the name and id to be given to this node
  25950. * @param scene the scene this node will be added to
  25951. * @param addToRootNodes the node will be added to scene.rootNodes
  25952. */
  25953. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25954. /**
  25955. * Gets the scene of the node
  25956. * @returns a scene
  25957. */
  25958. getScene(): Scene;
  25959. /**
  25960. * Gets the engine of the node
  25961. * @returns a Engine
  25962. */
  25963. getEngine(): Engine;
  25964. private _behaviors;
  25965. /**
  25966. * Attach a behavior to the node
  25967. * @see http://doc.babylonjs.com/features/behaviour
  25968. * @param behavior defines the behavior to attach
  25969. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25970. * @returns the current Node
  25971. */
  25972. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25973. /**
  25974. * Remove an attached behavior
  25975. * @see http://doc.babylonjs.com/features/behaviour
  25976. * @param behavior defines the behavior to attach
  25977. * @returns the current Node
  25978. */
  25979. removeBehavior(behavior: Behavior<Node>): Node;
  25980. /**
  25981. * Gets the list of attached behaviors
  25982. * @see http://doc.babylonjs.com/features/behaviour
  25983. */
  25984. readonly behaviors: Behavior<Node>[];
  25985. /**
  25986. * Gets an attached behavior by name
  25987. * @param name defines the name of the behavior to look for
  25988. * @see http://doc.babylonjs.com/features/behaviour
  25989. * @returns null if behavior was not found else the requested behavior
  25990. */
  25991. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25992. /**
  25993. * Returns the latest update of the World matrix
  25994. * @returns a Matrix
  25995. */
  25996. getWorldMatrix(): Matrix;
  25997. /** @hidden */
  25998. _getWorldMatrixDeterminant(): number;
  25999. /**
  26000. * Returns directly the latest state of the mesh World matrix.
  26001. * A Matrix is returned.
  26002. */
  26003. readonly worldMatrixFromCache: Matrix;
  26004. /** @hidden */
  26005. _initCache(): void;
  26006. /** @hidden */
  26007. updateCache(force?: boolean): void;
  26008. /** @hidden */
  26009. _updateCache(ignoreParentClass?: boolean): void;
  26010. /** @hidden */
  26011. _isSynchronized(): boolean;
  26012. /** @hidden */
  26013. _markSyncedWithParent(): void;
  26014. /** @hidden */
  26015. isSynchronizedWithParent(): boolean;
  26016. /** @hidden */
  26017. isSynchronized(): boolean;
  26018. /**
  26019. * Is this node ready to be used/rendered
  26020. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26021. * @return true if the node is ready
  26022. */
  26023. isReady(completeCheck?: boolean): boolean;
  26024. /**
  26025. * Is this node enabled?
  26026. * 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
  26027. * @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
  26028. * @return whether this node (and its parent) is enabled
  26029. */
  26030. isEnabled(checkAncestors?: boolean): boolean;
  26031. /** @hidden */
  26032. protected _syncParentEnabledState(): void;
  26033. /**
  26034. * Set the enabled state of this node
  26035. * @param value defines the new enabled state
  26036. */
  26037. setEnabled(value: boolean): void;
  26038. /**
  26039. * Is this node a descendant of the given node?
  26040. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26041. * @param ancestor defines the parent node to inspect
  26042. * @returns a boolean indicating if this node is a descendant of the given node
  26043. */
  26044. isDescendantOf(ancestor: Node): boolean;
  26045. /** @hidden */
  26046. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26047. /**
  26048. * Will return all nodes that have this node as ascendant
  26049. * @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
  26050. * @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
  26051. * @return all children nodes of all types
  26052. */
  26053. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26054. /**
  26055. * Get all child-meshes of this node
  26056. * @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
  26057. * @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
  26058. * @returns an array of AbstractMesh
  26059. */
  26060. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26061. /**
  26062. * Get all direct children of this node
  26063. * @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
  26064. * @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)
  26065. * @returns an array of Node
  26066. */
  26067. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26068. /** @hidden */
  26069. _setReady(state: boolean): void;
  26070. /**
  26071. * Get an animation by name
  26072. * @param name defines the name of the animation to look for
  26073. * @returns null if not found else the requested animation
  26074. */
  26075. getAnimationByName(name: string): Nullable<Animation>;
  26076. /**
  26077. * Creates an animation range for this node
  26078. * @param name defines the name of the range
  26079. * @param from defines the starting key
  26080. * @param to defines the end key
  26081. */
  26082. createAnimationRange(name: string, from: number, to: number): void;
  26083. /**
  26084. * Delete a specific animation range
  26085. * @param name defines the name of the range to delete
  26086. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26087. */
  26088. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26089. /**
  26090. * Get an animation range by name
  26091. * @param name defines the name of the animation range to look for
  26092. * @returns null if not found else the requested animation range
  26093. */
  26094. getAnimationRange(name: string): Nullable<AnimationRange>;
  26095. /**
  26096. * Will start the animation sequence
  26097. * @param name defines the range frames for animation sequence
  26098. * @param loop defines if the animation should loop (false by default)
  26099. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26100. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26101. * @returns the object created for this animation. If range does not exist, it will return null
  26102. */
  26103. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26104. /**
  26105. * Serialize animation ranges into a JSON compatible object
  26106. * @returns serialization object
  26107. */
  26108. serializeAnimationRanges(): any;
  26109. /**
  26110. * Computes the world matrix of the node
  26111. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26112. * @returns the world matrix
  26113. */
  26114. computeWorldMatrix(force?: boolean): Matrix;
  26115. /**
  26116. * Releases resources associated with this node.
  26117. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26118. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26119. */
  26120. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26121. /**
  26122. * Parse animation range data from a serialization object and store them into a given node
  26123. * @param node defines where to store the animation ranges
  26124. * @param parsedNode defines the serialization object to read data from
  26125. * @param scene defines the hosting scene
  26126. */
  26127. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26128. }
  26129. }
  26130. declare module "babylonjs/Animations/animation" {
  26131. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26132. import { Path2, Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26133. import { Nullable } from "babylonjs/types";
  26134. import { Scene } from "babylonjs/scene";
  26135. import { IAnimatable } from "babylonjs/Misc/tools";
  26136. import { Node } from "babylonjs/node";
  26137. import { Animatable } from "babylonjs/Animations/animatable";
  26138. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26139. /**
  26140. * Represents the range of an animation
  26141. */
  26142. export class AnimationRange {
  26143. /**The name of the animation range**/
  26144. name: string;
  26145. /**The starting frame of the animation */
  26146. from: number;
  26147. /**The ending frame of the animation*/
  26148. to: number;
  26149. /**
  26150. * Initializes the range of an animation
  26151. * @param name The name of the animation range
  26152. * @param from The starting frame of the animation
  26153. * @param to The ending frame of the animation
  26154. */
  26155. constructor(
  26156. /**The name of the animation range**/
  26157. name: string,
  26158. /**The starting frame of the animation */
  26159. from: number,
  26160. /**The ending frame of the animation*/
  26161. to: number);
  26162. /**
  26163. * Makes a copy of the animation range
  26164. * @returns A copy of the animation range
  26165. */
  26166. clone(): AnimationRange;
  26167. }
  26168. /**
  26169. * Composed of a frame, and an action function
  26170. */
  26171. export class AnimationEvent {
  26172. /** The frame for which the event is triggered **/
  26173. frame: number;
  26174. /** The event to perform when triggered **/
  26175. action: (currentFrame: number) => void;
  26176. /** Specifies if the event should be triggered only once**/
  26177. onlyOnce?: boolean | undefined;
  26178. /**
  26179. * Specifies if the animation event is done
  26180. */
  26181. isDone: boolean;
  26182. /**
  26183. * Initializes the animation event
  26184. * @param frame The frame for which the event is triggered
  26185. * @param action The event to perform when triggered
  26186. * @param onlyOnce Specifies if the event should be triggered only once
  26187. */
  26188. constructor(
  26189. /** The frame for which the event is triggered **/
  26190. frame: number,
  26191. /** The event to perform when triggered **/
  26192. action: (currentFrame: number) => void,
  26193. /** Specifies if the event should be triggered only once**/
  26194. onlyOnce?: boolean | undefined);
  26195. /** @hidden */
  26196. _clone(): AnimationEvent;
  26197. }
  26198. /**
  26199. * A cursor which tracks a point on a path
  26200. */
  26201. export class PathCursor {
  26202. private path;
  26203. /**
  26204. * Stores path cursor callbacks for when an onchange event is triggered
  26205. */
  26206. private _onchange;
  26207. /**
  26208. * The value of the path cursor
  26209. */
  26210. value: number;
  26211. /**
  26212. * The animation array of the path cursor
  26213. */
  26214. animations: Animation[];
  26215. /**
  26216. * Initializes the path cursor
  26217. * @param path The path to track
  26218. */
  26219. constructor(path: Path2);
  26220. /**
  26221. * Gets the cursor point on the path
  26222. * @returns A point on the path cursor at the cursor location
  26223. */
  26224. getPoint(): Vector3;
  26225. /**
  26226. * Moves the cursor ahead by the step amount
  26227. * @param step The amount to move the cursor forward
  26228. * @returns This path cursor
  26229. */
  26230. moveAhead(step?: number): PathCursor;
  26231. /**
  26232. * Moves the cursor behind by the step amount
  26233. * @param step The amount to move the cursor back
  26234. * @returns This path cursor
  26235. */
  26236. moveBack(step?: number): PathCursor;
  26237. /**
  26238. * Moves the cursor by the step amount
  26239. * If the step amount is greater than one, an exception is thrown
  26240. * @param step The amount to move the cursor
  26241. * @returns This path cursor
  26242. */
  26243. move(step: number): PathCursor;
  26244. /**
  26245. * Ensures that the value is limited between zero and one
  26246. * @returns This path cursor
  26247. */
  26248. private ensureLimits;
  26249. /**
  26250. * Runs onchange callbacks on change (used by the animation engine)
  26251. * @returns This path cursor
  26252. */
  26253. private raiseOnChange;
  26254. /**
  26255. * Executes a function on change
  26256. * @param f A path cursor onchange callback
  26257. * @returns This path cursor
  26258. */
  26259. onchange(f: (cursor: PathCursor) => void): PathCursor;
  26260. }
  26261. /**
  26262. * Defines an interface which represents an animation key frame
  26263. */
  26264. export interface IAnimationKey {
  26265. /**
  26266. * Frame of the key frame
  26267. */
  26268. frame: number;
  26269. /**
  26270. * Value at the specifies key frame
  26271. */
  26272. value: any;
  26273. /**
  26274. * The input tangent for the cubic hermite spline
  26275. */
  26276. inTangent?: any;
  26277. /**
  26278. * The output tangent for the cubic hermite spline
  26279. */
  26280. outTangent?: any;
  26281. /**
  26282. * The animation interpolation type
  26283. */
  26284. interpolation?: AnimationKeyInterpolation;
  26285. }
  26286. /**
  26287. * Enum for the animation key frame interpolation type
  26288. */
  26289. export enum AnimationKeyInterpolation {
  26290. /**
  26291. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  26292. */
  26293. STEP = 1
  26294. }
  26295. /**
  26296. * Class used to store any kind of animation
  26297. */
  26298. export class Animation {
  26299. /**Name of the animation */
  26300. name: string;
  26301. /**Property to animate */
  26302. targetProperty: string;
  26303. /**The frames per second of the animation */
  26304. framePerSecond: number;
  26305. /**The data type of the animation */
  26306. dataType: number;
  26307. /**The loop mode of the animation */
  26308. loopMode?: number | undefined;
  26309. /**Specifies if blending should be enabled */
  26310. enableBlending?: boolean | undefined;
  26311. /**
  26312. * Use matrix interpolation instead of using direct key value when animating matrices
  26313. */
  26314. static AllowMatricesInterpolation: boolean;
  26315. /**
  26316. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26317. */
  26318. static AllowMatrixDecomposeForInterpolation: boolean;
  26319. /**
  26320. * Stores the key frames of the animation
  26321. */
  26322. private _keys;
  26323. /**
  26324. * Stores the easing function of the animation
  26325. */
  26326. private _easingFunction;
  26327. /**
  26328. * @hidden Internal use only
  26329. */
  26330. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26331. /**
  26332. * The set of event that will be linked to this animation
  26333. */
  26334. private _events;
  26335. /**
  26336. * Stores an array of target property paths
  26337. */
  26338. targetPropertyPath: string[];
  26339. /**
  26340. * Stores the blending speed of the animation
  26341. */
  26342. blendingSpeed: number;
  26343. /**
  26344. * Stores the animation ranges for the animation
  26345. */
  26346. private _ranges;
  26347. /**
  26348. * @hidden Internal use
  26349. */
  26350. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26351. /**
  26352. * Sets up an animation
  26353. * @param property The property to animate
  26354. * @param animationType The animation type to apply
  26355. * @param framePerSecond The frames per second of the animation
  26356. * @param easingFunction The easing function used in the animation
  26357. * @returns The created animation
  26358. */
  26359. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26360. /**
  26361. * Create and start an animation on a node
  26362. * @param name defines the name of the global animation that will be run on all nodes
  26363. * @param node defines the root node where the animation will take place
  26364. * @param targetProperty defines property to animate
  26365. * @param framePerSecond defines the number of frame per second yo use
  26366. * @param totalFrame defines the number of frames in total
  26367. * @param from defines the initial value
  26368. * @param to defines the final value
  26369. * @param loopMode defines which loop mode you want to use (off by default)
  26370. * @param easingFunction defines the easing function to use (linear by default)
  26371. * @param onAnimationEnd defines the callback to call when animation end
  26372. * @returns the animatable created for this animation
  26373. */
  26374. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26375. /**
  26376. * Create and start an animation on a node and its descendants
  26377. * @param name defines the name of the global animation that will be run on all nodes
  26378. * @param node defines the root node where the animation will take place
  26379. * @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
  26380. * @param targetProperty defines property to animate
  26381. * @param framePerSecond defines the number of frame per second to use
  26382. * @param totalFrame defines the number of frames in total
  26383. * @param from defines the initial value
  26384. * @param to defines the final value
  26385. * @param loopMode defines which loop mode you want to use (off by default)
  26386. * @param easingFunction defines the easing function to use (linear by default)
  26387. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26388. * @returns the list of animatables created for all nodes
  26389. * @example https://www.babylonjs-playground.com/#MH0VLI
  26390. */
  26391. 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[]>;
  26392. /**
  26393. * Creates a new animation, merges it with the existing animations and starts it
  26394. * @param name Name of the animation
  26395. * @param node Node which contains the scene that begins the animations
  26396. * @param targetProperty Specifies which property to animate
  26397. * @param framePerSecond The frames per second of the animation
  26398. * @param totalFrame The total number of frames
  26399. * @param from The frame at the beginning of the animation
  26400. * @param to The frame at the end of the animation
  26401. * @param loopMode Specifies the loop mode of the animation
  26402. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26403. * @param onAnimationEnd Callback to run once the animation is complete
  26404. * @returns Nullable animation
  26405. */
  26406. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26407. /**
  26408. * Transition property of an host to the target Value
  26409. * @param property The property to transition
  26410. * @param targetValue The target Value of the property
  26411. * @param host The object where the property to animate belongs
  26412. * @param scene Scene used to run the animation
  26413. * @param frameRate Framerate (in frame/s) to use
  26414. * @param transition The transition type we want to use
  26415. * @param duration The duration of the animation, in milliseconds
  26416. * @param onAnimationEnd Callback trigger at the end of the animation
  26417. * @returns Nullable animation
  26418. */
  26419. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26420. /**
  26421. * Return the array of runtime animations currently using this animation
  26422. */
  26423. readonly runtimeAnimations: RuntimeAnimation[];
  26424. /**
  26425. * Specifies if any of the runtime animations are currently running
  26426. */
  26427. readonly hasRunningRuntimeAnimations: boolean;
  26428. /**
  26429. * Initializes the animation
  26430. * @param name Name of the animation
  26431. * @param targetProperty Property to animate
  26432. * @param framePerSecond The frames per second of the animation
  26433. * @param dataType The data type of the animation
  26434. * @param loopMode The loop mode of the animation
  26435. * @param enableBlendings Specifies if blending should be enabled
  26436. */
  26437. constructor(
  26438. /**Name of the animation */
  26439. name: string,
  26440. /**Property to animate */
  26441. targetProperty: string,
  26442. /**The frames per second of the animation */
  26443. framePerSecond: number,
  26444. /**The data type of the animation */
  26445. dataType: number,
  26446. /**The loop mode of the animation */
  26447. loopMode?: number | undefined,
  26448. /**Specifies if blending should be enabled */
  26449. enableBlending?: boolean | undefined);
  26450. /**
  26451. * Converts the animation to a string
  26452. * @param fullDetails support for multiple levels of logging within scene loading
  26453. * @returns String form of the animation
  26454. */
  26455. toString(fullDetails?: boolean): string;
  26456. /**
  26457. * Add an event to this animation
  26458. * @param event Event to add
  26459. */
  26460. addEvent(event: AnimationEvent): void;
  26461. /**
  26462. * Remove all events found at the given frame
  26463. * @param frame The frame to remove events from
  26464. */
  26465. removeEvents(frame: number): void;
  26466. /**
  26467. * Retrieves all the events from the animation
  26468. * @returns Events from the animation
  26469. */
  26470. getEvents(): AnimationEvent[];
  26471. /**
  26472. * Creates an animation range
  26473. * @param name Name of the animation range
  26474. * @param from Starting frame of the animation range
  26475. * @param to Ending frame of the animation
  26476. */
  26477. createRange(name: string, from: number, to: number): void;
  26478. /**
  26479. * Deletes an animation range by name
  26480. * @param name Name of the animation range to delete
  26481. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26482. */
  26483. deleteRange(name: string, deleteFrames?: boolean): void;
  26484. /**
  26485. * Gets the animation range by name, or null if not defined
  26486. * @param name Name of the animation range
  26487. * @returns Nullable animation range
  26488. */
  26489. getRange(name: string): Nullable<AnimationRange>;
  26490. /**
  26491. * Gets the key frames from the animation
  26492. * @returns The key frames of the animation
  26493. */
  26494. getKeys(): Array<IAnimationKey>;
  26495. /**
  26496. * Gets the highest frame rate of the animation
  26497. * @returns Highest frame rate of the animation
  26498. */
  26499. getHighestFrame(): number;
  26500. /**
  26501. * Gets the easing function of the animation
  26502. * @returns Easing function of the animation
  26503. */
  26504. getEasingFunction(): IEasingFunction;
  26505. /**
  26506. * Sets the easing function of the animation
  26507. * @param easingFunction A custom mathematical formula for animation
  26508. */
  26509. setEasingFunction(easingFunction: EasingFunction): void;
  26510. /**
  26511. * Interpolates a scalar linearly
  26512. * @param startValue Start value of the animation curve
  26513. * @param endValue End value of the animation curve
  26514. * @param gradient Scalar amount to interpolate
  26515. * @returns Interpolated scalar value
  26516. */
  26517. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26518. /**
  26519. * Interpolates a scalar cubically
  26520. * @param startValue Start value of the animation curve
  26521. * @param outTangent End tangent of the animation
  26522. * @param endValue End value of the animation curve
  26523. * @param inTangent Start tangent of the animation curve
  26524. * @param gradient Scalar amount to interpolate
  26525. * @returns Interpolated scalar value
  26526. */
  26527. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26528. /**
  26529. * Interpolates a quaternion using a spherical linear interpolation
  26530. * @param startValue Start value of the animation curve
  26531. * @param endValue End value of the animation curve
  26532. * @param gradient Scalar amount to interpolate
  26533. * @returns Interpolated quaternion value
  26534. */
  26535. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26536. /**
  26537. * Interpolates a quaternion cubically
  26538. * @param startValue Start value of the animation curve
  26539. * @param outTangent End tangent of the animation curve
  26540. * @param endValue End value of the animation curve
  26541. * @param inTangent Start tangent of the animation curve
  26542. * @param gradient Scalar amount to interpolate
  26543. * @returns Interpolated quaternion value
  26544. */
  26545. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26546. /**
  26547. * Interpolates a Vector3 linearl
  26548. * @param startValue Start value of the animation curve
  26549. * @param endValue End value of the animation curve
  26550. * @param gradient Scalar amount to interpolate
  26551. * @returns Interpolated scalar value
  26552. */
  26553. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26554. /**
  26555. * Interpolates a Vector3 cubically
  26556. * @param startValue Start value of the animation curve
  26557. * @param outTangent End tangent of the animation
  26558. * @param endValue End value of the animation curve
  26559. * @param inTangent Start tangent of the animation curve
  26560. * @param gradient Scalar amount to interpolate
  26561. * @returns InterpolatedVector3 value
  26562. */
  26563. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26564. /**
  26565. * Interpolates a Vector2 linearly
  26566. * @param startValue Start value of the animation curve
  26567. * @param endValue End value of the animation curve
  26568. * @param gradient Scalar amount to interpolate
  26569. * @returns Interpolated Vector2 value
  26570. */
  26571. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26572. /**
  26573. * Interpolates a Vector2 cubically
  26574. * @param startValue Start value of the animation curve
  26575. * @param outTangent End tangent of the animation
  26576. * @param endValue End value of the animation curve
  26577. * @param inTangent Start tangent of the animation curve
  26578. * @param gradient Scalar amount to interpolate
  26579. * @returns Interpolated Vector2 value
  26580. */
  26581. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26582. /**
  26583. * Interpolates a size linearly
  26584. * @param startValue Start value of the animation curve
  26585. * @param endValue End value of the animation curve
  26586. * @param gradient Scalar amount to interpolate
  26587. * @returns Interpolated Size value
  26588. */
  26589. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26590. /**
  26591. * Interpolates a Color3 linearly
  26592. * @param startValue Start value of the animation curve
  26593. * @param endValue End value of the animation curve
  26594. * @param gradient Scalar amount to interpolate
  26595. * @returns Interpolated Color3 value
  26596. */
  26597. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26598. /**
  26599. * @hidden Internal use only
  26600. */
  26601. _getKeyValue(value: any): any;
  26602. /**
  26603. * @hidden Internal use only
  26604. */
  26605. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26606. /**
  26607. * Defines the function to use to interpolate matrices
  26608. * @param startValue defines the start matrix
  26609. * @param endValue defines the end matrix
  26610. * @param gradient defines the gradient between both matrices
  26611. * @param result defines an optional target matrix where to store the interpolation
  26612. * @returns the interpolated matrix
  26613. */
  26614. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26615. /**
  26616. * Makes a copy of the animation
  26617. * @returns Cloned animation
  26618. */
  26619. clone(): Animation;
  26620. /**
  26621. * Sets the key frames of the animation
  26622. * @param values The animation key frames to set
  26623. */
  26624. setKeys(values: Array<IAnimationKey>): void;
  26625. /**
  26626. * Serializes the animation to an object
  26627. * @returns Serialized object
  26628. */
  26629. serialize(): any;
  26630. /**
  26631. * Float animation type
  26632. */
  26633. private static _ANIMATIONTYPE_FLOAT;
  26634. /**
  26635. * Vector3 animation type
  26636. */
  26637. private static _ANIMATIONTYPE_VECTOR3;
  26638. /**
  26639. * Quaternion animation type
  26640. */
  26641. private static _ANIMATIONTYPE_QUATERNION;
  26642. /**
  26643. * Matrix animation type
  26644. */
  26645. private static _ANIMATIONTYPE_MATRIX;
  26646. /**
  26647. * Color3 animation type
  26648. */
  26649. private static _ANIMATIONTYPE_COLOR3;
  26650. /**
  26651. * Vector2 animation type
  26652. */
  26653. private static _ANIMATIONTYPE_VECTOR2;
  26654. /**
  26655. * Size animation type
  26656. */
  26657. private static _ANIMATIONTYPE_SIZE;
  26658. /**
  26659. * Relative Loop Mode
  26660. */
  26661. private static _ANIMATIONLOOPMODE_RELATIVE;
  26662. /**
  26663. * Cycle Loop Mode
  26664. */
  26665. private static _ANIMATIONLOOPMODE_CYCLE;
  26666. /**
  26667. * Constant Loop Mode
  26668. */
  26669. private static _ANIMATIONLOOPMODE_CONSTANT;
  26670. /**
  26671. * Get the float animation type
  26672. */
  26673. static readonly ANIMATIONTYPE_FLOAT: number;
  26674. /**
  26675. * Get the Vector3 animation type
  26676. */
  26677. static readonly ANIMATIONTYPE_VECTOR3: number;
  26678. /**
  26679. * Get the Vector2 animation type
  26680. */
  26681. static readonly ANIMATIONTYPE_VECTOR2: number;
  26682. /**
  26683. * Get the Size animation type
  26684. */
  26685. static readonly ANIMATIONTYPE_SIZE: number;
  26686. /**
  26687. * Get the Quaternion animation type
  26688. */
  26689. static readonly ANIMATIONTYPE_QUATERNION: number;
  26690. /**
  26691. * Get the Matrix animation type
  26692. */
  26693. static readonly ANIMATIONTYPE_MATRIX: number;
  26694. /**
  26695. * Get the Color3 animation type
  26696. */
  26697. static readonly ANIMATIONTYPE_COLOR3: number;
  26698. /**
  26699. * Get the Relative Loop Mode
  26700. */
  26701. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26702. /**
  26703. * Get the Cycle Loop Mode
  26704. */
  26705. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26706. /**
  26707. * Get the Constant Loop Mode
  26708. */
  26709. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26710. /** @hidden */
  26711. static _UniversalLerp(left: any, right: any, amount: number): any;
  26712. /**
  26713. * Parses an animation object and creates an animation
  26714. * @param parsedAnimation Parsed animation object
  26715. * @returns Animation object
  26716. */
  26717. static Parse(parsedAnimation: any): Animation;
  26718. /**
  26719. * Appends the serialized animations from the source animations
  26720. * @param source Source containing the animations
  26721. * @param destination Target to store the animations
  26722. */
  26723. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26724. }
  26725. }
  26726. declare module "babylonjs/Materials/Textures/baseTexture" {
  26727. import { Observable } from "babylonjs/Misc/observable";
  26728. import { IAnimatable } from "babylonjs/Misc/tools";
  26729. import { Nullable } from "babylonjs/types";
  26730. import { Scene } from "babylonjs/scene";
  26731. import { Matrix, ISize } from "babylonjs/Maths/math";
  26732. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26733. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26734. /**
  26735. * Base class of all the textures in babylon.
  26736. * It groups all the common properties the materials, post process, lights... might need
  26737. * in order to make a correct use of the texture.
  26738. */
  26739. export class BaseTexture implements IAnimatable {
  26740. /**
  26741. * Default anisotropic filtering level for the application.
  26742. * It is set to 4 as a good tradeoff between perf and quality.
  26743. */
  26744. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26745. /**
  26746. * Gets or sets the unique id of the texture
  26747. */
  26748. uniqueId: number;
  26749. /**
  26750. * Define the name of the texture.
  26751. */
  26752. name: string;
  26753. /**
  26754. * Gets or sets an object used to store user defined information.
  26755. */
  26756. metadata: any;
  26757. /**
  26758. * For internal use only. Please do not use.
  26759. */
  26760. reservedDataStore: any;
  26761. private _hasAlpha;
  26762. /**
  26763. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26764. */
  26765. hasAlpha: boolean;
  26766. /**
  26767. * Defines if the alpha value should be determined via the rgb values.
  26768. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26769. */
  26770. getAlphaFromRGB: boolean;
  26771. /**
  26772. * Intensity or strength of the texture.
  26773. * It is commonly used by materials to fine tune the intensity of the texture
  26774. */
  26775. level: number;
  26776. /**
  26777. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26778. * This is part of the texture as textures usually maps to one uv set.
  26779. */
  26780. coordinatesIndex: number;
  26781. private _coordinatesMode;
  26782. /**
  26783. * How a texture is mapped.
  26784. *
  26785. * | Value | Type | Description |
  26786. * | ----- | ----------------------------------- | ----------- |
  26787. * | 0 | EXPLICIT_MODE | |
  26788. * | 1 | SPHERICAL_MODE | |
  26789. * | 2 | PLANAR_MODE | |
  26790. * | 3 | CUBIC_MODE | |
  26791. * | 4 | PROJECTION_MODE | |
  26792. * | 5 | SKYBOX_MODE | |
  26793. * | 6 | INVCUBIC_MODE | |
  26794. * | 7 | EQUIRECTANGULAR_MODE | |
  26795. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26796. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26797. */
  26798. coordinatesMode: number;
  26799. /**
  26800. * | Value | Type | Description |
  26801. * | ----- | ------------------ | ----------- |
  26802. * | 0 | CLAMP_ADDRESSMODE | |
  26803. * | 1 | WRAP_ADDRESSMODE | |
  26804. * | 2 | MIRROR_ADDRESSMODE | |
  26805. */
  26806. wrapU: number;
  26807. /**
  26808. * | Value | Type | Description |
  26809. * | ----- | ------------------ | ----------- |
  26810. * | 0 | CLAMP_ADDRESSMODE | |
  26811. * | 1 | WRAP_ADDRESSMODE | |
  26812. * | 2 | MIRROR_ADDRESSMODE | |
  26813. */
  26814. wrapV: number;
  26815. /**
  26816. * | Value | Type | Description |
  26817. * | ----- | ------------------ | ----------- |
  26818. * | 0 | CLAMP_ADDRESSMODE | |
  26819. * | 1 | WRAP_ADDRESSMODE | |
  26820. * | 2 | MIRROR_ADDRESSMODE | |
  26821. */
  26822. wrapR: number;
  26823. /**
  26824. * With compliant hardware and browser (supporting anisotropic filtering)
  26825. * this defines the level of anisotropic filtering in the texture.
  26826. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26827. */
  26828. anisotropicFilteringLevel: number;
  26829. /**
  26830. * Define if the texture is a cube texture or if false a 2d texture.
  26831. */
  26832. isCube: boolean;
  26833. /**
  26834. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26835. */
  26836. is3D: boolean;
  26837. /**
  26838. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26839. * HDR texture are usually stored in linear space.
  26840. * This only impacts the PBR and Background materials
  26841. */
  26842. gammaSpace: boolean;
  26843. /**
  26844. * Gets whether or not the texture contains RGBD data.
  26845. */
  26846. readonly isRGBD: boolean;
  26847. /**
  26848. * Is Z inverted in the texture (useful in a cube texture).
  26849. */
  26850. invertZ: boolean;
  26851. /**
  26852. * Are mip maps generated for this texture or not.
  26853. */
  26854. readonly noMipmap: boolean;
  26855. /**
  26856. * @hidden
  26857. */
  26858. lodLevelInAlpha: boolean;
  26859. /**
  26860. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26861. */
  26862. lodGenerationOffset: number;
  26863. /**
  26864. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26865. */
  26866. lodGenerationScale: number;
  26867. /**
  26868. * Define if the texture is a render target.
  26869. */
  26870. isRenderTarget: boolean;
  26871. /**
  26872. * Define the unique id of the texture in the scene.
  26873. */
  26874. readonly uid: string;
  26875. /**
  26876. * Return a string representation of the texture.
  26877. * @returns the texture as a string
  26878. */
  26879. toString(): string;
  26880. /**
  26881. * Get the class name of the texture.
  26882. * @returns "BaseTexture"
  26883. */
  26884. getClassName(): string;
  26885. /**
  26886. * Define the list of animation attached to the texture.
  26887. */
  26888. animations: import("babylonjs/Animations/animation").Animation[];
  26889. /**
  26890. * An event triggered when the texture is disposed.
  26891. */
  26892. onDisposeObservable: Observable<BaseTexture>;
  26893. private _onDisposeObserver;
  26894. /**
  26895. * Callback triggered when the texture has been disposed.
  26896. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26897. */
  26898. onDispose: () => void;
  26899. /**
  26900. * Define the current state of the loading sequence when in delayed load mode.
  26901. */
  26902. delayLoadState: number;
  26903. private _scene;
  26904. /** @hidden */
  26905. _texture: Nullable<InternalTexture>;
  26906. private _uid;
  26907. /**
  26908. * Define if the texture is preventinga material to render or not.
  26909. * If not and the texture is not ready, the engine will use a default black texture instead.
  26910. */
  26911. readonly isBlocking: boolean;
  26912. /**
  26913. * Instantiates a new BaseTexture.
  26914. * Base class of all the textures in babylon.
  26915. * It groups all the common properties the materials, post process, lights... might need
  26916. * in order to make a correct use of the texture.
  26917. * @param scene Define the scene the texture blongs to
  26918. */
  26919. constructor(scene: Nullable<Scene>);
  26920. /**
  26921. * Get the scene the texture belongs to.
  26922. * @returns the scene or null if undefined
  26923. */
  26924. getScene(): Nullable<Scene>;
  26925. /**
  26926. * Get the texture transform matrix used to offset tile the texture for istance.
  26927. * @returns the transformation matrix
  26928. */
  26929. getTextureMatrix(): Matrix;
  26930. /**
  26931. * Get the texture reflection matrix used to rotate/transform the reflection.
  26932. * @returns the reflection matrix
  26933. */
  26934. getReflectionTextureMatrix(): Matrix;
  26935. /**
  26936. * Get the underlying lower level texture from Babylon.
  26937. * @returns the insternal texture
  26938. */
  26939. getInternalTexture(): Nullable<InternalTexture>;
  26940. /**
  26941. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26942. * @returns true if ready or not blocking
  26943. */
  26944. isReadyOrNotBlocking(): boolean;
  26945. /**
  26946. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26947. * @returns true if fully ready
  26948. */
  26949. isReady(): boolean;
  26950. private _cachedSize;
  26951. /**
  26952. * Get the size of the texture.
  26953. * @returns the texture size.
  26954. */
  26955. getSize(): ISize;
  26956. /**
  26957. * Get the base size of the texture.
  26958. * It can be different from the size if the texture has been resized for POT for instance
  26959. * @returns the base size
  26960. */
  26961. getBaseSize(): ISize;
  26962. /**
  26963. * Update the sampling mode of the texture.
  26964. * Default is Trilinear mode.
  26965. *
  26966. * | Value | Type | Description |
  26967. * | ----- | ------------------ | ----------- |
  26968. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26969. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26970. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26971. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26972. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26973. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26974. * | 7 | NEAREST_LINEAR | |
  26975. * | 8 | NEAREST_NEAREST | |
  26976. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26977. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26978. * | 11 | LINEAR_LINEAR | |
  26979. * | 12 | LINEAR_NEAREST | |
  26980. *
  26981. * > _mag_: magnification filter (close to the viewer)
  26982. * > _min_: minification filter (far from the viewer)
  26983. * > _mip_: filter used between mip map levels
  26984. *@param samplingMode Define the new sampling mode of the texture
  26985. */
  26986. updateSamplingMode(samplingMode: number): void;
  26987. /**
  26988. * Scales the texture if is `canRescale()`
  26989. * @param ratio the resize factor we want to use to rescale
  26990. */
  26991. scale(ratio: number): void;
  26992. /**
  26993. * Get if the texture can rescale.
  26994. */
  26995. readonly canRescale: boolean;
  26996. /** @hidden */
  26997. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  26998. /** @hidden */
  26999. _rebuild(): void;
  27000. /**
  27001. * Triggers the load sequence in delayed load mode.
  27002. */
  27003. delayLoad(): void;
  27004. /**
  27005. * Clones the texture.
  27006. * @returns the cloned texture
  27007. */
  27008. clone(): Nullable<BaseTexture>;
  27009. /**
  27010. * Get the texture underlying type (INT, FLOAT...)
  27011. */
  27012. readonly textureType: number;
  27013. /**
  27014. * Get the texture underlying format (RGB, RGBA...)
  27015. */
  27016. readonly textureFormat: number;
  27017. /**
  27018. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27019. * This will returns an RGBA array buffer containing either in values (0-255) or
  27020. * float values (0-1) depending of the underlying buffer type.
  27021. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27022. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27023. * @param buffer defines a user defined buffer to fill with data (can be null)
  27024. * @returns The Array buffer containing the pixels data.
  27025. */
  27026. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27027. /**
  27028. * Release and destroy the underlying lower level texture aka internalTexture.
  27029. */
  27030. releaseInternalTexture(): void;
  27031. /**
  27032. * Get the polynomial representation of the texture data.
  27033. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27034. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27035. */
  27036. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27037. /** @hidden */
  27038. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27039. /** @hidden */
  27040. readonly _lodTextureMid: Nullable<BaseTexture>;
  27041. /** @hidden */
  27042. readonly _lodTextureLow: Nullable<BaseTexture>;
  27043. /**
  27044. * Dispose the texture and release its associated resources.
  27045. */
  27046. dispose(): void;
  27047. /**
  27048. * Serialize the texture into a JSON representation that can be parsed later on.
  27049. * @returns the JSON representation of the texture
  27050. */
  27051. serialize(): any;
  27052. /**
  27053. * Helper function to be called back once a list of texture contains only ready textures.
  27054. * @param textures Define the list of textures to wait for
  27055. * @param callback Define the callback triggered once the entire list will be ready
  27056. */
  27057. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27058. }
  27059. }
  27060. declare module "babylonjs/Materials/uniformBuffer" {
  27061. import { Nullable, FloatArray } from "babylonjs/types";
  27062. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27063. import { Engine } from "babylonjs/Engines/engine";
  27064. import { Effect } from "babylonjs/Materials/effect";
  27065. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27066. /**
  27067. * Uniform buffer objects.
  27068. *
  27069. * Handles blocks of uniform on the GPU.
  27070. *
  27071. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27072. *
  27073. * For more information, please refer to :
  27074. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27075. */
  27076. export class UniformBuffer {
  27077. private _engine;
  27078. private _buffer;
  27079. private _data;
  27080. private _bufferData;
  27081. private _dynamic?;
  27082. private _uniformLocations;
  27083. private _uniformSizes;
  27084. private _uniformLocationPointer;
  27085. private _needSync;
  27086. private _noUBO;
  27087. private _currentEffect;
  27088. private static _MAX_UNIFORM_SIZE;
  27089. private static _tempBuffer;
  27090. /**
  27091. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27092. * This is dynamic to allow compat with webgl 1 and 2.
  27093. * You will need to pass the name of the uniform as well as the value.
  27094. */
  27095. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27096. /**
  27097. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27098. * This is dynamic to allow compat with webgl 1 and 2.
  27099. * You will need to pass the name of the uniform as well as the value.
  27100. */
  27101. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27102. /**
  27103. * Lambda to Update a single float in a uniform buffer.
  27104. * This is dynamic to allow compat with webgl 1 and 2.
  27105. * You will need to pass the name of the uniform as well as the value.
  27106. */
  27107. updateFloat: (name: string, x: number) => void;
  27108. /**
  27109. * Lambda to Update a vec2 of float in a uniform buffer.
  27110. * This is dynamic to allow compat with webgl 1 and 2.
  27111. * You will need to pass the name of the uniform as well as the value.
  27112. */
  27113. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27114. /**
  27115. * Lambda to Update a vec3 of float in a uniform buffer.
  27116. * This is dynamic to allow compat with webgl 1 and 2.
  27117. * You will need to pass the name of the uniform as well as the value.
  27118. */
  27119. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27120. /**
  27121. * Lambda to Update a vec4 of float in a uniform buffer.
  27122. * This is dynamic to allow compat with webgl 1 and 2.
  27123. * You will need to pass the name of the uniform as well as the value.
  27124. */
  27125. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27126. /**
  27127. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27128. * This is dynamic to allow compat with webgl 1 and 2.
  27129. * You will need to pass the name of the uniform as well as the value.
  27130. */
  27131. updateMatrix: (name: string, mat: Matrix) => void;
  27132. /**
  27133. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27134. * This is dynamic to allow compat with webgl 1 and 2.
  27135. * You will need to pass the name of the uniform as well as the value.
  27136. */
  27137. updateVector3: (name: string, vector: Vector3) => void;
  27138. /**
  27139. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27140. * This is dynamic to allow compat with webgl 1 and 2.
  27141. * You will need to pass the name of the uniform as well as the value.
  27142. */
  27143. updateVector4: (name: string, vector: Vector4) => void;
  27144. /**
  27145. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27146. * This is dynamic to allow compat with webgl 1 and 2.
  27147. * You will need to pass the name of the uniform as well as the value.
  27148. */
  27149. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27150. /**
  27151. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27152. * This is dynamic to allow compat with webgl 1 and 2.
  27153. * You will need to pass the name of the uniform as well as the value.
  27154. */
  27155. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27156. /**
  27157. * Instantiates a new Uniform buffer objects.
  27158. *
  27159. * Handles blocks of uniform on the GPU.
  27160. *
  27161. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27162. *
  27163. * For more information, please refer to :
  27164. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27165. * @param engine Define the engine the buffer is associated with
  27166. * @param data Define the data contained in the buffer
  27167. * @param dynamic Define if the buffer is updatable
  27168. */
  27169. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27170. /**
  27171. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27172. * or just falling back on setUniformXXX calls.
  27173. */
  27174. readonly useUbo: boolean;
  27175. /**
  27176. * Indicates if the WebGL underlying uniform buffer is in sync
  27177. * with the javascript cache data.
  27178. */
  27179. readonly isSync: boolean;
  27180. /**
  27181. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27182. * Also, a dynamic UniformBuffer will disable cache verification and always
  27183. * update the underlying WebGL uniform buffer to the GPU.
  27184. * @returns if Dynamic, otherwise false
  27185. */
  27186. isDynamic(): boolean;
  27187. /**
  27188. * The data cache on JS side.
  27189. * @returns the underlying data as a float array
  27190. */
  27191. getData(): Float32Array;
  27192. /**
  27193. * The underlying WebGL Uniform buffer.
  27194. * @returns the webgl buffer
  27195. */
  27196. getBuffer(): Nullable<WebGLBuffer>;
  27197. /**
  27198. * std140 layout specifies how to align data within an UBO structure.
  27199. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27200. * for specs.
  27201. */
  27202. private _fillAlignment;
  27203. /**
  27204. * Adds an uniform in the buffer.
  27205. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27206. * for the layout to be correct !
  27207. * @param name Name of the uniform, as used in the uniform block in the shader.
  27208. * @param size Data size, or data directly.
  27209. */
  27210. addUniform(name: string, size: number | number[]): void;
  27211. /**
  27212. * Adds a Matrix 4x4 to the uniform buffer.
  27213. * @param name Name of the uniform, as used in the uniform block in the shader.
  27214. * @param mat A 4x4 matrix.
  27215. */
  27216. addMatrix(name: string, mat: Matrix): void;
  27217. /**
  27218. * Adds a vec2 to the uniform buffer.
  27219. * @param name Name of the uniform, as used in the uniform block in the shader.
  27220. * @param x Define the x component value of the vec2
  27221. * @param y Define the y component value of the vec2
  27222. */
  27223. addFloat2(name: string, x: number, y: number): void;
  27224. /**
  27225. * Adds a vec3 to the uniform buffer.
  27226. * @param name Name of the uniform, as used in the uniform block in the shader.
  27227. * @param x Define the x component value of the vec3
  27228. * @param y Define the y component value of the vec3
  27229. * @param z Define the z component value of the vec3
  27230. */
  27231. addFloat3(name: string, x: number, y: number, z: number): void;
  27232. /**
  27233. * Adds a vec3 to the uniform buffer.
  27234. * @param name Name of the uniform, as used in the uniform block in the shader.
  27235. * @param color Define the vec3 from a Color
  27236. */
  27237. addColor3(name: string, color: Color3): void;
  27238. /**
  27239. * Adds a vec4 to the uniform buffer.
  27240. * @param name Name of the uniform, as used in the uniform block in the shader.
  27241. * @param color Define the rgb components from a Color
  27242. * @param alpha Define the a component of the vec4
  27243. */
  27244. addColor4(name: string, color: Color3, alpha: number): void;
  27245. /**
  27246. * Adds a vec3 to the uniform buffer.
  27247. * @param name Name of the uniform, as used in the uniform block in the shader.
  27248. * @param vector Define the vec3 components from a Vector
  27249. */
  27250. addVector3(name: string, vector: Vector3): void;
  27251. /**
  27252. * Adds a Matrix 3x3 to the uniform buffer.
  27253. * @param name Name of the uniform, as used in the uniform block in the shader.
  27254. */
  27255. addMatrix3x3(name: string): void;
  27256. /**
  27257. * Adds a Matrix 2x2 to the uniform buffer.
  27258. * @param name Name of the uniform, as used in the uniform block in the shader.
  27259. */
  27260. addMatrix2x2(name: string): void;
  27261. /**
  27262. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27263. */
  27264. create(): void;
  27265. /** @hidden */
  27266. _rebuild(): void;
  27267. /**
  27268. * Updates the WebGL Uniform Buffer on the GPU.
  27269. * If the `dynamic` flag is set to true, no cache comparison is done.
  27270. * Otherwise, the buffer will be updated only if the cache differs.
  27271. */
  27272. update(): void;
  27273. /**
  27274. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27275. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27276. * @param data Define the flattened data
  27277. * @param size Define the size of the data.
  27278. */
  27279. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27280. private _updateMatrix3x3ForUniform;
  27281. private _updateMatrix3x3ForEffect;
  27282. private _updateMatrix2x2ForEffect;
  27283. private _updateMatrix2x2ForUniform;
  27284. private _updateFloatForEffect;
  27285. private _updateFloatForUniform;
  27286. private _updateFloat2ForEffect;
  27287. private _updateFloat2ForUniform;
  27288. private _updateFloat3ForEffect;
  27289. private _updateFloat3ForUniform;
  27290. private _updateFloat4ForEffect;
  27291. private _updateFloat4ForUniform;
  27292. private _updateMatrixForEffect;
  27293. private _updateMatrixForUniform;
  27294. private _updateVector3ForEffect;
  27295. private _updateVector3ForUniform;
  27296. private _updateVector4ForEffect;
  27297. private _updateVector4ForUniform;
  27298. private _updateColor3ForEffect;
  27299. private _updateColor3ForUniform;
  27300. private _updateColor4ForEffect;
  27301. private _updateColor4ForUniform;
  27302. /**
  27303. * Sets a sampler uniform on the effect.
  27304. * @param name Define the name of the sampler.
  27305. * @param texture Define the texture to set in the sampler
  27306. */
  27307. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27308. /**
  27309. * Directly updates the value of the uniform in the cache AND on the GPU.
  27310. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27311. * @param data Define the flattened data
  27312. */
  27313. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27314. /**
  27315. * Binds this uniform buffer to an effect.
  27316. * @param effect Define the effect to bind the buffer to
  27317. * @param name Name of the uniform block in the shader.
  27318. */
  27319. bindToEffect(effect: Effect, name: string): void;
  27320. /**
  27321. * Disposes the uniform buffer.
  27322. */
  27323. dispose(): void;
  27324. }
  27325. }
  27326. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  27327. import { Nullable } from "babylonjs/types";
  27328. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27329. /**
  27330. * This represents the required contract to create a new type of texture loader.
  27331. */
  27332. export interface IInternalTextureLoader {
  27333. /**
  27334. * Defines wether the loader supports cascade loading the different faces.
  27335. */
  27336. supportCascades: boolean;
  27337. /**
  27338. * This returns if the loader support the current file information.
  27339. * @param extension defines the file extension of the file being loaded
  27340. * @param textureFormatInUse defines the current compressed format in use iun the engine
  27341. * @param fallback defines the fallback internal texture if any
  27342. * @param isBase64 defines whether the texture is encoded as a base64
  27343. * @param isBuffer defines whether the texture data are stored as a buffer
  27344. * @returns true if the loader can load the specified file
  27345. */
  27346. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  27347. /**
  27348. * Transform the url before loading if required.
  27349. * @param rootUrl the url of the texture
  27350. * @param textureFormatInUse defines the current compressed format in use iun the engine
  27351. * @returns the transformed texture
  27352. */
  27353. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  27354. /**
  27355. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  27356. * @param rootUrl the url of the texture
  27357. * @param textureFormatInUse defines the current compressed format in use iun the engine
  27358. * @returns the fallback texture
  27359. */
  27360. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  27361. /**
  27362. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  27363. * @param data contains the texture data
  27364. * @param texture defines the BabylonJS internal texture
  27365. * @param createPolynomials will be true if polynomials have been requested
  27366. * @param onLoad defines the callback to trigger once the texture is ready
  27367. * @param onError defines the callback to trigger in case of error
  27368. */
  27369. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  27370. /**
  27371. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  27372. * @param data contains the texture data
  27373. * @param texture defines the BabylonJS internal texture
  27374. * @param callback defines the method to call once ready to upload
  27375. */
  27376. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  27377. }
  27378. }
  27379. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  27380. import { Scene } from "babylonjs/scene";
  27381. import { Engine } from "babylonjs/Engines/engine";
  27382. import { Texture } from "babylonjs/Materials/Textures/texture";
  27383. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27384. /**
  27385. * Creation options of the multi render target texture.
  27386. */
  27387. export interface IMultiRenderTargetOptions {
  27388. /**
  27389. * Define if the texture needs to create mip maps after render.
  27390. */
  27391. generateMipMaps?: boolean;
  27392. /**
  27393. * Define the types of all the draw buffers we want to create
  27394. */
  27395. types?: number[];
  27396. /**
  27397. * Define the sampling modes of all the draw buffers we want to create
  27398. */
  27399. samplingModes?: number[];
  27400. /**
  27401. * Define if a depth buffer is required
  27402. */
  27403. generateDepthBuffer?: boolean;
  27404. /**
  27405. * Define if a stencil buffer is required
  27406. */
  27407. generateStencilBuffer?: boolean;
  27408. /**
  27409. * Define if a depth texture is required instead of a depth buffer
  27410. */
  27411. generateDepthTexture?: boolean;
  27412. /**
  27413. * Define the number of desired draw buffers
  27414. */
  27415. textureCount?: number;
  27416. /**
  27417. * Define if aspect ratio should be adapted to the texture or stay the scene one
  27418. */
  27419. doNotChangeAspectRatio?: boolean;
  27420. /**
  27421. * Define the default type of the buffers we are creating
  27422. */
  27423. defaultType?: number;
  27424. }
  27425. /**
  27426. * A multi render target, like a render target provides the ability to render to a texture.
  27427. * Unlike the render target, it can render to several draw buffers in one draw.
  27428. * This is specially interesting in deferred rendering or for any effects requiring more than
  27429. * just one color from a single pass.
  27430. */
  27431. export class MultiRenderTarget extends RenderTargetTexture {
  27432. private _internalTextures;
  27433. private _textures;
  27434. private _multiRenderTargetOptions;
  27435. /**
  27436. * Get if draw buffers are currently supported by the used hardware and browser.
  27437. */
  27438. readonly isSupported: boolean;
  27439. /**
  27440. * Get the list of textures generated by the multi render target.
  27441. */
  27442. readonly textures: Texture[];
  27443. /**
  27444. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  27445. */
  27446. readonly depthTexture: Texture;
  27447. /**
  27448. * Set the wrapping mode on U of all the textures we are rendering to.
  27449. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  27450. */
  27451. wrapU: number;
  27452. /**
  27453. * Set the wrapping mode on V of all the textures we are rendering to.
  27454. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  27455. */
  27456. wrapV: number;
  27457. /**
  27458. * Instantiate a new multi render target texture.
  27459. * A multi render target, like a render target provides the ability to render to a texture.
  27460. * Unlike the render target, it can render to several draw buffers in one draw.
  27461. * This is specially interesting in deferred rendering or for any effects requiring more than
  27462. * just one color from a single pass.
  27463. * @param name Define the name of the texture
  27464. * @param size Define the size of the buffers to render to
  27465. * @param count Define the number of target we are rendering into
  27466. * @param scene Define the scene the texture belongs to
  27467. * @param options Define the options used to create the multi render target
  27468. */
  27469. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  27470. /** @hidden */
  27471. _rebuild(): void;
  27472. private _createInternalTextures;
  27473. private _createTextures;
  27474. /**
  27475. * Define the number of samples used if MSAA is enabled.
  27476. */
  27477. samples: number;
  27478. /**
  27479. * Resize all the textures in the multi render target.
  27480. * Be carrefull as it will recreate all the data in the new texture.
  27481. * @param size Define the new size
  27482. */
  27483. resize(size: any): void;
  27484. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  27485. /**
  27486. * Dispose the render targets and their associated resources
  27487. */
  27488. dispose(): void;
  27489. /**
  27490. * Release all the underlying texture used as draw buffers.
  27491. */
  27492. releaseInternalTextures(): void;
  27493. }
  27494. }
  27495. declare module "babylonjs/Audio/analyser" {
  27496. import { Scene } from "babylonjs/scene";
  27497. /**
  27498. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27500. */
  27501. export class Analyser {
  27502. /**
  27503. * Gets or sets the smoothing
  27504. * @ignorenaming
  27505. */
  27506. SMOOTHING: number;
  27507. /**
  27508. * Gets or sets the FFT table size
  27509. * @ignorenaming
  27510. */
  27511. FFT_SIZE: number;
  27512. /**
  27513. * Gets or sets the bar graph amplitude
  27514. * @ignorenaming
  27515. */
  27516. BARGRAPHAMPLITUDE: number;
  27517. /**
  27518. * Gets or sets the position of the debug canvas
  27519. * @ignorenaming
  27520. */
  27521. DEBUGCANVASPOS: {
  27522. x: number;
  27523. y: number;
  27524. };
  27525. /**
  27526. * Gets or sets the debug canvas size
  27527. * @ignorenaming
  27528. */
  27529. DEBUGCANVASSIZE: {
  27530. width: number;
  27531. height: number;
  27532. };
  27533. private _byteFreqs;
  27534. private _byteTime;
  27535. private _floatFreqs;
  27536. private _webAudioAnalyser;
  27537. private _debugCanvas;
  27538. private _debugCanvasContext;
  27539. private _scene;
  27540. private _registerFunc;
  27541. private _audioEngine;
  27542. /**
  27543. * Creates a new analyser
  27544. * @param scene defines hosting scene
  27545. */
  27546. constructor(scene: Scene);
  27547. /**
  27548. * Get the number of data values you will have to play with for the visualization
  27549. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27550. * @returns a number
  27551. */
  27552. getFrequencyBinCount(): number;
  27553. /**
  27554. * Gets the current frequency data as a byte array
  27555. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27556. * @returns a Uint8Array
  27557. */
  27558. getByteFrequencyData(): Uint8Array;
  27559. /**
  27560. * Gets the current waveform as a byte array
  27561. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27562. * @returns a Uint8Array
  27563. */
  27564. getByteTimeDomainData(): Uint8Array;
  27565. /**
  27566. * Gets the current frequency data as a float array
  27567. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27568. * @returns a Float32Array
  27569. */
  27570. getFloatFrequencyData(): Float32Array;
  27571. /**
  27572. * Renders the debug canvas
  27573. */
  27574. drawDebugCanvas(): void;
  27575. /**
  27576. * Stops rendering the debug canvas and removes it
  27577. */
  27578. stopDebugCanvas(): void;
  27579. /**
  27580. * Connects two audio nodes
  27581. * @param inputAudioNode defines first node to connect
  27582. * @param outputAudioNode defines second node to connect
  27583. */
  27584. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27585. /**
  27586. * Releases all associated resources
  27587. */
  27588. dispose(): void;
  27589. }
  27590. }
  27591. declare module "babylonjs/Audio/audioEngine" {
  27592. import { IDisposable } from "babylonjs/scene";
  27593. import { Analyser } from "babylonjs/Audio/analyser";
  27594. import { Nullable } from "babylonjs/types";
  27595. import { Observable } from "babylonjs/Misc/observable";
  27596. /**
  27597. * This represents an audio engine and it is responsible
  27598. * to play, synchronize and analyse sounds throughout the application.
  27599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27600. */
  27601. export interface IAudioEngine extends IDisposable {
  27602. /**
  27603. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27604. */
  27605. readonly canUseWebAudio: boolean;
  27606. /**
  27607. * Gets the current AudioContext if available.
  27608. */
  27609. readonly audioContext: Nullable<AudioContext>;
  27610. /**
  27611. * The master gain node defines the global audio volume of your audio engine.
  27612. */
  27613. readonly masterGain: GainNode;
  27614. /**
  27615. * Gets whether or not mp3 are supported by your browser.
  27616. */
  27617. readonly isMP3supported: boolean;
  27618. /**
  27619. * Gets whether or not ogg are supported by your browser.
  27620. */
  27621. readonly isOGGsupported: boolean;
  27622. /**
  27623. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27624. * @ignoreNaming
  27625. */
  27626. WarnedWebAudioUnsupported: boolean;
  27627. /**
  27628. * Defines if the audio engine relies on a custom unlocked button.
  27629. * In this case, the embedded button will not be displayed.
  27630. */
  27631. useCustomUnlockedButton: boolean;
  27632. /**
  27633. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27634. */
  27635. readonly unlocked: boolean;
  27636. /**
  27637. * Event raised when audio has been unlocked on the browser.
  27638. */
  27639. onAudioUnlockedObservable: Observable<AudioEngine>;
  27640. /**
  27641. * Event raised when audio has been locked on the browser.
  27642. */
  27643. onAudioLockedObservable: Observable<AudioEngine>;
  27644. /**
  27645. * Flags the audio engine in Locked state.
  27646. * This happens due to new browser policies preventing audio to autoplay.
  27647. */
  27648. lock(): void;
  27649. /**
  27650. * Unlocks the audio engine once a user action has been done on the dom.
  27651. * This is helpful to resume play once browser policies have been satisfied.
  27652. */
  27653. unlock(): void;
  27654. }
  27655. /**
  27656. * This represents the default audio engine used in babylon.
  27657. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27659. */
  27660. export class AudioEngine implements IAudioEngine {
  27661. private _audioContext;
  27662. private _audioContextInitialized;
  27663. private _muteButton;
  27664. private _hostElement;
  27665. /**
  27666. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27667. */
  27668. canUseWebAudio: boolean;
  27669. /**
  27670. * The master gain node defines the global audio volume of your audio engine.
  27671. */
  27672. masterGain: GainNode;
  27673. /**
  27674. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27675. * @ignoreNaming
  27676. */
  27677. WarnedWebAudioUnsupported: boolean;
  27678. /**
  27679. * Gets whether or not mp3 are supported by your browser.
  27680. */
  27681. isMP3supported: boolean;
  27682. /**
  27683. * Gets whether or not ogg are supported by your browser.
  27684. */
  27685. isOGGsupported: boolean;
  27686. /**
  27687. * Gets whether audio has been unlocked on the device.
  27688. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27689. * a user interaction has happened.
  27690. */
  27691. unlocked: boolean;
  27692. /**
  27693. * Defines if the audio engine relies on a custom unlocked button.
  27694. * In this case, the embedded button will not be displayed.
  27695. */
  27696. useCustomUnlockedButton: boolean;
  27697. /**
  27698. * Event raised when audio has been unlocked on the browser.
  27699. */
  27700. onAudioUnlockedObservable: Observable<AudioEngine>;
  27701. /**
  27702. * Event raised when audio has been locked on the browser.
  27703. */
  27704. onAudioLockedObservable: Observable<AudioEngine>;
  27705. /**
  27706. * Gets the current AudioContext if available.
  27707. */
  27708. readonly audioContext: Nullable<AudioContext>;
  27709. private _connectedAnalyser;
  27710. /**
  27711. * Instantiates a new audio engine.
  27712. *
  27713. * There should be only one per page as some browsers restrict the number
  27714. * of audio contexts you can create.
  27715. * @param hostElement defines the host element where to display the mute icon if necessary
  27716. */
  27717. constructor(hostElement?: Nullable<HTMLElement>);
  27718. /**
  27719. * Flags the audio engine in Locked state.
  27720. * This happens due to new browser policies preventing audio to autoplay.
  27721. */
  27722. lock(): void;
  27723. /**
  27724. * Unlocks the audio engine once a user action has been done on the dom.
  27725. * This is helpful to resume play once browser policies have been satisfied.
  27726. */
  27727. unlock(): void;
  27728. private _resumeAudioContext;
  27729. private _initializeAudioContext;
  27730. private _tryToRun;
  27731. private _triggerRunningState;
  27732. private _triggerSuspendedState;
  27733. private _displayMuteButton;
  27734. private _moveButtonToTopLeft;
  27735. private _onResize;
  27736. private _hideMuteButton;
  27737. /**
  27738. * Destroy and release the resources associated with the audio ccontext.
  27739. */
  27740. dispose(): void;
  27741. /**
  27742. * Gets the global volume sets on the master gain.
  27743. * @returns the global volume if set or -1 otherwise
  27744. */
  27745. getGlobalVolume(): number;
  27746. /**
  27747. * Sets the global volume of your experience (sets on the master gain).
  27748. * @param newVolume Defines the new global volume of the application
  27749. */
  27750. setGlobalVolume(newVolume: number): void;
  27751. /**
  27752. * Connect the audio engine to an audio analyser allowing some amazing
  27753. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27755. * @param analyser The analyser to connect to the engine
  27756. */
  27757. connectToAnalyser(analyser: Analyser): void;
  27758. }
  27759. }
  27760. declare module "babylonjs/Loading/loadingScreen" {
  27761. /**
  27762. * Interface used to present a loading screen while loading a scene
  27763. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27764. */
  27765. export interface ILoadingScreen {
  27766. /**
  27767. * Function called to display the loading screen
  27768. */
  27769. displayLoadingUI: () => void;
  27770. /**
  27771. * Function called to hide the loading screen
  27772. */
  27773. hideLoadingUI: () => void;
  27774. /**
  27775. * Gets or sets the color to use for the background
  27776. */
  27777. loadingUIBackgroundColor: string;
  27778. /**
  27779. * Gets or sets the text to display while loading
  27780. */
  27781. loadingUIText: string;
  27782. }
  27783. /**
  27784. * Class used for the default loading screen
  27785. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27786. */
  27787. export class DefaultLoadingScreen implements ILoadingScreen {
  27788. private _renderingCanvas;
  27789. private _loadingText;
  27790. private _loadingDivBackgroundColor;
  27791. private _loadingDiv;
  27792. private _loadingTextDiv;
  27793. /**
  27794. * Creates a new default loading screen
  27795. * @param _renderingCanvas defines the canvas used to render the scene
  27796. * @param _loadingText defines the default text to display
  27797. * @param _loadingDivBackgroundColor defines the default background color
  27798. */
  27799. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27800. /**
  27801. * Function called to display the loading screen
  27802. */
  27803. displayLoadingUI(): void;
  27804. /**
  27805. * Function called to hide the loading screen
  27806. */
  27807. hideLoadingUI(): void;
  27808. /**
  27809. * Gets or sets the text to display while loading
  27810. */
  27811. loadingUIText: string;
  27812. /**
  27813. * Gets or sets the color to use for the background
  27814. */
  27815. loadingUIBackgroundColor: string;
  27816. private _resizeLoadingUI;
  27817. }
  27818. }
  27819. declare module "babylonjs/Materials/Textures/videoTexture" {
  27820. import { Observable } from "babylonjs/Misc/observable";
  27821. import { Nullable } from "babylonjs/types";
  27822. import { Scene } from "babylonjs/scene";
  27823. import { Texture } from "babylonjs/Materials/Textures/texture";
  27824. /**
  27825. * Settings for finer control over video usage
  27826. */
  27827. export interface VideoTextureSettings {
  27828. /**
  27829. * Applies `autoplay` to video, if specified
  27830. */
  27831. autoPlay?: boolean;
  27832. /**
  27833. * Applies `loop` to video, if specified
  27834. */
  27835. loop?: boolean;
  27836. /**
  27837. * Automatically updates internal texture from video at every frame in the render loop
  27838. */
  27839. autoUpdateTexture: boolean;
  27840. /**
  27841. * Image src displayed during the video loading or until the user interacts with the video.
  27842. */
  27843. poster?: string;
  27844. }
  27845. /**
  27846. * If you want to display a video in your scene, this is the special texture for that.
  27847. * This special texture works similar to other textures, with the exception of a few parameters.
  27848. * @see https://doc.babylonjs.com/how_to/video_texture
  27849. */
  27850. export class VideoTexture extends Texture {
  27851. /**
  27852. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27853. */
  27854. readonly autoUpdateTexture: boolean;
  27855. /**
  27856. * The video instance used by the texture internally
  27857. */
  27858. readonly video: HTMLVideoElement;
  27859. private _onUserActionRequestedObservable;
  27860. /**
  27861. * Event triggerd when a dom action is required by the user to play the video.
  27862. * This happens due to recent changes in browser policies preventing video to auto start.
  27863. */
  27864. readonly onUserActionRequestedObservable: Observable<Texture>;
  27865. private _generateMipMaps;
  27866. private _engine;
  27867. private _stillImageCaptured;
  27868. private _displayingPosterTexture;
  27869. private _settings;
  27870. private _createInternalTextureOnEvent;
  27871. /**
  27872. * Creates a video texture.
  27873. * If you want to display a video in your scene, this is the special texture for that.
  27874. * This special texture works similar to other textures, with the exception of a few parameters.
  27875. * @see https://doc.babylonjs.com/how_to/video_texture
  27876. * @param name optional name, will detect from video source, if not defined
  27877. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27878. * @param scene is obviously the current scene.
  27879. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27880. * @param invertY is false by default but can be used to invert video on Y axis
  27881. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27882. * @param settings allows finer control over video usage
  27883. */
  27884. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27885. private _getName;
  27886. private _getVideo;
  27887. private _createInternalTexture;
  27888. private reset;
  27889. /**
  27890. * @hidden Internal method to initiate `update`.
  27891. */
  27892. _rebuild(): void;
  27893. /**
  27894. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27895. */
  27896. update(): void;
  27897. /**
  27898. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27899. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27900. */
  27901. updateTexture(isVisible: boolean): void;
  27902. protected _updateInternalTexture: () => void;
  27903. /**
  27904. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27905. * @param url New url.
  27906. */
  27907. updateURL(url: string): void;
  27908. /**
  27909. * Dispose the texture and release its associated resources.
  27910. */
  27911. dispose(): void;
  27912. /**
  27913. * Creates a video texture straight from your WebCam video feed.
  27914. * @param scene Define the scene the texture should be created in
  27915. * @param onReady Define a callback to triggered once the texture will be ready
  27916. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27917. */
  27918. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27919. minWidth: number;
  27920. maxWidth: number;
  27921. minHeight: number;
  27922. maxHeight: number;
  27923. deviceId: string;
  27924. }): void;
  27925. }
  27926. }
  27927. declare module "babylonjs/Engines/engine" {
  27928. import { Observable } from "babylonjs/Misc/observable";
  27929. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27930. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27931. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27932. import { Camera } from "babylonjs/Cameras/camera";
  27933. import { Scene } from "babylonjs/scene";
  27934. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27935. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27936. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27937. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27938. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27939. import { Material } from "babylonjs/Materials/material";
  27940. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27941. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27942. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27943. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27944. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27945. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27946. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27947. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27948. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27949. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27950. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27951. /**
  27952. * Interface for attribute information associated with buffer instanciation
  27953. */
  27954. export class InstancingAttributeInfo {
  27955. /**
  27956. * Index/offset of the attribute in the vertex shader
  27957. */
  27958. index: number;
  27959. /**
  27960. * size of the attribute, 1, 2, 3 or 4
  27961. */
  27962. attributeSize: number;
  27963. /**
  27964. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27965. * default is FLOAT
  27966. */
  27967. attribyteType: number;
  27968. /**
  27969. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27970. */
  27971. normalized: boolean;
  27972. /**
  27973. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27974. */
  27975. offset: number;
  27976. /**
  27977. * Name of the GLSL attribute, for debugging purpose only
  27978. */
  27979. attributeName: string;
  27980. }
  27981. /**
  27982. * Define options used to create a depth texture
  27983. */
  27984. export class DepthTextureCreationOptions {
  27985. /** Specifies whether or not a stencil should be allocated in the texture */
  27986. generateStencil?: boolean;
  27987. /** Specifies whether or not bilinear filtering is enable on the texture */
  27988. bilinearFiltering?: boolean;
  27989. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27990. comparisonFunction?: number;
  27991. /** Specifies if the created texture is a cube texture */
  27992. isCube?: boolean;
  27993. }
  27994. /**
  27995. * Class used to describe the capabilities of the engine relatively to the current browser
  27996. */
  27997. export class EngineCapabilities {
  27998. /** Maximum textures units per fragment shader */
  27999. maxTexturesImageUnits: number;
  28000. /** Maximum texture units per vertex shader */
  28001. maxVertexTextureImageUnits: number;
  28002. /** Maximum textures units in the entire pipeline */
  28003. maxCombinedTexturesImageUnits: number;
  28004. /** Maximum texture size */
  28005. maxTextureSize: number;
  28006. /** Maximum cube texture size */
  28007. maxCubemapTextureSize: number;
  28008. /** Maximum render texture size */
  28009. maxRenderTextureSize: number;
  28010. /** Maximum number of vertex attributes */
  28011. maxVertexAttribs: number;
  28012. /** Maximum number of varyings */
  28013. maxVaryingVectors: number;
  28014. /** Maximum number of uniforms per vertex shader */
  28015. maxVertexUniformVectors: number;
  28016. /** Maximum number of uniforms per fragment shader */
  28017. maxFragmentUniformVectors: number;
  28018. /** Defines if standard derivates (dx/dy) are supported */
  28019. standardDerivatives: boolean;
  28020. /** Defines if s3tc texture compression is supported */
  28021. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28022. /** Defines if pvrtc texture compression is supported */
  28023. pvrtc: any;
  28024. /** Defines if etc1 texture compression is supported */
  28025. etc1: any;
  28026. /** Defines if etc2 texture compression is supported */
  28027. etc2: any;
  28028. /** Defines if astc texture compression is supported */
  28029. astc: any;
  28030. /** Defines if float textures are supported */
  28031. textureFloat: boolean;
  28032. /** Defines if vertex array objects are supported */
  28033. vertexArrayObject: boolean;
  28034. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28035. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28036. /** Gets the maximum level of anisotropy supported */
  28037. maxAnisotropy: number;
  28038. /** Defines if instancing is supported */
  28039. instancedArrays: boolean;
  28040. /** Defines if 32 bits indices are supported */
  28041. uintIndices: boolean;
  28042. /** Defines if high precision shaders are supported */
  28043. highPrecisionShaderSupported: boolean;
  28044. /** Defines if depth reading in the fragment shader is supported */
  28045. fragmentDepthSupported: boolean;
  28046. /** Defines if float texture linear filtering is supported*/
  28047. textureFloatLinearFiltering: boolean;
  28048. /** Defines if rendering to float textures is supported */
  28049. textureFloatRender: boolean;
  28050. /** Defines if half float textures are supported*/
  28051. textureHalfFloat: boolean;
  28052. /** Defines if half float texture linear filtering is supported*/
  28053. textureHalfFloatLinearFiltering: boolean;
  28054. /** Defines if rendering to half float textures is supported */
  28055. textureHalfFloatRender: boolean;
  28056. /** Defines if textureLOD shader command is supported */
  28057. textureLOD: boolean;
  28058. /** Defines if draw buffers extension is supported */
  28059. drawBuffersExtension: boolean;
  28060. /** Defines if depth textures are supported */
  28061. depthTextureExtension: boolean;
  28062. /** Defines if float color buffer are supported */
  28063. colorBufferFloat: boolean;
  28064. /** Gets disjoint timer query extension (null if not supported) */
  28065. timerQuery: EXT_disjoint_timer_query;
  28066. /** Defines if timestamp can be used with timer query */
  28067. canUseTimestampForTimerQuery: boolean;
  28068. /** Function used to let the system compiles shaders in background */
  28069. parallelShaderCompile: {
  28070. MAX_SHADER_COMPILER_THREADS_KHR: number;
  28071. maxShaderCompilerThreadsKHR: (thread: number) => void;
  28072. COMPLETION_STATUS_KHR: number;
  28073. };
  28074. }
  28075. /** Interface defining initialization parameters for Engine class */
  28076. export interface EngineOptions extends WebGLContextAttributes {
  28077. /**
  28078. * Defines if the engine should no exceed a specified device ratio
  28079. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28080. */
  28081. limitDeviceRatio?: number;
  28082. /**
  28083. * Defines if webvr should be enabled automatically
  28084. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28085. */
  28086. autoEnableWebVR?: boolean;
  28087. /**
  28088. * Defines if webgl2 should be turned off even if supported
  28089. * @see http://doc.babylonjs.com/features/webgl2
  28090. */
  28091. disableWebGL2Support?: boolean;
  28092. /**
  28093. * Defines if webaudio should be initialized as well
  28094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28095. */
  28096. audioEngine?: boolean;
  28097. /**
  28098. * Defines if animations should run using a deterministic lock step
  28099. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28100. */
  28101. deterministicLockstep?: boolean;
  28102. /** Defines the maximum steps to use with deterministic lock step mode */
  28103. lockstepMaxSteps?: number;
  28104. /**
  28105. * Defines that engine should ignore context lost events
  28106. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28107. */
  28108. doNotHandleContextLost?: boolean;
  28109. /**
  28110. * Defines that engine should ignore modifying touch action attribute and style
  28111. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28112. */
  28113. doNotHandleTouchAction?: boolean;
  28114. }
  28115. /**
  28116. * Defines the interface used by display changed events
  28117. */
  28118. export interface IDisplayChangedEventArgs {
  28119. /** Gets the vrDisplay object (if any) */
  28120. vrDisplay: Nullable<any>;
  28121. /** Gets a boolean indicating if webVR is supported */
  28122. vrSupported: boolean;
  28123. }
  28124. /**
  28125. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28126. */
  28127. export class Engine {
  28128. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28129. static ExceptionList: ({
  28130. key: string;
  28131. capture: string;
  28132. captureConstraint: number;
  28133. targets: string[];
  28134. } | {
  28135. key: string;
  28136. capture: null;
  28137. captureConstraint: null;
  28138. targets: string[];
  28139. })[];
  28140. /** Gets the list of created engines */
  28141. static readonly Instances: Engine[];
  28142. /**
  28143. * Gets the latest created engine
  28144. */
  28145. static readonly LastCreatedEngine: Nullable<Engine>;
  28146. /**
  28147. * Gets the latest created scene
  28148. */
  28149. static readonly LastCreatedScene: Nullable<Scene>;
  28150. /**
  28151. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28152. * @param flag defines which part of the materials must be marked as dirty
  28153. * @param predicate defines a predicate used to filter which materials should be affected
  28154. */
  28155. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28156. /**
  28157. * Hidden
  28158. */
  28159. static _TextureLoaders: IInternalTextureLoader[];
  28160. /** Defines that alpha blending is disabled */
  28161. static readonly ALPHA_DISABLE: number;
  28162. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28163. static readonly ALPHA_ADD: number;
  28164. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28165. static readonly ALPHA_COMBINE: number;
  28166. /** Defines that alpha blending to DEST - SRC * DEST */
  28167. static readonly ALPHA_SUBTRACT: number;
  28168. /** Defines that alpha blending to SRC * DEST */
  28169. static readonly ALPHA_MULTIPLY: number;
  28170. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28171. static readonly ALPHA_MAXIMIZED: number;
  28172. /** Defines that alpha blending to SRC + DEST */
  28173. static readonly ALPHA_ONEONE: number;
  28174. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28175. static readonly ALPHA_PREMULTIPLIED: number;
  28176. /**
  28177. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28178. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28179. */
  28180. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28181. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28182. static readonly ALPHA_INTERPOLATE: number;
  28183. /**
  28184. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28185. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28186. */
  28187. static readonly ALPHA_SCREENMODE: number;
  28188. /** Defines that the ressource is not delayed*/
  28189. static readonly DELAYLOADSTATE_NONE: number;
  28190. /** Defines that the ressource was successfully delay loaded */
  28191. static readonly DELAYLOADSTATE_LOADED: number;
  28192. /** Defines that the ressource is currently delay loading */
  28193. static readonly DELAYLOADSTATE_LOADING: number;
  28194. /** Defines that the ressource is delayed and has not started loading */
  28195. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28196. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28197. static readonly NEVER: number;
  28198. /** 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 */
  28199. static readonly ALWAYS: number;
  28200. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28201. static readonly LESS: number;
  28202. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28203. static readonly EQUAL: number;
  28204. /** 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 */
  28205. static readonly LEQUAL: number;
  28206. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28207. static readonly GREATER: number;
  28208. /** 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 */
  28209. static readonly GEQUAL: number;
  28210. /** 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 */
  28211. static readonly NOTEQUAL: number;
  28212. /** Passed to stencilOperation to specify that stencil value must be kept */
  28213. static readonly KEEP: number;
  28214. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28215. static readonly REPLACE: number;
  28216. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28217. static readonly INCR: number;
  28218. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28219. static readonly DECR: number;
  28220. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28221. static readonly INVERT: number;
  28222. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28223. static readonly INCR_WRAP: number;
  28224. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28225. static readonly DECR_WRAP: number;
  28226. /** Texture is not repeating outside of 0..1 UVs */
  28227. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28228. /** Texture is repeating outside of 0..1 UVs */
  28229. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28230. /** Texture is repeating and mirrored */
  28231. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28232. /** ALPHA */
  28233. static readonly TEXTUREFORMAT_ALPHA: number;
  28234. /** LUMINANCE */
  28235. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28236. /** LUMINANCE_ALPHA */
  28237. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28238. /** RGB */
  28239. static readonly TEXTUREFORMAT_RGB: number;
  28240. /** RGBA */
  28241. static readonly TEXTUREFORMAT_RGBA: number;
  28242. /** RED */
  28243. static readonly TEXTUREFORMAT_RED: number;
  28244. /** RED (2nd reference) */
  28245. static readonly TEXTUREFORMAT_R: number;
  28246. /** RG */
  28247. static readonly TEXTUREFORMAT_RG: number;
  28248. /** RED_INTEGER */
  28249. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28250. /** RED_INTEGER (2nd reference) */
  28251. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28252. /** RG_INTEGER */
  28253. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28254. /** RGB_INTEGER */
  28255. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28256. /** RGBA_INTEGER */
  28257. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28258. /** UNSIGNED_BYTE */
  28259. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28260. /** UNSIGNED_BYTE (2nd reference) */
  28261. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28262. /** FLOAT */
  28263. static readonly TEXTURETYPE_FLOAT: number;
  28264. /** HALF_FLOAT */
  28265. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28266. /** BYTE */
  28267. static readonly TEXTURETYPE_BYTE: number;
  28268. /** SHORT */
  28269. static readonly TEXTURETYPE_SHORT: number;
  28270. /** UNSIGNED_SHORT */
  28271. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28272. /** INT */
  28273. static readonly TEXTURETYPE_INT: number;
  28274. /** UNSIGNED_INT */
  28275. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28276. /** UNSIGNED_SHORT_4_4_4_4 */
  28277. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28278. /** UNSIGNED_SHORT_5_5_5_1 */
  28279. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28280. /** UNSIGNED_SHORT_5_6_5 */
  28281. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28282. /** UNSIGNED_INT_2_10_10_10_REV */
  28283. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28284. /** UNSIGNED_INT_24_8 */
  28285. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28286. /** UNSIGNED_INT_10F_11F_11F_REV */
  28287. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28288. /** UNSIGNED_INT_5_9_9_9_REV */
  28289. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28290. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28291. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28292. /** nearest is mag = nearest and min = nearest and mip = linear */
  28293. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28294. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28295. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28296. /** Trilinear is mag = linear and min = linear and mip = linear */
  28297. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28298. /** nearest is mag = nearest and min = nearest and mip = linear */
  28299. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28300. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28301. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28302. /** Trilinear is mag = linear and min = linear and mip = linear */
  28303. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28304. /** mag = nearest and min = nearest and mip = nearest */
  28305. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28306. /** mag = nearest and min = linear and mip = nearest */
  28307. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28308. /** mag = nearest and min = linear and mip = linear */
  28309. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28310. /** mag = nearest and min = linear and mip = none */
  28311. static readonly TEXTURE_NEAREST_LINEAR: number;
  28312. /** mag = nearest and min = nearest and mip = none */
  28313. static readonly TEXTURE_NEAREST_NEAREST: number;
  28314. /** mag = linear and min = nearest and mip = nearest */
  28315. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28316. /** mag = linear and min = nearest and mip = linear */
  28317. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28318. /** mag = linear and min = linear and mip = none */
  28319. static readonly TEXTURE_LINEAR_LINEAR: number;
  28320. /** mag = linear and min = nearest and mip = none */
  28321. static readonly TEXTURE_LINEAR_NEAREST: number;
  28322. /** Explicit coordinates mode */
  28323. static readonly TEXTURE_EXPLICIT_MODE: number;
  28324. /** Spherical coordinates mode */
  28325. static readonly TEXTURE_SPHERICAL_MODE: number;
  28326. /** Planar coordinates mode */
  28327. static readonly TEXTURE_PLANAR_MODE: number;
  28328. /** Cubic coordinates mode */
  28329. static readonly TEXTURE_CUBIC_MODE: number;
  28330. /** Projection coordinates mode */
  28331. static readonly TEXTURE_PROJECTION_MODE: number;
  28332. /** Skybox coordinates mode */
  28333. static readonly TEXTURE_SKYBOX_MODE: number;
  28334. /** Inverse Cubic coordinates mode */
  28335. static readonly TEXTURE_INVCUBIC_MODE: number;
  28336. /** Equirectangular coordinates mode */
  28337. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28338. /** Equirectangular Fixed coordinates mode */
  28339. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28340. /** Equirectangular Fixed Mirrored coordinates mode */
  28341. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28342. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28343. static readonly SCALEMODE_FLOOR: number;
  28344. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28345. static readonly SCALEMODE_NEAREST: number;
  28346. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28347. static readonly SCALEMODE_CEILING: number;
  28348. /**
  28349. * Returns the current version of the framework
  28350. */
  28351. static readonly Version: string;
  28352. /**
  28353. * Returns a string describing the current engine
  28354. */
  28355. readonly description: string;
  28356. /**
  28357. * Gets or sets the epsilon value used by collision engine
  28358. */
  28359. static CollisionsEpsilon: number;
  28360. /**
  28361. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28362. */
  28363. static ShadersRepository: string;
  28364. /**
  28365. * Method called to create the default loading screen.
  28366. * This can be overriden in your own app.
  28367. * @param canvas The rendering canvas element
  28368. * @returns The loading screen
  28369. */
  28370. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28371. /**
  28372. * Method called to create the default rescale post process on each engine.
  28373. */
  28374. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28375. /**
  28376. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28377. */
  28378. forcePOTTextures: boolean;
  28379. /**
  28380. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28381. */
  28382. isFullscreen: boolean;
  28383. /**
  28384. * Gets a boolean indicating if the pointer is currently locked
  28385. */
  28386. isPointerLock: boolean;
  28387. /**
  28388. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28389. */
  28390. cullBackFaces: boolean;
  28391. /**
  28392. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28393. */
  28394. renderEvenInBackground: boolean;
  28395. /**
  28396. * Gets or sets a boolean indicating that cache can be kept between frames
  28397. */
  28398. preventCacheWipeBetweenFrames: boolean;
  28399. /**
  28400. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28401. **/
  28402. enableOfflineSupport: boolean;
  28403. /**
  28404. * 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)
  28405. **/
  28406. disableManifestCheck: boolean;
  28407. /**
  28408. * Gets the list of created scenes
  28409. */
  28410. scenes: Scene[];
  28411. /**
  28412. * Event raised when a new scene is created
  28413. */
  28414. onNewSceneAddedObservable: Observable<Scene>;
  28415. /**
  28416. * Gets the list of created postprocesses
  28417. */
  28418. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28419. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28420. validateShaderPrograms: boolean;
  28421. /**
  28422. * Observable event triggered each time the rendering canvas is resized
  28423. */
  28424. onResizeObservable: Observable<Engine>;
  28425. /**
  28426. * Observable event triggered each time the canvas loses focus
  28427. */
  28428. onCanvasBlurObservable: Observable<Engine>;
  28429. /**
  28430. * Observable event triggered each time the canvas gains focus
  28431. */
  28432. onCanvasFocusObservable: Observable<Engine>;
  28433. /**
  28434. * Observable event triggered each time the canvas receives pointerout event
  28435. */
  28436. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28437. /**
  28438. * Observable event triggered before each texture is initialized
  28439. */
  28440. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28441. private _vrDisplay;
  28442. private _vrSupported;
  28443. private _oldSize;
  28444. private _oldHardwareScaleFactor;
  28445. private _vrExclusivePointerMode;
  28446. private _webVRInitPromise;
  28447. /**
  28448. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28449. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28450. */
  28451. readonly isInVRExclusivePointerMode: boolean;
  28452. /**
  28453. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28454. */
  28455. disableUniformBuffers: boolean;
  28456. /** @hidden */
  28457. _uniformBuffers: UniformBuffer[];
  28458. /**
  28459. * Gets a boolean indicating that the engine supports uniform buffers
  28460. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28461. */
  28462. readonly supportsUniformBuffers: boolean;
  28463. /**
  28464. * Observable raised when the engine begins a new frame
  28465. */
  28466. onBeginFrameObservable: Observable<Engine>;
  28467. /**
  28468. * If set, will be used to request the next animation frame for the render loop
  28469. */
  28470. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28471. /**
  28472. * Observable raised when the engine ends the current frame
  28473. */
  28474. onEndFrameObservable: Observable<Engine>;
  28475. /**
  28476. * Observable raised when the engine is about to compile a shader
  28477. */
  28478. onBeforeShaderCompilationObservable: Observable<Engine>;
  28479. /**
  28480. * Observable raised when the engine has jsut compiled a shader
  28481. */
  28482. onAfterShaderCompilationObservable: Observable<Engine>;
  28483. /** @hidden */
  28484. _gl: WebGLRenderingContext;
  28485. private _renderingCanvas;
  28486. private _windowIsBackground;
  28487. private _webGLVersion;
  28488. /**
  28489. * Gets a boolean indicating that only power of 2 textures are supported
  28490. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28491. */
  28492. readonly needPOTTextures: boolean;
  28493. /** @hidden */
  28494. _badOS: boolean;
  28495. /** @hidden */
  28496. _badDesktopOS: boolean;
  28497. /**
  28498. * Gets or sets a value indicating if we want to disable texture binding optimization.
  28499. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  28500. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  28501. */
  28502. disableTextureBindingOptimization: boolean;
  28503. /**
  28504. * Gets the audio engine
  28505. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28506. * @ignorenaming
  28507. */
  28508. static audioEngine: IAudioEngine;
  28509. /**
  28510. * Default AudioEngine factory responsible of creating the Audio Engine.
  28511. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28512. */
  28513. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28514. /**
  28515. * Default offline support factory responsible of creating a tool used to store data locally.
  28516. * By default, this will create a Database object if the workload has been embedded.
  28517. */
  28518. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28519. private _onFocus;
  28520. private _onBlur;
  28521. private _onCanvasPointerOut;
  28522. private _onCanvasBlur;
  28523. private _onCanvasFocus;
  28524. private _onFullscreenChange;
  28525. private _onPointerLockChange;
  28526. private _onVRDisplayPointerRestricted;
  28527. private _onVRDisplayPointerUnrestricted;
  28528. private _onVrDisplayConnect;
  28529. private _onVrDisplayDisconnect;
  28530. private _onVrDisplayPresentChange;
  28531. /**
  28532. * Observable signaled when VR display mode changes
  28533. */
  28534. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28535. /**
  28536. * Observable signaled when VR request present is complete
  28537. */
  28538. onVRRequestPresentComplete: Observable<boolean>;
  28539. /**
  28540. * Observable signaled when VR request present starts
  28541. */
  28542. onVRRequestPresentStart: Observable<Engine>;
  28543. private _hardwareScalingLevel;
  28544. /** @hidden */
  28545. protected _caps: EngineCapabilities;
  28546. private _pointerLockRequested;
  28547. private _isStencilEnable;
  28548. private _colorWrite;
  28549. private _loadingScreen;
  28550. /** @hidden */
  28551. _drawCalls: PerfCounter;
  28552. /** @hidden */
  28553. _textureCollisions: PerfCounter;
  28554. private _glVersion;
  28555. private _glRenderer;
  28556. private _glVendor;
  28557. private _videoTextureSupported;
  28558. private _renderingQueueLaunched;
  28559. private _activeRenderLoops;
  28560. private _deterministicLockstep;
  28561. private _lockstepMaxSteps;
  28562. /**
  28563. * Observable signaled when a context lost event is raised
  28564. */
  28565. onContextLostObservable: Observable<Engine>;
  28566. /**
  28567. * Observable signaled when a context restored event is raised
  28568. */
  28569. onContextRestoredObservable: Observable<Engine>;
  28570. private _onContextLost;
  28571. private _onContextRestored;
  28572. private _contextWasLost;
  28573. private _doNotHandleContextLost;
  28574. /**
  28575. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28576. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28577. */
  28578. doNotHandleContextLost: boolean;
  28579. private _performanceMonitor;
  28580. private _fps;
  28581. private _deltaTime;
  28582. /**
  28583. * Turn this value on if you want to pause FPS computation when in background
  28584. */
  28585. disablePerformanceMonitorInBackground: boolean;
  28586. /**
  28587. * Gets the performance monitor attached to this engine
  28588. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28589. */
  28590. readonly performanceMonitor: PerformanceMonitor;
  28591. /** @hidden */
  28592. protected _depthCullingState: _DepthCullingState;
  28593. /** @hidden */
  28594. protected _stencilState: _StencilState;
  28595. /** @hidden */
  28596. protected _alphaState: _AlphaState;
  28597. /** @hidden */
  28598. protected _alphaMode: number;
  28599. protected _internalTexturesCache: InternalTexture[];
  28600. /** @hidden */
  28601. protected _activeChannel: number;
  28602. private _currentTextureChannel;
  28603. /** @hidden */
  28604. protected _boundTexturesCache: {
  28605. [key: string]: Nullable<InternalTexture>;
  28606. };
  28607. /** @hidden */
  28608. protected _currentEffect: Nullable<Effect>;
  28609. /** @hidden */
  28610. protected _currentProgram: Nullable<WebGLProgram>;
  28611. private _compiledEffects;
  28612. private _vertexAttribArraysEnabled;
  28613. /** @hidden */
  28614. protected _cachedViewport: Nullable<Viewport>;
  28615. private _cachedVertexArrayObject;
  28616. /** @hidden */
  28617. protected _cachedVertexBuffers: any;
  28618. /** @hidden */
  28619. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28620. /** @hidden */
  28621. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28622. /** @hidden */
  28623. protected _currentRenderTarget: Nullable<InternalTexture>;
  28624. private _uintIndicesCurrentlySet;
  28625. private _currentBoundBuffer;
  28626. /** @hidden */
  28627. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28628. private _currentBufferPointers;
  28629. private _currentInstanceLocations;
  28630. private _currentInstanceBuffers;
  28631. private _textureUnits;
  28632. private _firstBoundInternalTextureTracker;
  28633. private _lastBoundInternalTextureTracker;
  28634. private _workingCanvas;
  28635. private _workingContext;
  28636. private _rescalePostProcess;
  28637. private _dummyFramebuffer;
  28638. private _externalData;
  28639. private _bindedRenderFunction;
  28640. private _vaoRecordInProgress;
  28641. private _mustWipeVertexAttributes;
  28642. private _emptyTexture;
  28643. private _emptyCubeTexture;
  28644. private _emptyTexture3D;
  28645. /** @hidden */
  28646. _frameHandler: number;
  28647. private _nextFreeTextureSlots;
  28648. private _maxSimultaneousTextures;
  28649. private _activeRequests;
  28650. private _texturesSupported;
  28651. private _textureFormatInUse;
  28652. /**
  28653. * Gets the list of texture formats supported
  28654. */
  28655. readonly texturesSupported: Array<string>;
  28656. /**
  28657. * Gets the list of texture formats in use
  28658. */
  28659. readonly textureFormatInUse: Nullable<string>;
  28660. /**
  28661. * Gets the current viewport
  28662. */
  28663. readonly currentViewport: Nullable<Viewport>;
  28664. /**
  28665. * Gets the default empty texture
  28666. */
  28667. readonly emptyTexture: InternalTexture;
  28668. /**
  28669. * Gets the default empty 3D texture
  28670. */
  28671. readonly emptyTexture3D: InternalTexture;
  28672. /**
  28673. * Gets the default empty cube texture
  28674. */
  28675. readonly emptyCubeTexture: InternalTexture;
  28676. /**
  28677. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28678. */
  28679. readonly premultipliedAlpha: boolean;
  28680. /**
  28681. * Creates a new engine
  28682. * @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
  28683. * @param antialias defines enable antialiasing (default: false)
  28684. * @param options defines further options to be sent to the getContext() function
  28685. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28686. */
  28687. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28688. private _disableTouchAction;
  28689. private _rebuildInternalTextures;
  28690. private _rebuildEffects;
  28691. /**
  28692. * Gets a boolean indicating if all created effects are ready
  28693. * @returns true if all effects are ready
  28694. */
  28695. areAllEffectsReady(): boolean;
  28696. private _rebuildBuffers;
  28697. private _initGLContext;
  28698. /**
  28699. * Gets version of the current webGL context
  28700. */
  28701. readonly webGLVersion: number;
  28702. /**
  28703. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28704. */
  28705. readonly isStencilEnable: boolean;
  28706. private _prepareWorkingCanvas;
  28707. /**
  28708. * Reset the texture cache to empty state
  28709. */
  28710. resetTextureCache(): void;
  28711. /**
  28712. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28713. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28714. * @returns true if engine is in deterministic lock step mode
  28715. */
  28716. isDeterministicLockStep(): boolean;
  28717. /**
  28718. * Gets the max steps when engine is running in deterministic lock step
  28719. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28720. * @returns the max steps
  28721. */
  28722. getLockstepMaxSteps(): number;
  28723. /**
  28724. * Gets an object containing information about the current webGL context
  28725. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28726. */
  28727. getGlInfo(): {
  28728. vendor: string;
  28729. renderer: string;
  28730. version: string;
  28731. };
  28732. /**
  28733. * Gets current aspect ratio
  28734. * @param camera defines the camera to use to get the aspect ratio
  28735. * @param useScreen defines if screen size must be used (or the current render target if any)
  28736. * @returns a number defining the aspect ratio
  28737. */
  28738. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28739. /**
  28740. * Gets current screen aspect ratio
  28741. * @returns a number defining the aspect ratio
  28742. */
  28743. getScreenAspectRatio(): number;
  28744. /**
  28745. * Gets the current render width
  28746. * @param useScreen defines if screen size must be used (or the current render target if any)
  28747. * @returns a number defining the current render width
  28748. */
  28749. getRenderWidth(useScreen?: boolean): number;
  28750. /**
  28751. * Gets the current render height
  28752. * @param useScreen defines if screen size must be used (or the current render target if any)
  28753. * @returns a number defining the current render height
  28754. */
  28755. getRenderHeight(useScreen?: boolean): number;
  28756. /**
  28757. * Gets the HTML canvas attached with the current webGL context
  28758. * @returns a HTML canvas
  28759. */
  28760. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28761. /**
  28762. * Gets the client rect of the HTML canvas attached with the current webGL context
  28763. * @returns a client rectanglee
  28764. */
  28765. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28766. /**
  28767. * Defines the hardware scaling level.
  28768. * By default the hardware scaling level is computed from the window device ratio.
  28769. * 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.
  28770. * @param level defines the level to use
  28771. */
  28772. setHardwareScalingLevel(level: number): void;
  28773. /**
  28774. * Gets the current hardware scaling level.
  28775. * By default the hardware scaling level is computed from the window device ratio.
  28776. * 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.
  28777. * @returns a number indicating the current hardware scaling level
  28778. */
  28779. getHardwareScalingLevel(): number;
  28780. /**
  28781. * Gets the list of loaded textures
  28782. * @returns an array containing all loaded textures
  28783. */
  28784. getLoadedTexturesCache(): InternalTexture[];
  28785. /**
  28786. * Gets the object containing all engine capabilities
  28787. * @returns the EngineCapabilities object
  28788. */
  28789. getCaps(): EngineCapabilities;
  28790. /**
  28791. * Gets the current depth function
  28792. * @returns a number defining the depth function
  28793. */
  28794. getDepthFunction(): Nullable<number>;
  28795. /**
  28796. * Sets the current depth function
  28797. * @param depthFunc defines the function to use
  28798. */
  28799. setDepthFunction(depthFunc: number): void;
  28800. /**
  28801. * Sets the current depth function to GREATER
  28802. */
  28803. setDepthFunctionToGreater(): void;
  28804. /**
  28805. * Sets the current depth function to GEQUAL
  28806. */
  28807. setDepthFunctionToGreaterOrEqual(): void;
  28808. /**
  28809. * Sets the current depth function to LESS
  28810. */
  28811. setDepthFunctionToLess(): void;
  28812. /**
  28813. * Sets the current depth function to LEQUAL
  28814. */
  28815. setDepthFunctionToLessOrEqual(): void;
  28816. /**
  28817. * Gets a boolean indicating if stencil buffer is enabled
  28818. * @returns the current stencil buffer state
  28819. */
  28820. getStencilBuffer(): boolean;
  28821. /**
  28822. * Enable or disable the stencil buffer
  28823. * @param enable defines if the stencil buffer must be enabled or disabled
  28824. */
  28825. setStencilBuffer(enable: boolean): void;
  28826. /**
  28827. * Gets the current stencil mask
  28828. * @returns a number defining the new stencil mask to use
  28829. */
  28830. getStencilMask(): number;
  28831. /**
  28832. * Sets the current stencil mask
  28833. * @param mask defines the new stencil mask to use
  28834. */
  28835. setStencilMask(mask: number): void;
  28836. /**
  28837. * Gets the current stencil function
  28838. * @returns a number defining the stencil function to use
  28839. */
  28840. getStencilFunction(): number;
  28841. /**
  28842. * Gets the current stencil reference value
  28843. * @returns a number defining the stencil reference value to use
  28844. */
  28845. getStencilFunctionReference(): number;
  28846. /**
  28847. * Gets the current stencil mask
  28848. * @returns a number defining the stencil mask to use
  28849. */
  28850. getStencilFunctionMask(): number;
  28851. /**
  28852. * Sets the current stencil function
  28853. * @param stencilFunc defines the new stencil function to use
  28854. */
  28855. setStencilFunction(stencilFunc: number): void;
  28856. /**
  28857. * Sets the current stencil reference
  28858. * @param reference defines the new stencil reference to use
  28859. */
  28860. setStencilFunctionReference(reference: number): void;
  28861. /**
  28862. * Sets the current stencil mask
  28863. * @param mask defines the new stencil mask to use
  28864. */
  28865. setStencilFunctionMask(mask: number): void;
  28866. /**
  28867. * Gets the current stencil operation when stencil fails
  28868. * @returns a number defining stencil operation to use when stencil fails
  28869. */
  28870. getStencilOperationFail(): number;
  28871. /**
  28872. * Gets the current stencil operation when depth fails
  28873. * @returns a number defining stencil operation to use when depth fails
  28874. */
  28875. getStencilOperationDepthFail(): number;
  28876. /**
  28877. * Gets the current stencil operation when stencil passes
  28878. * @returns a number defining stencil operation to use when stencil passes
  28879. */
  28880. getStencilOperationPass(): number;
  28881. /**
  28882. * Sets the stencil operation to use when stencil fails
  28883. * @param operation defines the stencil operation to use when stencil fails
  28884. */
  28885. setStencilOperationFail(operation: number): void;
  28886. /**
  28887. * Sets the stencil operation to use when depth fails
  28888. * @param operation defines the stencil operation to use when depth fails
  28889. */
  28890. setStencilOperationDepthFail(operation: number): void;
  28891. /**
  28892. * Sets the stencil operation to use when stencil passes
  28893. * @param operation defines the stencil operation to use when stencil passes
  28894. */
  28895. setStencilOperationPass(operation: number): void;
  28896. /**
  28897. * Sets a boolean indicating if the dithering state is enabled or disabled
  28898. * @param value defines the dithering state
  28899. */
  28900. setDitheringState(value: boolean): void;
  28901. /**
  28902. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28903. * @param value defines the rasterizer state
  28904. */
  28905. setRasterizerState(value: boolean): void;
  28906. /**
  28907. * stop executing a render loop function and remove it from the execution array
  28908. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28909. */
  28910. stopRenderLoop(renderFunction?: () => void): void;
  28911. /** @hidden */
  28912. _renderLoop(): void;
  28913. /**
  28914. * Register and execute a render loop. The engine can have more than one render function
  28915. * @param renderFunction defines the function to continuously execute
  28916. */
  28917. runRenderLoop(renderFunction: () => void): void;
  28918. /**
  28919. * Toggle full screen mode
  28920. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28921. */
  28922. switchFullscreen(requestPointerLock: boolean): void;
  28923. /**
  28924. * Clear the current render buffer or the current render target (if any is set up)
  28925. * @param color defines the color to use
  28926. * @param backBuffer defines if the back buffer must be cleared
  28927. * @param depth defines if the depth buffer must be cleared
  28928. * @param stencil defines if the stencil buffer must be cleared
  28929. */
  28930. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28931. /**
  28932. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28933. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28934. * @param y defines the y-coordinate of the corner of the clear rectangle
  28935. * @param width defines the width of the clear rectangle
  28936. * @param height defines the height of the clear rectangle
  28937. * @param clearColor defines the clear color
  28938. */
  28939. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28940. /**
  28941. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28942. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28943. * @param y defines the y-coordinate of the corner of the clear rectangle
  28944. * @param width defines the width of the clear rectangle
  28945. * @param height defines the height of the clear rectangle
  28946. */
  28947. enableScissor(x: number, y: number, width: number, height: number): void;
  28948. /**
  28949. * Disable previously set scissor test rectangle
  28950. */
  28951. disableScissor(): void;
  28952. private _viewportCached;
  28953. /** @hidden */
  28954. _viewport(x: number, y: number, width: number, height: number): void;
  28955. /**
  28956. * Set the WebGL's viewport
  28957. * @param viewport defines the viewport element to be used
  28958. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28959. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28960. */
  28961. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28962. /**
  28963. * Directly set the WebGL Viewport
  28964. * @param x defines the x coordinate of the viewport (in screen space)
  28965. * @param y defines the y coordinate of the viewport (in screen space)
  28966. * @param width defines the width of the viewport (in screen space)
  28967. * @param height defines the height of the viewport (in screen space)
  28968. * @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
  28969. */
  28970. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28971. /**
  28972. * Begin a new frame
  28973. */
  28974. beginFrame(): void;
  28975. /**
  28976. * Enf the current frame
  28977. */
  28978. endFrame(): void;
  28979. /**
  28980. * Resize the view according to the canvas' size
  28981. */
  28982. resize(): void;
  28983. /**
  28984. * Force a specific size of the canvas
  28985. * @param width defines the new canvas' width
  28986. * @param height defines the new canvas' height
  28987. */
  28988. setSize(width: number, height: number): void;
  28989. /**
  28990. * Gets a boolean indicating if a webVR device was detected
  28991. * @returns true if a webVR device was detected
  28992. */
  28993. isVRDevicePresent(): boolean;
  28994. /**
  28995. * Gets the current webVR device
  28996. * @returns the current webVR device (or null)
  28997. */
  28998. getVRDevice(): any;
  28999. /**
  29000. * Initializes a webVR display and starts listening to display change events
  29001. * The onVRDisplayChangedObservable will be notified upon these changes
  29002. * @returns The onVRDisplayChangedObservable
  29003. */
  29004. initWebVR(): Observable<IDisplayChangedEventArgs>;
  29005. /**
  29006. * Initializes a webVR display and starts listening to display change events
  29007. * The onVRDisplayChangedObservable will be notified upon these changes
  29008. * @returns A promise containing a VRDisplay and if vr is supported
  29009. */
  29010. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  29011. /**
  29012. * Call this function to switch to webVR mode
  29013. * Will do nothing if webVR is not supported or if there is no webVR device
  29014. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29015. */
  29016. enableVR(): void;
  29017. /**
  29018. * Call this function to leave webVR mode
  29019. * Will do nothing if webVR is not supported or if there is no webVR device
  29020. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29021. */
  29022. disableVR(): void;
  29023. private _onVRFullScreenTriggered;
  29024. private _getVRDisplaysAsync;
  29025. /**
  29026. * Binds the frame buffer to the specified texture.
  29027. * @param texture The texture to render to or null for the default canvas
  29028. * @param faceIndex The face of the texture to render to in case of cube texture
  29029. * @param requiredWidth The width of the target to render to
  29030. * @param requiredHeight The height of the target to render to
  29031. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29032. * @param depthStencilTexture The depth stencil texture to use to render
  29033. * @param lodLevel defines le lod level to bind to the frame buffer
  29034. */
  29035. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29036. private bindUnboundFramebuffer;
  29037. /**
  29038. * Unbind the current render target texture from the webGL context
  29039. * @param texture defines the render target texture to unbind
  29040. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29041. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29042. */
  29043. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29044. /**
  29045. * Unbind a list of render target textures from the webGL context
  29046. * This is used only when drawBuffer extension or webGL2 are active
  29047. * @param textures defines the render target textures to unbind
  29048. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29049. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29050. */
  29051. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29052. /**
  29053. * Force the mipmap generation for the given render target texture
  29054. * @param texture defines the render target texture to use
  29055. */
  29056. generateMipMapsForCubemap(texture: InternalTexture): void;
  29057. /**
  29058. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29059. */
  29060. flushFramebuffer(): void;
  29061. /**
  29062. * Unbind the current render target and bind the default framebuffer
  29063. */
  29064. restoreDefaultFramebuffer(): void;
  29065. /**
  29066. * Create an uniform buffer
  29067. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29068. * @param elements defines the content of the uniform buffer
  29069. * @returns the webGL uniform buffer
  29070. */
  29071. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  29072. /**
  29073. * Create a dynamic uniform buffer
  29074. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29075. * @param elements defines the content of the uniform buffer
  29076. * @returns the webGL uniform buffer
  29077. */
  29078. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  29079. /**
  29080. * Update an existing uniform buffer
  29081. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29082. * @param uniformBuffer defines the target uniform buffer
  29083. * @param elements defines the content to update
  29084. * @param offset defines the offset in the uniform buffer where update should start
  29085. * @param count defines the size of the data to update
  29086. */
  29087. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29088. private _resetVertexBufferBinding;
  29089. /**
  29090. * Creates a vertex buffer
  29091. * @param data the data for the vertex buffer
  29092. * @returns the new WebGL static buffer
  29093. */
  29094. createVertexBuffer(data: DataArray): WebGLBuffer;
  29095. /**
  29096. * Creates a dynamic vertex buffer
  29097. * @param data the data for the dynamic vertex buffer
  29098. * @returns the new WebGL dynamic buffer
  29099. */
  29100. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  29101. /**
  29102. * Update a dynamic index buffer
  29103. * @param indexBuffer defines the target index buffer
  29104. * @param indices defines the data to update
  29105. * @param offset defines the offset in the target index buffer where update should start
  29106. */
  29107. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  29108. /**
  29109. * Updates a dynamic vertex buffer.
  29110. * @param vertexBuffer the vertex buffer to update
  29111. * @param data the data used to update the vertex buffer
  29112. * @param byteOffset the byte offset of the data
  29113. * @param byteLength the byte length of the data
  29114. */
  29115. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29116. private _resetIndexBufferBinding;
  29117. /**
  29118. * Creates a new index buffer
  29119. * @param indices defines the content of the index buffer
  29120. * @param updatable defines if the index buffer must be updatable
  29121. * @returns a new webGL buffer
  29122. */
  29123. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  29124. /**
  29125. * Bind a webGL buffer to the webGL context
  29126. * @param buffer defines the buffer to bind
  29127. */
  29128. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  29129. /**
  29130. * Bind an uniform buffer to the current webGL context
  29131. * @param buffer defines the buffer to bind
  29132. */
  29133. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  29134. /**
  29135. * Bind a buffer to the current webGL context at a given location
  29136. * @param buffer defines the buffer to bind
  29137. * @param location defines the index where to bind the buffer
  29138. */
  29139. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  29140. /**
  29141. * Bind a specific block at a given index in a specific shader program
  29142. * @param shaderProgram defines the shader program
  29143. * @param blockName defines the block name
  29144. * @param index defines the index where to bind the block
  29145. */
  29146. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  29147. private bindIndexBuffer;
  29148. private bindBuffer;
  29149. /**
  29150. * update the bound buffer with the given data
  29151. * @param data defines the data to update
  29152. */
  29153. updateArrayBuffer(data: Float32Array): void;
  29154. private _vertexAttribPointer;
  29155. private _bindIndexBufferWithCache;
  29156. private _bindVertexBuffersAttributes;
  29157. /**
  29158. * Records a vertex array object
  29159. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29160. * @param vertexBuffers defines the list of vertex buffers to store
  29161. * @param indexBuffer defines the index buffer to store
  29162. * @param effect defines the effect to store
  29163. * @returns the new vertex array object
  29164. */
  29165. recordVertexArrayObject(vertexBuffers: {
  29166. [key: string]: VertexBuffer;
  29167. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  29168. /**
  29169. * Bind a specific vertex array object
  29170. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29171. * @param vertexArrayObject defines the vertex array object to bind
  29172. * @param indexBuffer defines the index buffer to bind
  29173. */
  29174. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  29175. /**
  29176. * Bind webGl buffers directly to the webGL context
  29177. * @param vertexBuffer defines the vertex buffer to bind
  29178. * @param indexBuffer defines the index buffer to bind
  29179. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29180. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29181. * @param effect defines the effect associated with the vertex buffer
  29182. */
  29183. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29184. private _unbindVertexArrayObject;
  29185. /**
  29186. * Bind a list of vertex buffers to the webGL context
  29187. * @param vertexBuffers defines the list of vertex buffers to bind
  29188. * @param indexBuffer defines the index buffer to bind
  29189. * @param effect defines the effect associated with the vertex buffers
  29190. */
  29191. bindBuffers(vertexBuffers: {
  29192. [key: string]: Nullable<VertexBuffer>;
  29193. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  29194. /**
  29195. * Unbind all instance attributes
  29196. */
  29197. unbindInstanceAttributes(): void;
  29198. /**
  29199. * Release and free the memory of a vertex array object
  29200. * @param vao defines the vertex array object to delete
  29201. */
  29202. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29203. /** @hidden */
  29204. _releaseBuffer(buffer: WebGLBuffer): boolean;
  29205. /**
  29206. * Creates a webGL buffer to use with instanciation
  29207. * @param capacity defines the size of the buffer
  29208. * @returns the webGL buffer
  29209. */
  29210. createInstancesBuffer(capacity: number): WebGLBuffer;
  29211. /**
  29212. * Delete a webGL buffer used with instanciation
  29213. * @param buffer defines the webGL buffer to delete
  29214. */
  29215. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29216. /**
  29217. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29218. * @param instancesBuffer defines the webGL buffer to update and bind
  29219. * @param data defines the data to store in the buffer
  29220. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29221. */
  29222. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29223. /**
  29224. * Apply all cached states (depth, culling, stencil and alpha)
  29225. */
  29226. applyStates(): void;
  29227. /**
  29228. * Send a draw order
  29229. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29230. * @param indexStart defines the starting index
  29231. * @param indexCount defines the number of index to draw
  29232. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29233. */
  29234. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29235. /**
  29236. * Draw a list of points
  29237. * @param verticesStart defines the index of first vertex to draw
  29238. * @param verticesCount defines the count of vertices to draw
  29239. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29240. */
  29241. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29242. /**
  29243. * Draw a list of unindexed primitives
  29244. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29245. * @param verticesStart defines the index of first vertex to draw
  29246. * @param verticesCount defines the count of vertices to draw
  29247. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29248. */
  29249. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29250. /**
  29251. * Draw a list of indexed primitives
  29252. * @param fillMode defines the primitive to use
  29253. * @param indexStart defines the starting index
  29254. * @param indexCount defines the number of index to draw
  29255. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29256. */
  29257. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29258. /**
  29259. * Draw a list of unindexed primitives
  29260. * @param fillMode defines the primitive to use
  29261. * @param verticesStart defines the index of first vertex to draw
  29262. * @param verticesCount defines the count of vertices to draw
  29263. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29264. */
  29265. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29266. private _drawMode;
  29267. /** @hidden */
  29268. _releaseEffect(effect: Effect): void;
  29269. /** @hidden */
  29270. _deleteProgram(program: WebGLProgram): void;
  29271. /**
  29272. * Create a new effect (used to store vertex/fragment shaders)
  29273. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29274. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29275. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29276. * @param samplers defines an array of string used to represent textures
  29277. * @param defines defines the string containing the defines to use to compile the shaders
  29278. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29279. * @param onCompiled defines a function to call when the effect creation is successful
  29280. * @param onError defines a function to call when the effect creation has failed
  29281. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29282. * @returns the new Effect
  29283. */
  29284. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  29285. private _compileShader;
  29286. private _compileRawShader;
  29287. /**
  29288. * Directly creates a webGL program
  29289. * @param vertexCode defines the vertex shader code to use
  29290. * @param fragmentCode defines the fragment shader code to use
  29291. * @param context defines the webGL context to use (if not set, the current one will be used)
  29292. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29293. * @returns the new webGL program
  29294. */
  29295. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29296. /**
  29297. * Creates a webGL program
  29298. * @param vertexCode defines the vertex shader code to use
  29299. * @param fragmentCode defines the fragment shader code to use
  29300. * @param defines defines the string containing the defines to use to compile the shaders
  29301. * @param context defines the webGL context to use (if not set, the current one will be used)
  29302. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29303. * @returns the new webGL program
  29304. */
  29305. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29306. private _createShaderProgram;
  29307. private _finalizeProgram;
  29308. /** @hidden */
  29309. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  29310. /** @hidden */
  29311. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  29312. /**
  29313. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29314. * @param shaderProgram defines the webGL program to use
  29315. * @param uniformsNames defines the list of uniform names
  29316. * @returns an array of webGL uniform locations
  29317. */
  29318. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29319. /**
  29320. * Gets the lsit of active attributes for a given webGL program
  29321. * @param shaderProgram defines the webGL program to use
  29322. * @param attributesNames defines the list of attribute names to get
  29323. * @returns an array of indices indicating the offset of each attribute
  29324. */
  29325. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  29326. /**
  29327. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29328. * @param effect defines the effect to activate
  29329. */
  29330. enableEffect(effect: Nullable<Effect>): void;
  29331. /**
  29332. * Set the value of an uniform to an array of int32
  29333. * @param uniform defines the webGL uniform location where to store the value
  29334. * @param array defines the array of int32 to store
  29335. */
  29336. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29337. /**
  29338. * Set the value of an uniform to an array of int32 (stored as vec2)
  29339. * @param uniform defines the webGL uniform location where to store the value
  29340. * @param array defines the array of int32 to store
  29341. */
  29342. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29343. /**
  29344. * Set the value of an uniform to an array of int32 (stored as vec3)
  29345. * @param uniform defines the webGL uniform location where to store the value
  29346. * @param array defines the array of int32 to store
  29347. */
  29348. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29349. /**
  29350. * Set the value of an uniform to an array of int32 (stored as vec4)
  29351. * @param uniform defines the webGL uniform location where to store the value
  29352. * @param array defines the array of int32 to store
  29353. */
  29354. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29355. /**
  29356. * Set the value of an uniform to an array of float32
  29357. * @param uniform defines the webGL uniform location where to store the value
  29358. * @param array defines the array of float32 to store
  29359. */
  29360. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29361. /**
  29362. * Set the value of an uniform to an array of float32 (stored as vec2)
  29363. * @param uniform defines the webGL uniform location where to store the value
  29364. * @param array defines the array of float32 to store
  29365. */
  29366. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29367. /**
  29368. * Set the value of an uniform to an array of float32 (stored as vec3)
  29369. * @param uniform defines the webGL uniform location where to store the value
  29370. * @param array defines the array of float32 to store
  29371. */
  29372. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29373. /**
  29374. * Set the value of an uniform to an array of float32 (stored as vec4)
  29375. * @param uniform defines the webGL uniform location where to store the value
  29376. * @param array defines the array of float32 to store
  29377. */
  29378. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29379. /**
  29380. * Set the value of an uniform to an array of number
  29381. * @param uniform defines the webGL uniform location where to store the value
  29382. * @param array defines the array of number to store
  29383. */
  29384. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29385. /**
  29386. * Set the value of an uniform to an array of number (stored as vec2)
  29387. * @param uniform defines the webGL uniform location where to store the value
  29388. * @param array defines the array of number to store
  29389. */
  29390. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29391. /**
  29392. * Set the value of an uniform to an array of number (stored as vec3)
  29393. * @param uniform defines the webGL uniform location where to store the value
  29394. * @param array defines the array of number to store
  29395. */
  29396. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29397. /**
  29398. * Set the value of an uniform to an array of number (stored as vec4)
  29399. * @param uniform defines the webGL uniform location where to store the value
  29400. * @param array defines the array of number to store
  29401. */
  29402. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29403. /**
  29404. * Set the value of an uniform to an array of float32 (stored as matrices)
  29405. * @param uniform defines the webGL uniform location where to store the value
  29406. * @param matrices defines the array of float32 to store
  29407. */
  29408. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29409. /**
  29410. * Set the value of an uniform to a matrix
  29411. * @param uniform defines the webGL uniform location where to store the value
  29412. * @param matrix defines the matrix to store
  29413. */
  29414. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29415. /**
  29416. * Set the value of an uniform to a matrix (3x3)
  29417. * @param uniform defines the webGL uniform location where to store the value
  29418. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29419. */
  29420. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29421. /**
  29422. * Set the value of an uniform to a matrix (2x2)
  29423. * @param uniform defines the webGL uniform location where to store the value
  29424. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29425. */
  29426. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29427. /**
  29428. * Set the value of an uniform to a number (int)
  29429. * @param uniform defines the webGL uniform location where to store the value
  29430. * @param value defines the int number to store
  29431. */
  29432. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29433. /**
  29434. * Set the value of an uniform to a number (float)
  29435. * @param uniform defines the webGL uniform location where to store the value
  29436. * @param value defines the float number to store
  29437. */
  29438. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29439. /**
  29440. * Set the value of an uniform to a vec2
  29441. * @param uniform defines the webGL uniform location where to store the value
  29442. * @param x defines the 1st component of the value
  29443. * @param y defines the 2nd component of the value
  29444. */
  29445. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29446. /**
  29447. * Set the value of an uniform to a vec3
  29448. * @param uniform defines the webGL uniform location where to store the value
  29449. * @param x defines the 1st component of the value
  29450. * @param y defines the 2nd component of the value
  29451. * @param z defines the 3rd component of the value
  29452. */
  29453. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29454. /**
  29455. * Set the value of an uniform to a boolean
  29456. * @param uniform defines the webGL uniform location where to store the value
  29457. * @param bool defines the boolean to store
  29458. */
  29459. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29460. /**
  29461. * Set the value of an uniform to a vec4
  29462. * @param uniform defines the webGL uniform location where to store the value
  29463. * @param x defines the 1st component of the value
  29464. * @param y defines the 2nd component of the value
  29465. * @param z defines the 3rd component of the value
  29466. * @param w defines the 4th component of the value
  29467. */
  29468. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29469. /**
  29470. * Set the value of an uniform to a Color3
  29471. * @param uniform defines the webGL uniform location where to store the value
  29472. * @param color3 defines the color to store
  29473. */
  29474. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29475. /**
  29476. * Set the value of an uniform to a Color3 and an alpha value
  29477. * @param uniform defines the webGL uniform location where to store the value
  29478. * @param color3 defines the color to store
  29479. * @param alpha defines the alpha component to store
  29480. */
  29481. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29482. /**
  29483. * Sets a Color4 on a uniform variable
  29484. * @param uniform defines the uniform location
  29485. * @param color4 defines the value to be set
  29486. */
  29487. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29488. /**
  29489. * Set various states to the webGL context
  29490. * @param culling defines backface culling state
  29491. * @param zOffset defines the value to apply to zOffset (0 by default)
  29492. * @param force defines if states must be applied even if cache is up to date
  29493. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29494. */
  29495. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29496. /**
  29497. * Set the z offset to apply to current rendering
  29498. * @param value defines the offset to apply
  29499. */
  29500. setZOffset(value: number): void;
  29501. /**
  29502. * Gets the current value of the zOffset
  29503. * @returns the current zOffset state
  29504. */
  29505. getZOffset(): number;
  29506. /**
  29507. * Enable or disable depth buffering
  29508. * @param enable defines the state to set
  29509. */
  29510. setDepthBuffer(enable: boolean): void;
  29511. /**
  29512. * Gets a boolean indicating if depth writing is enabled
  29513. * @returns the current depth writing state
  29514. */
  29515. getDepthWrite(): boolean;
  29516. /**
  29517. * Enable or disable depth writing
  29518. * @param enable defines the state to set
  29519. */
  29520. setDepthWrite(enable: boolean): void;
  29521. /**
  29522. * Enable or disable color writing
  29523. * @param enable defines the state to set
  29524. */
  29525. setColorWrite(enable: boolean): void;
  29526. /**
  29527. * Gets a boolean indicating if color writing is enabled
  29528. * @returns the current color writing state
  29529. */
  29530. getColorWrite(): boolean;
  29531. /**
  29532. * Sets alpha constants used by some alpha blending modes
  29533. * @param r defines the red component
  29534. * @param g defines the green component
  29535. * @param b defines the blue component
  29536. * @param a defines the alpha component
  29537. */
  29538. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29539. /**
  29540. * Sets the current alpha mode
  29541. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29542. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29543. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29544. */
  29545. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29546. /**
  29547. * Gets the current alpha mode
  29548. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29549. * @returns the current alpha mode
  29550. */
  29551. getAlphaMode(): number;
  29552. /**
  29553. * Clears the list of texture accessible through engine.
  29554. * This can help preventing texture load conflict due to name collision.
  29555. */
  29556. clearInternalTexturesCache(): void;
  29557. /**
  29558. * Force the entire cache to be cleared
  29559. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29560. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29561. */
  29562. wipeCaches(bruteForce?: boolean): void;
  29563. /**
  29564. * Set the compressed texture format to use, based on the formats you have, and the formats
  29565. * supported by the hardware / browser.
  29566. *
  29567. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29568. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29569. * to API arguments needed to compressed textures. This puts the burden on the container
  29570. * generator to house the arcane code for determining these for current & future formats.
  29571. *
  29572. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29573. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29574. *
  29575. * Note: The result of this call is not taken into account when a texture is base64.
  29576. *
  29577. * @param formatsAvailable defines the list of those format families you have created
  29578. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29579. *
  29580. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29581. * @returns The extension selected.
  29582. */
  29583. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29584. private _getSamplingParameters;
  29585. private _partialLoadImg;
  29586. private _cascadeLoadImgs;
  29587. /** @hidden */
  29588. _createTexture(): WebGLTexture;
  29589. /**
  29590. * Usually called from Texture.ts.
  29591. * Passed information to create a WebGLTexture
  29592. * @param urlArg defines a value which contains one of the following:
  29593. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29594. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29595. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29596. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29597. * @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)
  29598. * @param scene needed for loading to the correct scene
  29599. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29600. * @param onLoad optional callback to be called upon successful completion
  29601. * @param onError optional callback to be called upon failure
  29602. * @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
  29603. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29604. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29605. * @param forcedExtension defines the extension to use to pick the right loader
  29606. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29607. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29608. */
  29609. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29610. private _rescaleTexture;
  29611. /**
  29612. * Update a raw texture
  29613. * @param texture defines the texture to update
  29614. * @param data defines the data to store in the texture
  29615. * @param format defines the format of the data
  29616. * @param invertY defines if data must be stored with Y axis inverted
  29617. * @param compression defines the compression used (null by default)
  29618. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29619. */
  29620. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29621. /**
  29622. * Creates a raw texture
  29623. * @param data defines the data to store in the texture
  29624. * @param width defines the width of the texture
  29625. * @param height defines the height of the texture
  29626. * @param format defines the format of the data
  29627. * @param generateMipMaps defines if the engine should generate the mip levels
  29628. * @param invertY defines if data must be stored with Y axis inverted
  29629. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29630. * @param compression defines the compression used (null by default)
  29631. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29632. * @returns the raw texture inside an InternalTexture
  29633. */
  29634. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29635. private _unpackFlipYCached;
  29636. /**
  29637. * In case you are sharing the context with other applications, it might
  29638. * be interested to not cache the unpack flip y state to ensure a consistent
  29639. * value would be set.
  29640. */
  29641. enableUnpackFlipYCached: boolean;
  29642. /** @hidden */
  29643. _unpackFlipY(value: boolean): void;
  29644. /** @hidden */
  29645. _getUnpackAlignement(): number;
  29646. /**
  29647. * Creates a dynamic texture
  29648. * @param width defines the width of the texture
  29649. * @param height defines the height of the texture
  29650. * @param generateMipMaps defines if the engine should generate the mip levels
  29651. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29652. * @returns the dynamic texture inside an InternalTexture
  29653. */
  29654. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29655. /**
  29656. * Update the sampling mode of a given texture
  29657. * @param samplingMode defines the required sampling mode
  29658. * @param texture defines the texture to update
  29659. */
  29660. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29661. /**
  29662. * Update the content of a dynamic texture
  29663. * @param texture defines the texture to update
  29664. * @param canvas defines the canvas containing the source
  29665. * @param invertY defines if data must be stored with Y axis inverted
  29666. * @param premulAlpha defines if alpha is stored as premultiplied
  29667. * @param format defines the format of the data
  29668. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29669. */
  29670. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29671. /**
  29672. * Update a video texture
  29673. * @param texture defines the texture to update
  29674. * @param video defines the video element to use
  29675. * @param invertY defines if data must be stored with Y axis inverted
  29676. */
  29677. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29678. /**
  29679. * Updates a depth texture Comparison Mode and Function.
  29680. * If the comparison Function is equal to 0, the mode will be set to none.
  29681. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29682. * @param texture The texture to set the comparison function for
  29683. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29684. */
  29685. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29686. private _setupDepthStencilTexture;
  29687. /**
  29688. * Creates a depth stencil texture.
  29689. * This is only available in WebGL 2 or with the depth texture extension available.
  29690. * @param size The size of face edge in the texture.
  29691. * @param options The options defining the texture.
  29692. * @returns The texture
  29693. */
  29694. createDepthStencilTexture(size: number | {
  29695. width: number;
  29696. height: number;
  29697. }, options: DepthTextureCreationOptions): InternalTexture;
  29698. /**
  29699. * Creates a depth stencil texture.
  29700. * This is only available in WebGL 2 or with the depth texture extension available.
  29701. * @param size The size of face edge in the texture.
  29702. * @param options The options defining the texture.
  29703. * @returns The texture
  29704. */
  29705. private _createDepthStencilTexture;
  29706. /**
  29707. * Creates a depth stencil cube texture.
  29708. * This is only available in WebGL 2.
  29709. * @param size The size of face edge in the cube texture.
  29710. * @param options The options defining the cube texture.
  29711. * @returns The cube texture
  29712. */
  29713. private _createDepthStencilCubeTexture;
  29714. /**
  29715. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29716. * @param renderTarget The render target to set the frame buffer for
  29717. */
  29718. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29719. /**
  29720. * Creates a new render target texture
  29721. * @param size defines the size of the texture
  29722. * @param options defines the options used to create the texture
  29723. * @returns a new render target texture stored in an InternalTexture
  29724. */
  29725. createRenderTargetTexture(size: number | {
  29726. width: number;
  29727. height: number;
  29728. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29729. /**
  29730. * Create a multi render target texture
  29731. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29732. * @param size defines the size of the texture
  29733. * @param options defines the creation options
  29734. * @returns the cube texture as an InternalTexture
  29735. */
  29736. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29737. private _setupFramebufferDepthAttachments;
  29738. /**
  29739. * Updates the sample count of a render target texture
  29740. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29741. * @param texture defines the texture to update
  29742. * @param samples defines the sample count to set
  29743. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29744. */
  29745. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29746. /**
  29747. * Update the sample count for a given multiple render target texture
  29748. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29749. * @param textures defines the textures to update
  29750. * @param samples defines the sample count to set
  29751. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29752. */
  29753. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29754. /** @hidden */
  29755. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29756. /** @hidden */
  29757. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29758. /** @hidden */
  29759. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29760. /** @hidden */
  29761. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29762. /**
  29763. * Creates a new render target cube texture
  29764. * @param size defines the size of the texture
  29765. * @param options defines the options used to create the texture
  29766. * @returns a new render target cube texture stored in an InternalTexture
  29767. */
  29768. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29769. /**
  29770. * Creates a cube texture
  29771. * @param rootUrl defines the url where the files to load is located
  29772. * @param scene defines the current scene
  29773. * @param files defines the list of files to load (1 per face)
  29774. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29775. * @param onLoad defines an optional callback raised when the texture is loaded
  29776. * @param onError defines an optional callback raised if there is an issue to load the texture
  29777. * @param format defines the format of the data
  29778. * @param forcedExtension defines the extension to use to pick the right loader
  29779. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29780. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29781. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29782. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29783. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29784. * @returns the cube texture as an InternalTexture
  29785. */
  29786. 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>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29787. /**
  29788. * @hidden
  29789. */
  29790. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29791. /**
  29792. * Update a raw cube texture
  29793. * @param texture defines the texture to udpdate
  29794. * @param data defines the data to store
  29795. * @param format defines the data format
  29796. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29797. * @param invertY defines if data must be stored with Y axis inverted
  29798. * @param compression defines the compression used (null by default)
  29799. * @param level defines which level of the texture to update
  29800. */
  29801. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29802. /**
  29803. * Creates a new raw cube texture
  29804. * @param data defines the array of data to use to create each face
  29805. * @param size defines the size of the textures
  29806. * @param format defines the format of the data
  29807. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29808. * @param generateMipMaps defines if the engine should generate the mip levels
  29809. * @param invertY defines if data must be stored with Y axis inverted
  29810. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29811. * @param compression defines the compression used (null by default)
  29812. * @returns the cube texture as an InternalTexture
  29813. */
  29814. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29815. /**
  29816. * Creates a new raw cube texture from a specified url
  29817. * @param url defines the url where the data is located
  29818. * @param scene defines the current scene
  29819. * @param size defines the size of the textures
  29820. * @param format defines the format of the data
  29821. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29822. * @param noMipmap defines if the engine should avoid generating the mip levels
  29823. * @param callback defines a callback used to extract texture data from loaded data
  29824. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29825. * @param onLoad defines a callback called when texture is loaded
  29826. * @param onError defines a callback called if there is an error
  29827. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29828. * @param invertY defines if data must be stored with Y axis inverted
  29829. * @returns the cube texture as an InternalTexture
  29830. */
  29831. createRawCubeTextureFromUrl(url: string, scene: 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;
  29832. /**
  29833. * Update a raw 3D texture
  29834. * @param texture defines the texture to update
  29835. * @param data defines the data to store
  29836. * @param format defines the data format
  29837. * @param invertY defines if data must be stored with Y axis inverted
  29838. * @param compression defines the used compression (can be null)
  29839. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29840. */
  29841. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29842. /**
  29843. * Creates a new raw 3D texture
  29844. * @param data defines the data used to create the texture
  29845. * @param width defines the width of the texture
  29846. * @param height defines the height of the texture
  29847. * @param depth defines the depth of the texture
  29848. * @param format defines the format of the texture
  29849. * @param generateMipMaps defines if the engine must generate mip levels
  29850. * @param invertY defines if data must be stored with Y axis inverted
  29851. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29852. * @param compression defines the compressed used (can be null)
  29853. * @param textureType defines the compressed used (can be null)
  29854. * @returns a new raw 3D texture (stored in an InternalTexture)
  29855. */
  29856. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29857. private _prepareWebGLTextureContinuation;
  29858. private _prepareWebGLTexture;
  29859. private _convertRGBtoRGBATextureData;
  29860. /** @hidden */
  29861. _releaseFramebufferObjects(texture: InternalTexture): void;
  29862. /** @hidden */
  29863. _releaseTexture(texture: InternalTexture): void;
  29864. private setProgram;
  29865. private _boundUniforms;
  29866. /**
  29867. * Binds an effect to the webGL context
  29868. * @param effect defines the effect to bind
  29869. */
  29870. bindSamplers(effect: Effect): void;
  29871. private _moveBoundTextureOnTop;
  29872. private _getCorrectTextureChannel;
  29873. private _linkTrackers;
  29874. private _removeDesignatedSlot;
  29875. private _activateCurrentTexture;
  29876. /** @hidden */
  29877. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29878. /** @hidden */
  29879. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29880. /**
  29881. * Sets a texture to the webGL context from a postprocess
  29882. * @param channel defines the channel to use
  29883. * @param postProcess defines the source postprocess
  29884. */
  29885. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29886. /**
  29887. * Binds the output of the passed in post process to the texture channel specified
  29888. * @param channel The channel the texture should be bound to
  29889. * @param postProcess The post process which's output should be bound
  29890. */
  29891. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29892. /**
  29893. * Unbind all textures from the webGL context
  29894. */
  29895. unbindAllTextures(): void;
  29896. /**
  29897. * Sets a texture to the according uniform.
  29898. * @param channel The texture channel
  29899. * @param uniform The uniform to set
  29900. * @param texture The texture to apply
  29901. */
  29902. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29903. /**
  29904. * Sets a depth stencil texture from a render target to the according uniform.
  29905. * @param channel The texture channel
  29906. * @param uniform The uniform to set
  29907. * @param texture The render target texture containing the depth stencil texture to apply
  29908. */
  29909. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29910. private _bindSamplerUniformToChannel;
  29911. private _getTextureWrapMode;
  29912. private _setTexture;
  29913. /**
  29914. * Sets an array of texture to the webGL context
  29915. * @param channel defines the channel where the texture array must be set
  29916. * @param uniform defines the associated uniform location
  29917. * @param textures defines the array of textures to bind
  29918. */
  29919. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29920. /** @hidden */
  29921. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29922. private _setTextureParameterFloat;
  29923. private _setTextureParameterInteger;
  29924. /**
  29925. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29926. * @param x defines the x coordinate of the rectangle where pixels must be read
  29927. * @param y defines the y coordinate of the rectangle where pixels must be read
  29928. * @param width defines the width of the rectangle where pixels must be read
  29929. * @param height defines the height of the rectangle where pixels must be read
  29930. * @returns a Uint8Array containing RGBA colors
  29931. */
  29932. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29933. /**
  29934. * Add an externaly attached data from its key.
  29935. * This method call will fail and return false, if such key already exists.
  29936. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29937. * @param key the unique key that identifies the data
  29938. * @param data the data object to associate to the key for this Engine instance
  29939. * @return true if no such key were already present and the data was added successfully, false otherwise
  29940. */
  29941. addExternalData<T>(key: string, data: T): boolean;
  29942. /**
  29943. * Get an externaly attached data from its key
  29944. * @param key the unique key that identifies the data
  29945. * @return the associated data, if present (can be null), or undefined if not present
  29946. */
  29947. getExternalData<T>(key: string): T;
  29948. /**
  29949. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29950. * @param key the unique key that identifies the data
  29951. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29952. * @return the associated data, can be null if the factory returned null.
  29953. */
  29954. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29955. /**
  29956. * Remove an externaly attached data from the Engine instance
  29957. * @param key the unique key that identifies the data
  29958. * @return true if the data was successfully removed, false if it doesn't exist
  29959. */
  29960. removeExternalData(key: string): boolean;
  29961. /**
  29962. * Unbind all vertex attributes from the webGL context
  29963. */
  29964. unbindAllAttributes(): void;
  29965. /**
  29966. * 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
  29967. */
  29968. releaseEffects(): void;
  29969. /**
  29970. * Dispose and release all associated resources
  29971. */
  29972. dispose(): void;
  29973. /**
  29974. * Display the loading screen
  29975. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29976. */
  29977. displayLoadingUI(): void;
  29978. /**
  29979. * Hide the loading screen
  29980. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29981. */
  29982. hideLoadingUI(): void;
  29983. /**
  29984. * Gets the current loading screen object
  29985. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29986. */
  29987. /**
  29988. * Sets the current loading screen object
  29989. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29990. */
  29991. loadingScreen: ILoadingScreen;
  29992. /**
  29993. * Sets the current loading screen text
  29994. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29995. */
  29996. loadingUIText: string;
  29997. /**
  29998. * Sets the current loading screen background color
  29999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30000. */
  30001. loadingUIBackgroundColor: string;
  30002. /**
  30003. * Attach a new callback raised when context lost event is fired
  30004. * @param callback defines the callback to call
  30005. */
  30006. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30007. /**
  30008. * Attach a new callback raised when context restored event is fired
  30009. * @param callback defines the callback to call
  30010. */
  30011. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30012. /**
  30013. * Gets the source code of the vertex shader associated with a specific webGL program
  30014. * @param program defines the program to use
  30015. * @returns a string containing the source code of the vertex shader associated with the program
  30016. */
  30017. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30018. /**
  30019. * Gets the source code of the fragment shader associated with a specific webGL program
  30020. * @param program defines the program to use
  30021. * @returns a string containing the source code of the fragment shader associated with the program
  30022. */
  30023. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30024. /**
  30025. * Get the current error code of the webGL context
  30026. * @returns the error code
  30027. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30028. */
  30029. getError(): number;
  30030. /**
  30031. * Gets the current framerate
  30032. * @returns a number representing the framerate
  30033. */
  30034. getFps(): number;
  30035. /**
  30036. * Gets the time spent between current and previous frame
  30037. * @returns a number representing the delta time in ms
  30038. */
  30039. getDeltaTime(): number;
  30040. private _measureFps;
  30041. /** @hidden */
  30042. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30043. private _canRenderToFloatFramebuffer;
  30044. private _canRenderToHalfFloatFramebuffer;
  30045. private _canRenderToFramebuffer;
  30046. /** @hidden */
  30047. _getWebGLTextureType(type: number): number;
  30048. private _getInternalFormat;
  30049. /** @hidden */
  30050. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30051. /** @hidden */
  30052. _getRGBAMultiSampleBufferFormat(type: number): number;
  30053. /** @hidden */
  30054. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  30055. /** @hidden */
  30056. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30057. private _partialLoadFile;
  30058. private _cascadeLoadFiles;
  30059. /**
  30060. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30061. * @returns true if the engine can be created
  30062. * @ignorenaming
  30063. */
  30064. static isSupported(): boolean;
  30065. }
  30066. }
  30067. declare module "babylonjs/Materials/effect" {
  30068. import { Observable } from "babylonjs/Misc/observable";
  30069. import { Nullable } from "babylonjs/types";
  30070. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  30071. import { Engine } from "babylonjs/Engines/engine";
  30072. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30073. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30074. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30075. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30077. /**
  30078. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30079. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30080. */
  30081. export class EffectFallbacks {
  30082. private _defines;
  30083. private _currentRank;
  30084. private _maxRank;
  30085. private _mesh;
  30086. /**
  30087. * Removes the fallback from the bound mesh.
  30088. */
  30089. unBindMesh(): void;
  30090. /**
  30091. * Adds a fallback on the specified property.
  30092. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30093. * @param define The name of the define in the shader
  30094. */
  30095. addFallback(rank: number, define: string): void;
  30096. /**
  30097. * Sets the mesh to use CPU skinning when needing to fallback.
  30098. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30099. * @param mesh The mesh to use the fallbacks.
  30100. */
  30101. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30102. /**
  30103. * Checks to see if more fallbacks are still availible.
  30104. */
  30105. readonly isMoreFallbacks: boolean;
  30106. /**
  30107. * Removes the defines that shoould be removed when falling back.
  30108. * @param currentDefines defines the current define statements for the shader.
  30109. * @param effect defines the current effect we try to compile
  30110. * @returns The resulting defines with defines of the current rank removed.
  30111. */
  30112. reduce(currentDefines: string, effect: Effect): string;
  30113. }
  30114. /**
  30115. * Options to be used when creating an effect.
  30116. */
  30117. export class EffectCreationOptions {
  30118. /**
  30119. * Atrributes that will be used in the shader.
  30120. */
  30121. attributes: string[];
  30122. /**
  30123. * Uniform varible names that will be set in the shader.
  30124. */
  30125. uniformsNames: string[];
  30126. /**
  30127. * Uniform buffer varible names that will be set in the shader.
  30128. */
  30129. uniformBuffersNames: string[];
  30130. /**
  30131. * Sampler texture variable names that will be set in the shader.
  30132. */
  30133. samplers: string[];
  30134. /**
  30135. * Define statements that will be set in the shader.
  30136. */
  30137. defines: any;
  30138. /**
  30139. * Possible fallbacks for this effect to improve performance when needed.
  30140. */
  30141. fallbacks: Nullable<EffectFallbacks>;
  30142. /**
  30143. * Callback that will be called when the shader is compiled.
  30144. */
  30145. onCompiled: Nullable<(effect: Effect) => void>;
  30146. /**
  30147. * Callback that will be called if an error occurs during shader compilation.
  30148. */
  30149. onError: Nullable<(effect: Effect, errors: string) => void>;
  30150. /**
  30151. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30152. */
  30153. indexParameters: any;
  30154. /**
  30155. * Max number of lights that can be used in the shader.
  30156. */
  30157. maxSimultaneousLights: number;
  30158. /**
  30159. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30160. */
  30161. transformFeedbackVaryings: Nullable<string[]>;
  30162. }
  30163. /**
  30164. * Effect containing vertex and fragment shader that can be executed on an object.
  30165. */
  30166. export class Effect {
  30167. /**
  30168. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30169. */
  30170. static ShadersRepository: string;
  30171. /**
  30172. * Name of the effect.
  30173. */
  30174. name: any;
  30175. /**
  30176. * String container all the define statements that should be set on the shader.
  30177. */
  30178. defines: string;
  30179. /**
  30180. * Callback that will be called when the shader is compiled.
  30181. */
  30182. onCompiled: Nullable<(effect: Effect) => void>;
  30183. /**
  30184. * Callback that will be called if an error occurs during shader compilation.
  30185. */
  30186. onError: Nullable<(effect: Effect, errors: string) => void>;
  30187. /**
  30188. * Callback that will be called when effect is bound.
  30189. */
  30190. onBind: Nullable<(effect: Effect) => void>;
  30191. /**
  30192. * Unique ID of the effect.
  30193. */
  30194. uniqueId: number;
  30195. /**
  30196. * Observable that will be called when the shader is compiled.
  30197. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30198. */
  30199. onCompileObservable: Observable<Effect>;
  30200. /**
  30201. * Observable that will be called if an error occurs during shader compilation.
  30202. */
  30203. onErrorObservable: Observable<Effect>;
  30204. /** @hidden */
  30205. _onBindObservable: Nullable<Observable<Effect>>;
  30206. /**
  30207. * Observable that will be called when effect is bound.
  30208. */
  30209. readonly onBindObservable: Observable<Effect>;
  30210. /** @hidden */
  30211. _bonesComputationForcedToCPU: boolean;
  30212. private static _uniqueIdSeed;
  30213. private _engine;
  30214. private _uniformBuffersNames;
  30215. private _uniformsNames;
  30216. private _samplers;
  30217. private _isReady;
  30218. private _compilationError;
  30219. private _attributesNames;
  30220. private _attributes;
  30221. private _uniforms;
  30222. /**
  30223. * Key for the effect.
  30224. * @hidden
  30225. */
  30226. _key: string;
  30227. private _indexParameters;
  30228. private _fallbacks;
  30229. private _vertexSourceCode;
  30230. private _fragmentSourceCode;
  30231. private _vertexSourceCodeOverride;
  30232. private _fragmentSourceCodeOverride;
  30233. private _transformFeedbackVaryings;
  30234. /**
  30235. * Compiled shader to webGL program.
  30236. * @hidden
  30237. */
  30238. _program: WebGLProgram;
  30239. private _valueCache;
  30240. private static _baseCache;
  30241. /**
  30242. * Instantiates an effect.
  30243. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30244. * @param baseName Name of the effect.
  30245. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30246. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30247. * @param samplers List of sampler variables that will be passed to the shader.
  30248. * @param engine Engine to be used to render the effect
  30249. * @param defines Define statements to be added to the shader.
  30250. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30251. * @param onCompiled Callback that will be called when the shader is compiled.
  30252. * @param onError Callback that will be called if an error occurs during shader compilation.
  30253. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30254. */
  30255. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30256. /**
  30257. * Unique key for this effect
  30258. */
  30259. readonly key: string;
  30260. /**
  30261. * If the effect has been compiled and prepared.
  30262. * @returns if the effect is compiled and prepared.
  30263. */
  30264. isReady(): boolean;
  30265. /**
  30266. * The engine the effect was initialized with.
  30267. * @returns the engine.
  30268. */
  30269. getEngine(): Engine;
  30270. /**
  30271. * The compiled webGL program for the effect
  30272. * @returns the webGL program.
  30273. */
  30274. getProgram(): WebGLProgram;
  30275. /**
  30276. * The set of names of attribute variables for the shader.
  30277. * @returns An array of attribute names.
  30278. */
  30279. getAttributesNames(): string[];
  30280. /**
  30281. * Returns the attribute at the given index.
  30282. * @param index The index of the attribute.
  30283. * @returns The location of the attribute.
  30284. */
  30285. getAttributeLocation(index: number): number;
  30286. /**
  30287. * Returns the attribute based on the name of the variable.
  30288. * @param name of the attribute to look up.
  30289. * @returns the attribute location.
  30290. */
  30291. getAttributeLocationByName(name: string): number;
  30292. /**
  30293. * The number of attributes.
  30294. * @returns the numnber of attributes.
  30295. */
  30296. getAttributesCount(): number;
  30297. /**
  30298. * Gets the index of a uniform variable.
  30299. * @param uniformName of the uniform to look up.
  30300. * @returns the index.
  30301. */
  30302. getUniformIndex(uniformName: string): number;
  30303. /**
  30304. * Returns the attribute based on the name of the variable.
  30305. * @param uniformName of the uniform to look up.
  30306. * @returns the location of the uniform.
  30307. */
  30308. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30309. /**
  30310. * Returns an array of sampler variable names
  30311. * @returns The array of sampler variable neames.
  30312. */
  30313. getSamplers(): string[];
  30314. /**
  30315. * The error from the last compilation.
  30316. * @returns the error string.
  30317. */
  30318. getCompilationError(): string;
  30319. /**
  30320. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30321. * @param func The callback to be used.
  30322. */
  30323. executeWhenCompiled(func: (effect: Effect) => void): void;
  30324. private _checkIsReady;
  30325. /** @hidden */
  30326. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30327. /** @hidden */
  30328. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30329. /** @hidden */
  30330. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30331. private _processShaderConversion;
  30332. private _processIncludes;
  30333. private _processPrecision;
  30334. /**
  30335. * Recompiles the webGL program
  30336. * @param vertexSourceCode The source code for the vertex shader.
  30337. * @param fragmentSourceCode The source code for the fragment shader.
  30338. * @param onCompiled Callback called when completed.
  30339. * @param onError Callback called on error.
  30340. * @hidden
  30341. */
  30342. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  30343. /**
  30344. * Gets the uniform locations of the the specified variable names
  30345. * @param names THe names of the variables to lookup.
  30346. * @returns Array of locations in the same order as variable names.
  30347. */
  30348. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  30349. /**
  30350. * Prepares the effect
  30351. * @hidden
  30352. */
  30353. _prepareEffect(): void;
  30354. /**
  30355. * Checks if the effect is supported. (Must be called after compilation)
  30356. */
  30357. readonly isSupported: boolean;
  30358. /**
  30359. * Binds a texture to the engine to be used as output of the shader.
  30360. * @param channel Name of the output variable.
  30361. * @param texture Texture to bind.
  30362. * @hidden
  30363. */
  30364. _bindTexture(channel: string, texture: InternalTexture): void;
  30365. /**
  30366. * Sets a texture on the engine to be used in the shader.
  30367. * @param channel Name of the sampler variable.
  30368. * @param texture Texture to set.
  30369. */
  30370. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30371. /**
  30372. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30373. * @param channel Name of the sampler variable.
  30374. * @param texture Texture to set.
  30375. */
  30376. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30377. /**
  30378. * Sets an array of textures on the engine to be used in the shader.
  30379. * @param channel Name of the variable.
  30380. * @param textures Textures to set.
  30381. */
  30382. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30383. /**
  30384. * 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)
  30385. * @param channel Name of the sampler variable.
  30386. * @param postProcess Post process to get the input texture from.
  30387. */
  30388. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30389. /**
  30390. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30391. * 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)
  30392. * @param channel Name of the sampler variable.
  30393. * @param postProcess Post process to get the output texture from.
  30394. */
  30395. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30396. /** @hidden */
  30397. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30398. /** @hidden */
  30399. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30400. /** @hidden */
  30401. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30402. /** @hidden */
  30403. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30404. /**
  30405. * Binds a buffer to a uniform.
  30406. * @param buffer Buffer to bind.
  30407. * @param name Name of the uniform variable to bind to.
  30408. */
  30409. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  30410. /**
  30411. * Binds block to a uniform.
  30412. * @param blockName Name of the block to bind.
  30413. * @param index Index to bind.
  30414. */
  30415. bindUniformBlock(blockName: string, index: number): void;
  30416. /**
  30417. * Sets an interger value on a uniform variable.
  30418. * @param uniformName Name of the variable.
  30419. * @param value Value to be set.
  30420. * @returns this effect.
  30421. */
  30422. setInt(uniformName: string, value: number): Effect;
  30423. /**
  30424. * Sets an int array on a uniform variable.
  30425. * @param uniformName Name of the variable.
  30426. * @param array array to be set.
  30427. * @returns this effect.
  30428. */
  30429. setIntArray(uniformName: string, array: Int32Array): Effect;
  30430. /**
  30431. * 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)
  30432. * @param uniformName Name of the variable.
  30433. * @param array array to be set.
  30434. * @returns this effect.
  30435. */
  30436. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30437. /**
  30438. * 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)
  30439. * @param uniformName Name of the variable.
  30440. * @param array array to be set.
  30441. * @returns this effect.
  30442. */
  30443. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30444. /**
  30445. * 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)
  30446. * @param uniformName Name of the variable.
  30447. * @param array array to be set.
  30448. * @returns this effect.
  30449. */
  30450. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30451. /**
  30452. * Sets an float array on a uniform variable.
  30453. * @param uniformName Name of the variable.
  30454. * @param array array to be set.
  30455. * @returns this effect.
  30456. */
  30457. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30458. /**
  30459. * 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)
  30460. * @param uniformName Name of the variable.
  30461. * @param array array to be set.
  30462. * @returns this effect.
  30463. */
  30464. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30465. /**
  30466. * 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)
  30467. * @param uniformName Name of the variable.
  30468. * @param array array to be set.
  30469. * @returns this effect.
  30470. */
  30471. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30472. /**
  30473. * 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)
  30474. * @param uniformName Name of the variable.
  30475. * @param array array to be set.
  30476. * @returns this effect.
  30477. */
  30478. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30479. /**
  30480. * Sets an array on a uniform variable.
  30481. * @param uniformName Name of the variable.
  30482. * @param array array to be set.
  30483. * @returns this effect.
  30484. */
  30485. setArray(uniformName: string, array: number[]): Effect;
  30486. /**
  30487. * 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)
  30488. * @param uniformName Name of the variable.
  30489. * @param array array to be set.
  30490. * @returns this effect.
  30491. */
  30492. setArray2(uniformName: string, array: number[]): Effect;
  30493. /**
  30494. * 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)
  30495. * @param uniformName Name of the variable.
  30496. * @param array array to be set.
  30497. * @returns this effect.
  30498. */
  30499. setArray3(uniformName: string, array: number[]): Effect;
  30500. /**
  30501. * 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)
  30502. * @param uniformName Name of the variable.
  30503. * @param array array to be set.
  30504. * @returns this effect.
  30505. */
  30506. setArray4(uniformName: string, array: number[]): Effect;
  30507. /**
  30508. * Sets matrices on a uniform variable.
  30509. * @param uniformName Name of the variable.
  30510. * @param matrices matrices to be set.
  30511. * @returns this effect.
  30512. */
  30513. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30514. /**
  30515. * Sets matrix on a uniform variable.
  30516. * @param uniformName Name of the variable.
  30517. * @param matrix matrix to be set.
  30518. * @returns this effect.
  30519. */
  30520. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30521. /**
  30522. * 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)
  30523. * @param uniformName Name of the variable.
  30524. * @param matrix matrix to be set.
  30525. * @returns this effect.
  30526. */
  30527. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30528. /**
  30529. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30530. * @param uniformName Name of the variable.
  30531. * @param matrix matrix to be set.
  30532. * @returns this effect.
  30533. */
  30534. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30535. /**
  30536. * Sets a float on a uniform variable.
  30537. * @param uniformName Name of the variable.
  30538. * @param value value to be set.
  30539. * @returns this effect.
  30540. */
  30541. setFloat(uniformName: string, value: number): Effect;
  30542. /**
  30543. * Sets a boolean on a uniform variable.
  30544. * @param uniformName Name of the variable.
  30545. * @param bool value to be set.
  30546. * @returns this effect.
  30547. */
  30548. setBool(uniformName: string, bool: boolean): Effect;
  30549. /**
  30550. * Sets a Vector2 on a uniform variable.
  30551. * @param uniformName Name of the variable.
  30552. * @param vector2 vector2 to be set.
  30553. * @returns this effect.
  30554. */
  30555. setVector2(uniformName: string, vector2: Vector2): Effect;
  30556. /**
  30557. * Sets a float2 on a uniform variable.
  30558. * @param uniformName Name of the variable.
  30559. * @param x First float in float2.
  30560. * @param y Second float in float2.
  30561. * @returns this effect.
  30562. */
  30563. setFloat2(uniformName: string, x: number, y: number): Effect;
  30564. /**
  30565. * Sets a Vector3 on a uniform variable.
  30566. * @param uniformName Name of the variable.
  30567. * @param vector3 Value to be set.
  30568. * @returns this effect.
  30569. */
  30570. setVector3(uniformName: string, vector3: Vector3): Effect;
  30571. /**
  30572. * Sets a float3 on a uniform variable.
  30573. * @param uniformName Name of the variable.
  30574. * @param x First float in float3.
  30575. * @param y Second float in float3.
  30576. * @param z Third float in float3.
  30577. * @returns this effect.
  30578. */
  30579. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30580. /**
  30581. * Sets a Vector4 on a uniform variable.
  30582. * @param uniformName Name of the variable.
  30583. * @param vector4 Value to be set.
  30584. * @returns this effect.
  30585. */
  30586. setVector4(uniformName: string, vector4: Vector4): Effect;
  30587. /**
  30588. * Sets a float4 on a uniform variable.
  30589. * @param uniformName Name of the variable.
  30590. * @param x First float in float4.
  30591. * @param y Second float in float4.
  30592. * @param z Third float in float4.
  30593. * @param w Fourth float in float4.
  30594. * @returns this effect.
  30595. */
  30596. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30597. /**
  30598. * Sets a Color3 on a uniform variable.
  30599. * @param uniformName Name of the variable.
  30600. * @param color3 Value to be set.
  30601. * @returns this effect.
  30602. */
  30603. setColor3(uniformName: string, color3: Color3): Effect;
  30604. /**
  30605. * Sets a Color4 on a uniform variable.
  30606. * @param uniformName Name of the variable.
  30607. * @param color3 Value to be set.
  30608. * @param alpha Alpha value to be set.
  30609. * @returns this effect.
  30610. */
  30611. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30612. /**
  30613. * Sets a Color4 on a uniform variable
  30614. * @param uniformName defines the name of the variable
  30615. * @param color4 defines the value to be set
  30616. * @returns this effect.
  30617. */
  30618. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30619. /**
  30620. * This function will add a new shader to the shader store
  30621. * @param name the name of the shader
  30622. * @param pixelShader optional pixel shader content
  30623. * @param vertexShader optional vertex shader content
  30624. */
  30625. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30626. /**
  30627. * Store of each shader (The can be looked up using effect.key)
  30628. */
  30629. static ShadersStore: {
  30630. [key: string]: string;
  30631. };
  30632. /**
  30633. * Store of each included file for a shader (The can be looked up using effect.key)
  30634. */
  30635. static IncludesShadersStore: {
  30636. [key: string]: string;
  30637. };
  30638. /**
  30639. * Resets the cache of effects.
  30640. */
  30641. static ResetCache(): void;
  30642. }
  30643. }
  30644. declare module "babylonjs/Materials/colorCurves" {
  30645. import { Effect } from "babylonjs/Materials/effect";
  30646. /**
  30647. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30648. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30649. * 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;
  30650. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30651. */
  30652. export class ColorCurves {
  30653. private _dirty;
  30654. private _tempColor;
  30655. private _globalCurve;
  30656. private _highlightsCurve;
  30657. private _midtonesCurve;
  30658. private _shadowsCurve;
  30659. private _positiveCurve;
  30660. private _negativeCurve;
  30661. private _globalHue;
  30662. private _globalDensity;
  30663. private _globalSaturation;
  30664. private _globalExposure;
  30665. /**
  30666. * Gets the global Hue value.
  30667. * 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).
  30668. */
  30669. /**
  30670. * Sets the global Hue value.
  30671. * 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).
  30672. */
  30673. globalHue: number;
  30674. /**
  30675. * Gets the global Density value.
  30676. * 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.
  30677. * Values less than zero provide a filter of opposite hue.
  30678. */
  30679. /**
  30680. * Sets the global Density value.
  30681. * 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.
  30682. * Values less than zero provide a filter of opposite hue.
  30683. */
  30684. globalDensity: number;
  30685. /**
  30686. * Gets the global Saturation value.
  30687. * 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.
  30688. */
  30689. /**
  30690. * Sets the global Saturation value.
  30691. * 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.
  30692. */
  30693. globalSaturation: number;
  30694. /**
  30695. * Gets the global Exposure value.
  30696. * 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.
  30697. */
  30698. /**
  30699. * Sets the global Exposure value.
  30700. * 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.
  30701. */
  30702. globalExposure: number;
  30703. private _highlightsHue;
  30704. private _highlightsDensity;
  30705. private _highlightsSaturation;
  30706. private _highlightsExposure;
  30707. /**
  30708. * Gets the highlights Hue value.
  30709. * 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).
  30710. */
  30711. /**
  30712. * Sets the highlights Hue value.
  30713. * 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).
  30714. */
  30715. highlightsHue: number;
  30716. /**
  30717. * Gets the highlights Density value.
  30718. * 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.
  30719. * Values less than zero provide a filter of opposite hue.
  30720. */
  30721. /**
  30722. * Sets the highlights Density value.
  30723. * 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.
  30724. * Values less than zero provide a filter of opposite hue.
  30725. */
  30726. highlightsDensity: number;
  30727. /**
  30728. * Gets the highlights Saturation value.
  30729. * 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.
  30730. */
  30731. /**
  30732. * Sets the highlights Saturation value.
  30733. * 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.
  30734. */
  30735. highlightsSaturation: number;
  30736. /**
  30737. * Gets the highlights Exposure value.
  30738. * 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.
  30739. */
  30740. /**
  30741. * Sets the highlights Exposure value.
  30742. * 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.
  30743. */
  30744. highlightsExposure: number;
  30745. private _midtonesHue;
  30746. private _midtonesDensity;
  30747. private _midtonesSaturation;
  30748. private _midtonesExposure;
  30749. /**
  30750. * Gets the midtones Hue value.
  30751. * 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).
  30752. */
  30753. /**
  30754. * Sets the midtones Hue value.
  30755. * 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).
  30756. */
  30757. midtonesHue: number;
  30758. /**
  30759. * Gets the midtones Density value.
  30760. * 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.
  30761. * Values less than zero provide a filter of opposite hue.
  30762. */
  30763. /**
  30764. * Sets the midtones Density value.
  30765. * 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.
  30766. * Values less than zero provide a filter of opposite hue.
  30767. */
  30768. midtonesDensity: number;
  30769. /**
  30770. * Gets the midtones Saturation value.
  30771. * 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.
  30772. */
  30773. /**
  30774. * Sets the midtones Saturation value.
  30775. * 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.
  30776. */
  30777. midtonesSaturation: number;
  30778. /**
  30779. * Gets the midtones Exposure value.
  30780. * 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.
  30781. */
  30782. /**
  30783. * Sets the midtones Exposure value.
  30784. * 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.
  30785. */
  30786. midtonesExposure: number;
  30787. private _shadowsHue;
  30788. private _shadowsDensity;
  30789. private _shadowsSaturation;
  30790. private _shadowsExposure;
  30791. /**
  30792. * Gets the shadows Hue value.
  30793. * 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).
  30794. */
  30795. /**
  30796. * Sets the shadows Hue value.
  30797. * 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).
  30798. */
  30799. shadowsHue: number;
  30800. /**
  30801. * Gets the shadows Density value.
  30802. * 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.
  30803. * Values less than zero provide a filter of opposite hue.
  30804. */
  30805. /**
  30806. * Sets the shadows Density value.
  30807. * 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.
  30808. * Values less than zero provide a filter of opposite hue.
  30809. */
  30810. shadowsDensity: number;
  30811. /**
  30812. * Gets the shadows Saturation value.
  30813. * 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.
  30814. */
  30815. /**
  30816. * Sets the shadows Saturation value.
  30817. * 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.
  30818. */
  30819. shadowsSaturation: number;
  30820. /**
  30821. * Gets the shadows Exposure value.
  30822. * 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.
  30823. */
  30824. /**
  30825. * Sets the shadows Exposure value.
  30826. * 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.
  30827. */
  30828. shadowsExposure: number;
  30829. /**
  30830. * Returns the class name
  30831. * @returns The class name
  30832. */
  30833. getClassName(): string;
  30834. /**
  30835. * Binds the color curves to the shader.
  30836. * @param colorCurves The color curve to bind
  30837. * @param effect The effect to bind to
  30838. * @param positiveUniform The positive uniform shader parameter
  30839. * @param neutralUniform The neutral uniform shader parameter
  30840. * @param negativeUniform The negative uniform shader parameter
  30841. */
  30842. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30843. /**
  30844. * Prepare the list of uniforms associated with the ColorCurves effects.
  30845. * @param uniformsList The list of uniforms used in the effect
  30846. */
  30847. static PrepareUniforms(uniformsList: string[]): void;
  30848. /**
  30849. * Returns color grading data based on a hue, density, saturation and exposure value.
  30850. * @param filterHue The hue of the color filter.
  30851. * @param filterDensity The density of the color filter.
  30852. * @param saturation The saturation.
  30853. * @param exposure The exposure.
  30854. * @param result The result data container.
  30855. */
  30856. private getColorGradingDataToRef;
  30857. /**
  30858. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30859. * @param value The input slider value in range [-100,100].
  30860. * @returns Adjusted value.
  30861. */
  30862. private static applyColorGradingSliderNonlinear;
  30863. /**
  30864. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30865. * @param hue The hue (H) input.
  30866. * @param saturation The saturation (S) input.
  30867. * @param brightness The brightness (B) input.
  30868. * @result An RGBA color represented as Vector4.
  30869. */
  30870. private static fromHSBToRef;
  30871. /**
  30872. * Returns a value clamped between min and max
  30873. * @param value The value to clamp
  30874. * @param min The minimum of value
  30875. * @param max The maximum of value
  30876. * @returns The clamped value.
  30877. */
  30878. private static clamp;
  30879. /**
  30880. * Clones the current color curve instance.
  30881. * @return The cloned curves
  30882. */
  30883. clone(): ColorCurves;
  30884. /**
  30885. * Serializes the current color curve instance to a json representation.
  30886. * @return a JSON representation
  30887. */
  30888. serialize(): any;
  30889. /**
  30890. * Parses the color curve from a json representation.
  30891. * @param source the JSON source to parse
  30892. * @return The parsed curves
  30893. */
  30894. static Parse(source: any): ColorCurves;
  30895. }
  30896. }
  30897. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30898. import { Observable } from "babylonjs/Misc/observable";
  30899. import { Nullable } from "babylonjs/types";
  30900. import { Color4 } from "babylonjs/Maths/math";
  30901. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30902. import { Effect } from "babylonjs/Materials/effect";
  30903. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30904. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30905. /**
  30906. * Interface to follow in your material defines to integrate easily the
  30907. * Image proccessing functions.
  30908. * @hidden
  30909. */
  30910. export interface IImageProcessingConfigurationDefines {
  30911. IMAGEPROCESSING: boolean;
  30912. VIGNETTE: boolean;
  30913. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30914. VIGNETTEBLENDMODEOPAQUE: boolean;
  30915. TONEMAPPING: boolean;
  30916. TONEMAPPING_ACES: boolean;
  30917. CONTRAST: boolean;
  30918. EXPOSURE: boolean;
  30919. COLORCURVES: boolean;
  30920. COLORGRADING: boolean;
  30921. COLORGRADING3D: boolean;
  30922. SAMPLER3DGREENDEPTH: boolean;
  30923. SAMPLER3DBGRMAP: boolean;
  30924. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30925. }
  30926. /**
  30927. * @hidden
  30928. */
  30929. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30930. IMAGEPROCESSING: boolean;
  30931. VIGNETTE: boolean;
  30932. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30933. VIGNETTEBLENDMODEOPAQUE: boolean;
  30934. TONEMAPPING: boolean;
  30935. TONEMAPPING_ACES: boolean;
  30936. CONTRAST: boolean;
  30937. COLORCURVES: boolean;
  30938. COLORGRADING: boolean;
  30939. COLORGRADING3D: boolean;
  30940. SAMPLER3DGREENDEPTH: boolean;
  30941. SAMPLER3DBGRMAP: boolean;
  30942. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30943. EXPOSURE: boolean;
  30944. constructor();
  30945. }
  30946. /**
  30947. * This groups together the common properties used for image processing either in direct forward pass
  30948. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30949. * or not.
  30950. */
  30951. export class ImageProcessingConfiguration {
  30952. /**
  30953. * Default tone mapping applied in BabylonJS.
  30954. */
  30955. static readonly TONEMAPPING_STANDARD: number;
  30956. /**
  30957. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30958. * to other engines rendering to increase portability.
  30959. */
  30960. static readonly TONEMAPPING_ACES: number;
  30961. /**
  30962. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30963. */
  30964. colorCurves: Nullable<ColorCurves>;
  30965. private _colorCurvesEnabled;
  30966. /**
  30967. * Gets wether the color curves effect is enabled.
  30968. */
  30969. /**
  30970. * Sets wether the color curves effect is enabled.
  30971. */
  30972. colorCurvesEnabled: boolean;
  30973. private _colorGradingTexture;
  30974. /**
  30975. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30976. */
  30977. /**
  30978. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30979. */
  30980. colorGradingTexture: Nullable<BaseTexture>;
  30981. private _colorGradingEnabled;
  30982. /**
  30983. * Gets wether the color grading effect is enabled.
  30984. */
  30985. /**
  30986. * Sets wether the color grading effect is enabled.
  30987. */
  30988. colorGradingEnabled: boolean;
  30989. private _colorGradingWithGreenDepth;
  30990. /**
  30991. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30992. */
  30993. /**
  30994. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30995. */
  30996. colorGradingWithGreenDepth: boolean;
  30997. private _colorGradingBGR;
  30998. /**
  30999. * Gets wether the color grading texture contains BGR values.
  31000. */
  31001. /**
  31002. * Sets wether the color grading texture contains BGR values.
  31003. */
  31004. colorGradingBGR: boolean;
  31005. /** @hidden */
  31006. _exposure: number;
  31007. /**
  31008. * Gets the Exposure used in the effect.
  31009. */
  31010. /**
  31011. * Sets the Exposure used in the effect.
  31012. */
  31013. exposure: number;
  31014. private _toneMappingEnabled;
  31015. /**
  31016. * Gets wether the tone mapping effect is enabled.
  31017. */
  31018. /**
  31019. * Sets wether the tone mapping effect is enabled.
  31020. */
  31021. toneMappingEnabled: boolean;
  31022. private _toneMappingType;
  31023. /**
  31024. * Gets the type of tone mapping effect.
  31025. */
  31026. /**
  31027. * Sets the type of tone mapping effect used in BabylonJS.
  31028. */
  31029. toneMappingType: number;
  31030. protected _contrast: number;
  31031. /**
  31032. * Gets the contrast used in the effect.
  31033. */
  31034. /**
  31035. * Sets the contrast used in the effect.
  31036. */
  31037. contrast: number;
  31038. /**
  31039. * Vignette stretch size.
  31040. */
  31041. vignetteStretch: number;
  31042. /**
  31043. * Vignette centre X Offset.
  31044. */
  31045. vignetteCentreX: number;
  31046. /**
  31047. * Vignette centre Y Offset.
  31048. */
  31049. vignetteCentreY: number;
  31050. /**
  31051. * Vignette weight or intensity of the vignette effect.
  31052. */
  31053. vignetteWeight: number;
  31054. /**
  31055. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31056. * if vignetteEnabled is set to true.
  31057. */
  31058. vignetteColor: Color4;
  31059. /**
  31060. * Camera field of view used by the Vignette effect.
  31061. */
  31062. vignetteCameraFov: number;
  31063. private _vignetteBlendMode;
  31064. /**
  31065. * Gets the vignette blend mode allowing different kind of effect.
  31066. */
  31067. /**
  31068. * Sets the vignette blend mode allowing different kind of effect.
  31069. */
  31070. vignetteBlendMode: number;
  31071. private _vignetteEnabled;
  31072. /**
  31073. * Gets wether the vignette effect is enabled.
  31074. */
  31075. /**
  31076. * Sets wether the vignette effect is enabled.
  31077. */
  31078. vignetteEnabled: boolean;
  31079. private _applyByPostProcess;
  31080. /**
  31081. * Gets wether the image processing is applied through a post process or not.
  31082. */
  31083. /**
  31084. * Sets wether the image processing is applied through a post process or not.
  31085. */
  31086. applyByPostProcess: boolean;
  31087. private _isEnabled;
  31088. /**
  31089. * Gets wether the image processing is enabled or not.
  31090. */
  31091. /**
  31092. * Sets wether the image processing is enabled or not.
  31093. */
  31094. isEnabled: boolean;
  31095. /**
  31096. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31097. */
  31098. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31099. /**
  31100. * Method called each time the image processing information changes requires to recompile the effect.
  31101. */
  31102. protected _updateParameters(): void;
  31103. /**
  31104. * Gets the current class name.
  31105. * @return "ImageProcessingConfiguration"
  31106. */
  31107. getClassName(): string;
  31108. /**
  31109. * Prepare the list of uniforms associated with the Image Processing effects.
  31110. * @param uniforms The list of uniforms used in the effect
  31111. * @param defines the list of defines currently in use
  31112. */
  31113. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31114. /**
  31115. * Prepare the list of samplers associated with the Image Processing effects.
  31116. * @param samplersList The list of uniforms used in the effect
  31117. * @param defines the list of defines currently in use
  31118. */
  31119. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31120. /**
  31121. * Prepare the list of defines associated to the shader.
  31122. * @param defines the list of defines to complete
  31123. * @param forPostProcess Define if we are currently in post process mode or not
  31124. */
  31125. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31126. /**
  31127. * Returns true if all the image processing information are ready.
  31128. * @returns True if ready, otherwise, false
  31129. */
  31130. isReady(): boolean;
  31131. /**
  31132. * Binds the image processing to the shader.
  31133. * @param effect The effect to bind to
  31134. * @param aspectRatio Define the current aspect ratio of the effect
  31135. */
  31136. bind(effect: Effect, aspectRatio?: number): void;
  31137. /**
  31138. * Clones the current image processing instance.
  31139. * @return The cloned image processing
  31140. */
  31141. clone(): ImageProcessingConfiguration;
  31142. /**
  31143. * Serializes the current image processing instance to a json representation.
  31144. * @return a JSON representation
  31145. */
  31146. serialize(): any;
  31147. /**
  31148. * Parses the image processing from a json representation.
  31149. * @param source the JSON source to parse
  31150. * @return The parsed image processing
  31151. */
  31152. static Parse(source: any): ImageProcessingConfiguration;
  31153. private static _VIGNETTEMODE_MULTIPLY;
  31154. private static _VIGNETTEMODE_OPAQUE;
  31155. /**
  31156. * Used to apply the vignette as a mix with the pixel color.
  31157. */
  31158. static readonly VIGNETTEMODE_MULTIPLY: number;
  31159. /**
  31160. * Used to apply the vignette as a replacement of the pixel color.
  31161. */
  31162. static readonly VIGNETTEMODE_OPAQUE: number;
  31163. }
  31164. }
  31165. declare module "babylonjs/Materials/fresnelParameters" {
  31166. import { Color3 } from "babylonjs/Maths/math";
  31167. /**
  31168. * This represents all the required information to add a fresnel effect on a material:
  31169. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31170. */
  31171. export class FresnelParameters {
  31172. private _isEnabled;
  31173. /**
  31174. * Define if the fresnel effect is enable or not.
  31175. */
  31176. isEnabled: boolean;
  31177. /**
  31178. * Define the color used on edges (grazing angle)
  31179. */
  31180. leftColor: Color3;
  31181. /**
  31182. * Define the color used on center
  31183. */
  31184. rightColor: Color3;
  31185. /**
  31186. * Define bias applied to computed fresnel term
  31187. */
  31188. bias: number;
  31189. /**
  31190. * Defined the power exponent applied to fresnel term
  31191. */
  31192. power: number;
  31193. /**
  31194. * Clones the current fresnel and its valuues
  31195. * @returns a clone fresnel configuration
  31196. */
  31197. clone(): FresnelParameters;
  31198. /**
  31199. * Serializes the current fresnel parameters to a JSON representation.
  31200. * @return the JSON serialization
  31201. */
  31202. serialize(): any;
  31203. /**
  31204. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31205. * @param parsedFresnelParameters Define the JSON representation
  31206. * @returns the parsed parameters
  31207. */
  31208. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31209. }
  31210. }
  31211. declare module "babylonjs/Misc/decorators" {
  31212. import { Nullable } from "babylonjs/types";
  31213. import { Scene } from "babylonjs/scene";
  31214. import { IAnimatable } from "babylonjs/Misc/tools";
  31215. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31216. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31217. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31218. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31219. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31220. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31221. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31222. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31223. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31224. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31225. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31226. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31227. /**
  31228. * Decorator used to define property that can be serialized as reference to a camera
  31229. * @param sourceName defines the name of the property to decorate
  31230. */
  31231. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31232. /**
  31233. * Class used to help serialization objects
  31234. */
  31235. export class SerializationHelper {
  31236. /** hidden */
  31237. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31238. /** hidden */
  31239. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31240. /** hidden */
  31241. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31242. /** hidden */
  31243. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31244. /**
  31245. * Appends the serialized animations from the source animations
  31246. * @param source Source containing the animations
  31247. * @param destination Target to store the animations
  31248. */
  31249. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31250. /**
  31251. * Static function used to serialized a specific entity
  31252. * @param entity defines the entity to serialize
  31253. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31254. * @returns a JSON compatible object representing the serialization of the entity
  31255. */
  31256. static Serialize<T>(entity: T, serializationObject?: any): any;
  31257. /**
  31258. * Creates a new entity from a serialization data object
  31259. * @param creationFunction defines a function used to instanciated the new entity
  31260. * @param source defines the source serialization data
  31261. * @param scene defines the hosting scene
  31262. * @param rootUrl defines the root url for resources
  31263. * @returns a new entity
  31264. */
  31265. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31266. /**
  31267. * Clones an object
  31268. * @param creationFunction defines the function used to instanciate the new object
  31269. * @param source defines the source object
  31270. * @returns the cloned object
  31271. */
  31272. static Clone<T>(creationFunction: () => T, source: T): T;
  31273. /**
  31274. * Instanciates a new object based on a source one (some data will be shared between both object)
  31275. * @param creationFunction defines the function used to instanciate the new object
  31276. * @param source defines the source object
  31277. * @returns the new object
  31278. */
  31279. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31280. }
  31281. }
  31282. declare module "babylonjs/Shaders/pass.fragment" {
  31283. /** @hidden */
  31284. export var passPixelShader: {
  31285. name: string;
  31286. shader: string;
  31287. };
  31288. }
  31289. declare module "babylonjs/Shaders/passCube.fragment" {
  31290. /** @hidden */
  31291. export var passCubePixelShader: {
  31292. name: string;
  31293. shader: string;
  31294. };
  31295. }
  31296. declare module "babylonjs/PostProcesses/passPostProcess" {
  31297. import { Nullable } from "babylonjs/types";
  31298. import { Camera } from "babylonjs/Cameras/camera";
  31299. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  31300. import { Engine } from "babylonjs/Engines/engine";
  31301. import "babylonjs/Shaders/pass.fragment";
  31302. import "babylonjs/Shaders/passCube.fragment";
  31303. /**
  31304. * PassPostProcess which produces an output the same as it's input
  31305. */
  31306. export class PassPostProcess extends PostProcess {
  31307. /**
  31308. * Creates the PassPostProcess
  31309. * @param name The name of the effect.
  31310. * @param options The required width/height ratio to downsize to before computing the render pass.
  31311. * @param camera The camera to apply the render pass to.
  31312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31313. * @param engine The engine which the post process will be applied. (default: current engine)
  31314. * @param reusable If the post process can be reused on the same frame. (default: false)
  31315. * @param textureType The type of texture to be used when performing the post processing.
  31316. * @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)
  31317. */
  31318. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31319. }
  31320. /**
  31321. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  31322. */
  31323. export class PassCubePostProcess extends PostProcess {
  31324. private _face;
  31325. /**
  31326. * Gets or sets the cube face to display.
  31327. * * 0 is +X
  31328. * * 1 is -X
  31329. * * 2 is +Y
  31330. * * 3 is -Y
  31331. * * 4 is +Z
  31332. * * 5 is -Z
  31333. */
  31334. face: number;
  31335. /**
  31336. * Creates the PassCubePostProcess
  31337. * @param name The name of the effect.
  31338. * @param options The required width/height ratio to downsize to before computing the render pass.
  31339. * @param camera The camera to apply the render pass to.
  31340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31341. * @param engine The engine which the post process will be applied. (default: current engine)
  31342. * @param reusable If the post process can be reused on the same frame. (default: false)
  31343. * @param textureType The type of texture to be used when performing the post processing.
  31344. * @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)
  31345. */
  31346. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31347. }
  31348. }
  31349. declare module "babylonjs/Shaders/anaglyph.fragment" {
  31350. /** @hidden */
  31351. export var anaglyphPixelShader: {
  31352. name: string;
  31353. shader: string;
  31354. };
  31355. }
  31356. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  31357. import { Engine } from "babylonjs/Engines/engine";
  31358. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  31359. import { Camera } from "babylonjs/Cameras/camera";
  31360. import "babylonjs/Shaders/anaglyph.fragment";
  31361. /**
  31362. * Postprocess used to generate anaglyphic rendering
  31363. */
  31364. export class AnaglyphPostProcess extends PostProcess {
  31365. private _passedProcess;
  31366. /**
  31367. * Creates a new AnaglyphPostProcess
  31368. * @param name defines postprocess name
  31369. * @param options defines creation options or target ratio scale
  31370. * @param rigCameras defines cameras using this postprocess
  31371. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  31372. * @param engine defines hosting engine
  31373. * @param reusable defines if the postprocess will be reused multiple times per frame
  31374. */
  31375. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  31376. }
  31377. }
  31378. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  31379. /** @hidden */
  31380. export var stereoscopicInterlacePixelShader: {
  31381. name: string;
  31382. shader: string;
  31383. };
  31384. }
  31385. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  31386. import { Camera } from "babylonjs/Cameras/camera";
  31387. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31388. import { Engine } from "babylonjs/Engines/engine";
  31389. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  31390. /**
  31391. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  31392. */
  31393. export class StereoscopicInterlacePostProcess extends PostProcess {
  31394. private _stepSize;
  31395. private _passedProcess;
  31396. /**
  31397. * Initializes a StereoscopicInterlacePostProcess
  31398. * @param name The name of the effect.
  31399. * @param rigCameras The rig cameras to be appled to the post process
  31400. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  31401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31402. * @param engine The engine which the post process will be applied. (default: current engine)
  31403. * @param reusable If the post process can be reused on the same frame. (default: false)
  31404. */
  31405. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  31406. }
  31407. }
  31408. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  31409. import { Matrix } from "babylonjs/Maths/math";
  31410. /**
  31411. * This represents all the required metrics to create a VR camera.
  31412. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  31413. */
  31414. export class VRCameraMetrics {
  31415. /**
  31416. * Define the horizontal resolution off the screen.
  31417. */
  31418. hResolution: number;
  31419. /**
  31420. * Define the vertical resolution off the screen.
  31421. */
  31422. vResolution: number;
  31423. /**
  31424. * Define the horizontal screen size.
  31425. */
  31426. hScreenSize: number;
  31427. /**
  31428. * Define the vertical screen size.
  31429. */
  31430. vScreenSize: number;
  31431. /**
  31432. * Define the vertical screen center position.
  31433. */
  31434. vScreenCenter: number;
  31435. /**
  31436. * Define the distance of the eyes to the screen.
  31437. */
  31438. eyeToScreenDistance: number;
  31439. /**
  31440. * Define the distance between both lenses
  31441. */
  31442. lensSeparationDistance: number;
  31443. /**
  31444. * Define the distance between both viewer's eyes.
  31445. */
  31446. interpupillaryDistance: number;
  31447. /**
  31448. * Define the distortion factor of the VR postprocess.
  31449. * Please, touch with care.
  31450. */
  31451. distortionK: number[];
  31452. /**
  31453. * Define the chromatic aberration correction factors for the VR post process.
  31454. */
  31455. chromaAbCorrection: number[];
  31456. /**
  31457. * Define the scale factor of the post process.
  31458. * The smaller the better but the slower.
  31459. */
  31460. postProcessScaleFactor: number;
  31461. /**
  31462. * Define an offset for the lens center.
  31463. */
  31464. lensCenterOffset: number;
  31465. /**
  31466. * Define if the current vr camera should compensate the distortion of the lense or not.
  31467. */
  31468. compensateDistortion: boolean;
  31469. /**
  31470. * Gets the rendering aspect ratio based on the provided resolutions.
  31471. */
  31472. readonly aspectRatio: number;
  31473. /**
  31474. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  31475. */
  31476. readonly aspectRatioFov: number;
  31477. /**
  31478. * @hidden
  31479. */
  31480. readonly leftHMatrix: Matrix;
  31481. /**
  31482. * @hidden
  31483. */
  31484. readonly rightHMatrix: Matrix;
  31485. /**
  31486. * @hidden
  31487. */
  31488. readonly leftPreViewMatrix: Matrix;
  31489. /**
  31490. * @hidden
  31491. */
  31492. readonly rightPreViewMatrix: Matrix;
  31493. /**
  31494. * Get the default VRMetrics based on the most generic setup.
  31495. * @returns the default vr metrics
  31496. */
  31497. static GetDefault(): VRCameraMetrics;
  31498. }
  31499. }
  31500. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  31501. /** @hidden */
  31502. export var vrDistortionCorrectionPixelShader: {
  31503. name: string;
  31504. shader: string;
  31505. };
  31506. }
  31507. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  31508. import { Camera } from "babylonjs/Cameras/camera";
  31509. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  31510. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31511. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  31512. /**
  31513. * VRDistortionCorrectionPostProcess used for mobile VR
  31514. */
  31515. export class VRDistortionCorrectionPostProcess extends PostProcess {
  31516. private _isRightEye;
  31517. private _distortionFactors;
  31518. private _postProcessScaleFactor;
  31519. private _lensCenterOffset;
  31520. private _scaleIn;
  31521. private _scaleFactor;
  31522. private _lensCenter;
  31523. /**
  31524. * Initializes the VRDistortionCorrectionPostProcess
  31525. * @param name The name of the effect.
  31526. * @param camera The camera to apply the render pass to.
  31527. * @param isRightEye If this is for the right eye distortion
  31528. * @param vrMetrics All the required metrics for the VR camera
  31529. */
  31530. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  31531. }
  31532. }
  31533. declare module "babylonjs/Cameras/camera" {
  31534. import { SmartArray } from "babylonjs/Misc/smartArray";
  31535. import { Observable } from "babylonjs/Misc/observable";
  31536. import { Nullable } from "babylonjs/types";
  31537. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31538. import { Scene } from "babylonjs/scene";
  31539. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31540. import { Node } from "babylonjs/node";
  31541. import { Mesh } from "babylonjs/Meshes/mesh";
  31542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31543. import { Ray } from "babylonjs/Culling/ray";
  31544. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31545. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31546. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31547. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31548. /**
  31549. * This is the base class of all the camera used in the application.
  31550. * @see http://doc.babylonjs.com/features/cameras
  31551. */
  31552. export class Camera extends Node {
  31553. /** @hidden */
  31554. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31555. /**
  31556. * This is the default projection mode used by the cameras.
  31557. * It helps recreating a feeling of perspective and better appreciate depth.
  31558. * This is the best way to simulate real life cameras.
  31559. */
  31560. static readonly PERSPECTIVE_CAMERA: number;
  31561. /**
  31562. * This helps creating camera with an orthographic mode.
  31563. * 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.
  31564. */
  31565. static readonly ORTHOGRAPHIC_CAMERA: number;
  31566. /**
  31567. * This is the default FOV mode for perspective cameras.
  31568. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31569. */
  31570. static readonly FOVMODE_VERTICAL_FIXED: number;
  31571. /**
  31572. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31573. */
  31574. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31575. /**
  31576. * This specifies ther is no need for a camera rig.
  31577. * Basically only one eye is rendered corresponding to the camera.
  31578. */
  31579. static readonly RIG_MODE_NONE: number;
  31580. /**
  31581. * Simulates a camera Rig with one blue eye and one red eye.
  31582. * This can be use with 3d blue and red glasses.
  31583. */
  31584. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31585. /**
  31586. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31587. */
  31588. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31589. /**
  31590. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31591. */
  31592. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31593. /**
  31594. * Defines that both eyes of the camera will be rendered over under each other.
  31595. */
  31596. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31597. /**
  31598. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31599. */
  31600. static readonly RIG_MODE_VR: number;
  31601. /**
  31602. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31603. */
  31604. static readonly RIG_MODE_WEBVR: number;
  31605. /**
  31606. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31607. */
  31608. static readonly RIG_MODE_CUSTOM: number;
  31609. /**
  31610. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31611. */
  31612. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31613. /**
  31614. * @hidden
  31615. * Might be removed once multiview will be a thing
  31616. */
  31617. static UseAlternateWebVRRendering: boolean;
  31618. /**
  31619. * Define the input manager associated with the camera.
  31620. */
  31621. inputs: CameraInputsManager<Camera>;
  31622. /**
  31623. * Define the current local position of the camera in the scene
  31624. */
  31625. position: Vector3;
  31626. /**
  31627. * The vector the camera should consider as up.
  31628. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31629. */
  31630. upVector: Vector3;
  31631. /**
  31632. * Define the current limit on the left side for an orthographic camera
  31633. * In scene unit
  31634. */
  31635. orthoLeft: Nullable<number>;
  31636. /**
  31637. * Define the current limit on the right side for an orthographic camera
  31638. * In scene unit
  31639. */
  31640. orthoRight: Nullable<number>;
  31641. /**
  31642. * Define the current limit on the bottom side for an orthographic camera
  31643. * In scene unit
  31644. */
  31645. orthoBottom: Nullable<number>;
  31646. /**
  31647. * Define the current limit on the top side for an orthographic camera
  31648. * In scene unit
  31649. */
  31650. orthoTop: Nullable<number>;
  31651. /**
  31652. * Field Of View is set in Radians. (default is 0.8)
  31653. */
  31654. fov: number;
  31655. /**
  31656. * Define the minimum distance the camera can see from.
  31657. * This is important to note that the depth buffer are not infinite and the closer it starts
  31658. * the more your scene might encounter depth fighting issue.
  31659. */
  31660. minZ: number;
  31661. /**
  31662. * Define the maximum distance the camera can see to.
  31663. * This is important to note that the depth buffer are not infinite and the further it end
  31664. * the more your scene might encounter depth fighting issue.
  31665. */
  31666. maxZ: number;
  31667. /**
  31668. * Define the default inertia of the camera.
  31669. * This helps giving a smooth feeling to the camera movement.
  31670. */
  31671. inertia: number;
  31672. /**
  31673. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31674. */
  31675. mode: number;
  31676. /**
  31677. * Define wether the camera is intermediate.
  31678. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31679. */
  31680. isIntermediate: boolean;
  31681. /**
  31682. * Define the viewport of the camera.
  31683. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31684. */
  31685. viewport: Viewport;
  31686. /**
  31687. * Restricts the camera to viewing objects with the same layerMask.
  31688. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31689. */
  31690. layerMask: number;
  31691. /**
  31692. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31693. */
  31694. fovMode: number;
  31695. /**
  31696. * Rig mode of the camera.
  31697. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31698. * This is normally controlled byt the camera themselves as internal use.
  31699. */
  31700. cameraRigMode: number;
  31701. /**
  31702. * Defines the distance between both "eyes" in case of a RIG
  31703. */
  31704. interaxialDistance: number;
  31705. /**
  31706. * Defines if stereoscopic rendering is done side by side or over under.
  31707. */
  31708. isStereoscopicSideBySide: boolean;
  31709. /**
  31710. * 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
  31711. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31712. * else in the scene.
  31713. */
  31714. customRenderTargets: RenderTargetTexture[];
  31715. /**
  31716. * When set, the camera will render to this render target instead of the default canvas
  31717. */
  31718. outputRenderTarget: Nullable<RenderTargetTexture>;
  31719. /**
  31720. * Observable triggered when the camera view matrix has changed.
  31721. */
  31722. onViewMatrixChangedObservable: Observable<Camera>;
  31723. /**
  31724. * Observable triggered when the camera Projection matrix has changed.
  31725. */
  31726. onProjectionMatrixChangedObservable: Observable<Camera>;
  31727. /**
  31728. * Observable triggered when the inputs have been processed.
  31729. */
  31730. onAfterCheckInputsObservable: Observable<Camera>;
  31731. /**
  31732. * Observable triggered when reset has been called and applied to the camera.
  31733. */
  31734. onRestoreStateObservable: Observable<Camera>;
  31735. /** @hidden */
  31736. _cameraRigParams: any;
  31737. /** @hidden */
  31738. _rigCameras: Camera[];
  31739. /** @hidden */
  31740. _rigPostProcess: Nullable<PostProcess>;
  31741. protected _webvrViewMatrix: Matrix;
  31742. /** @hidden */
  31743. _skipRendering: boolean;
  31744. /** @hidden */
  31745. _alternateCamera: Camera;
  31746. /** @hidden */
  31747. _projectionMatrix: Matrix;
  31748. /** @hidden */
  31749. _postProcesses: Nullable<PostProcess>[];
  31750. /** @hidden */
  31751. _activeMeshes: SmartArray<AbstractMesh>;
  31752. protected _globalPosition: Vector3;
  31753. /** hidden */
  31754. _computedViewMatrix: Matrix;
  31755. private _doNotComputeProjectionMatrix;
  31756. private _transformMatrix;
  31757. private _frustumPlanes;
  31758. private _refreshFrustumPlanes;
  31759. private _storedFov;
  31760. private _stateStored;
  31761. /**
  31762. * Instantiates a new camera object.
  31763. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31764. * @see http://doc.babylonjs.com/features/cameras
  31765. * @param name Defines the name of the camera in the scene
  31766. * @param position Defines the position of the camera
  31767. * @param scene Defines the scene the camera belongs too
  31768. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31769. */
  31770. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31771. /**
  31772. * Store current camera state (fov, position, etc..)
  31773. * @returns the camera
  31774. */
  31775. storeState(): Camera;
  31776. /**
  31777. * Restores the camera state values if it has been stored. You must call storeState() first
  31778. */
  31779. protected _restoreStateValues(): boolean;
  31780. /**
  31781. * Restored camera state. You must call storeState() first.
  31782. * @returns true if restored and false otherwise
  31783. */
  31784. restoreState(): boolean;
  31785. /**
  31786. * Gets the class name of the camera.
  31787. * @returns the class name
  31788. */
  31789. getClassName(): string;
  31790. /** @hidden */
  31791. readonly _isCamera: boolean;
  31792. /**
  31793. * Gets a string representation of the camera useful for debug purpose.
  31794. * @param fullDetails Defines that a more verboe level of logging is required
  31795. * @returns the string representation
  31796. */
  31797. toString(fullDetails?: boolean): string;
  31798. /**
  31799. * Gets the current world space position of the camera.
  31800. */
  31801. readonly globalPosition: Vector3;
  31802. /**
  31803. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31804. * @returns the active meshe list
  31805. */
  31806. getActiveMeshes(): SmartArray<AbstractMesh>;
  31807. /**
  31808. * Check wether a mesh is part of the current active mesh list of the camera
  31809. * @param mesh Defines the mesh to check
  31810. * @returns true if active, false otherwise
  31811. */
  31812. isActiveMesh(mesh: Mesh): boolean;
  31813. /**
  31814. * Is this camera ready to be used/rendered
  31815. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31816. * @return true if the camera is ready
  31817. */
  31818. isReady(completeCheck?: boolean): boolean;
  31819. /** @hidden */
  31820. _initCache(): void;
  31821. /** @hidden */
  31822. _updateCache(ignoreParentClass?: boolean): void;
  31823. /** @hidden */
  31824. _isSynchronized(): boolean;
  31825. /** @hidden */
  31826. _isSynchronizedViewMatrix(): boolean;
  31827. /** @hidden */
  31828. _isSynchronizedProjectionMatrix(): boolean;
  31829. /**
  31830. * Attach the input controls to a specific dom element to get the input from.
  31831. * @param element Defines the element the controls should be listened from
  31832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31833. */
  31834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31835. /**
  31836. * Detach the current controls from the specified dom element.
  31837. * @param element Defines the element to stop listening the inputs from
  31838. */
  31839. detachControl(element: HTMLElement): void;
  31840. /**
  31841. * Update the camera state according to the different inputs gathered during the frame.
  31842. */
  31843. update(): void;
  31844. /** @hidden */
  31845. _checkInputs(): void;
  31846. /** @hidden */
  31847. readonly rigCameras: Camera[];
  31848. /**
  31849. * Gets the post process used by the rig cameras
  31850. */
  31851. readonly rigPostProcess: Nullable<PostProcess>;
  31852. /**
  31853. * Internal, gets the first post proces.
  31854. * @returns the first post process to be run on this camera.
  31855. */
  31856. _getFirstPostProcess(): Nullable<PostProcess>;
  31857. private _cascadePostProcessesToRigCams;
  31858. /**
  31859. * Attach a post process to the camera.
  31860. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31861. * @param postProcess The post process to attach to the camera
  31862. * @param insertAt The position of the post process in case several of them are in use in the scene
  31863. * @returns the position the post process has been inserted at
  31864. */
  31865. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31866. /**
  31867. * Detach a post process to the camera.
  31868. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31869. * @param postProcess The post process to detach from the camera
  31870. */
  31871. detachPostProcess(postProcess: PostProcess): void;
  31872. /**
  31873. * Gets the current world matrix of the camera
  31874. */
  31875. getWorldMatrix(): Matrix;
  31876. /** @hidden */
  31877. protected _getViewMatrix(): Matrix;
  31878. /**
  31879. * Gets the current view matrix of the camera.
  31880. * @param force forces the camera to recompute the matrix without looking at the cached state
  31881. * @returns the view matrix
  31882. */
  31883. getViewMatrix(force?: boolean): Matrix;
  31884. /**
  31885. * Freeze the projection matrix.
  31886. * It will prevent the cache check of the camera projection compute and can speed up perf
  31887. * if no parameter of the camera are meant to change
  31888. * @param projection Defines manually a projection if necessary
  31889. */
  31890. freezeProjectionMatrix(projection?: Matrix): void;
  31891. /**
  31892. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31893. */
  31894. unfreezeProjectionMatrix(): void;
  31895. /**
  31896. * Gets the current projection matrix of the camera.
  31897. * @param force forces the camera to recompute the matrix without looking at the cached state
  31898. * @returns the projection matrix
  31899. */
  31900. getProjectionMatrix(force?: boolean): Matrix;
  31901. /**
  31902. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31903. * @returns a Matrix
  31904. */
  31905. getTransformationMatrix(): Matrix;
  31906. private _updateFrustumPlanes;
  31907. /**
  31908. * Checks if a cullable object (mesh...) is in the camera frustum
  31909. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31910. * @param target The object to check
  31911. * @returns true if the object is in frustum otherwise false
  31912. */
  31913. isInFrustum(target: ICullable): boolean;
  31914. /**
  31915. * Checks if a cullable object (mesh...) is in the camera frustum
  31916. * Unlike isInFrustum this cheks the full bounding box
  31917. * @param target The object to check
  31918. * @returns true if the object is in frustum otherwise false
  31919. */
  31920. isCompletelyInFrustum(target: ICullable): boolean;
  31921. /**
  31922. * Gets a ray in the forward direction from the camera.
  31923. * @param length Defines the length of the ray to create
  31924. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31925. * @param origin Defines the start point of the ray which defaults to the camera position
  31926. * @returns the forward ray
  31927. */
  31928. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31929. /**
  31930. * Releases resources associated with this node.
  31931. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31932. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31933. */
  31934. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31935. /**
  31936. * Gets the left camera of a rig setup in case of Rigged Camera
  31937. */
  31938. readonly leftCamera: Nullable<FreeCamera>;
  31939. /**
  31940. * Gets the right camera of a rig setup in case of Rigged Camera
  31941. */
  31942. readonly rightCamera: Nullable<FreeCamera>;
  31943. /**
  31944. * Gets the left camera target of a rig setup in case of Rigged Camera
  31945. * @returns the target position
  31946. */
  31947. getLeftTarget(): Nullable<Vector3>;
  31948. /**
  31949. * Gets the right camera target of a rig setup in case of Rigged Camera
  31950. * @returns the target position
  31951. */
  31952. getRightTarget(): Nullable<Vector3>;
  31953. /**
  31954. * @hidden
  31955. */
  31956. setCameraRigMode(mode: number, rigParams: any): void;
  31957. private _getVRProjectionMatrix;
  31958. protected _updateCameraRotationMatrix(): void;
  31959. protected _updateWebVRCameraRotationMatrix(): void;
  31960. /**
  31961. * This function MUST be overwritten by the different WebVR cameras available.
  31962. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31963. */
  31964. protected _getWebVRProjectionMatrix(): Matrix;
  31965. /**
  31966. * This function MUST be overwritten by the different WebVR cameras available.
  31967. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31968. */
  31969. protected _getWebVRViewMatrix(): Matrix;
  31970. /** @hidden */
  31971. setCameraRigParameter(name: string, value: any): void;
  31972. /**
  31973. * needs to be overridden by children so sub has required properties to be copied
  31974. * @hidden
  31975. */
  31976. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31977. /**
  31978. * May need to be overridden by children
  31979. * @hidden
  31980. */
  31981. _updateRigCameras(): void;
  31982. /** @hidden */
  31983. _setupInputs(): void;
  31984. /**
  31985. * Serialiaze the camera setup to a json represention
  31986. * @returns the JSON representation
  31987. */
  31988. serialize(): any;
  31989. /**
  31990. * Clones the current camera.
  31991. * @param name The cloned camera name
  31992. * @returns the cloned camera
  31993. */
  31994. clone(name: string): Camera;
  31995. /**
  31996. * Gets the direction of the camera relative to a given local axis.
  31997. * @param localAxis Defines the reference axis to provide a relative direction.
  31998. * @return the direction
  31999. */
  32000. getDirection(localAxis: Vector3): Vector3;
  32001. /**
  32002. * Gets the direction of the camera relative to a given local axis into a passed vector.
  32003. * @param localAxis Defines the reference axis to provide a relative direction.
  32004. * @param result Defines the vector to store the result in
  32005. */
  32006. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  32007. /**
  32008. * Gets a camera constructor for a given camera type
  32009. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  32010. * @param name The name of the camera the result will be able to instantiate
  32011. * @param scene The scene the result will construct the camera in
  32012. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  32013. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  32014. * @returns a factory method to construc the camera
  32015. */
  32016. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  32017. /**
  32018. * Compute the world matrix of the camera.
  32019. * @returns the camera workd matrix
  32020. */
  32021. computeWorldMatrix(): Matrix;
  32022. /**
  32023. * Parse a JSON and creates the camera from the parsed information
  32024. * @param parsedCamera The JSON to parse
  32025. * @param scene The scene to instantiate the camera in
  32026. * @returns the newly constructed camera
  32027. */
  32028. static Parse(parsedCamera: any, scene: Scene): Camera;
  32029. }
  32030. }
  32031. declare module "babylonjs/Misc/tools" {
  32032. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  32033. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  32034. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32035. import { Observable } from "babylonjs/Misc/observable";
  32036. import { DomManagement } from "babylonjs/Misc/domManagement";
  32037. import { Camera } from "babylonjs/Cameras/camera";
  32038. import { Engine } from "babylonjs/Engines/engine";
  32039. import { Animation } from "babylonjs/Animations/animation";
  32040. /**
  32041. * Interface for any object that can request an animation frame
  32042. */
  32043. export interface ICustomAnimationFrameRequester {
  32044. /**
  32045. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32046. */
  32047. renderFunction?: Function;
  32048. /**
  32049. * Called to request the next frame to render to
  32050. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32051. */
  32052. requestAnimationFrame: Function;
  32053. /**
  32054. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32055. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32056. */
  32057. requestID?: number;
  32058. }
  32059. /**
  32060. * Interface containing an array of animations
  32061. */
  32062. export interface IAnimatable {
  32063. /**
  32064. * Array of animations
  32065. */
  32066. animations: Array<Animation>;
  32067. }
  32068. /** Interface used by value gradients (color, factor, ...) */
  32069. export interface IValueGradient {
  32070. /**
  32071. * Gets or sets the gradient value (between 0 and 1)
  32072. */
  32073. gradient: number;
  32074. }
  32075. /** Class used to store color4 gradient */
  32076. export class ColorGradient implements IValueGradient {
  32077. /**
  32078. * Gets or sets the gradient value (between 0 and 1)
  32079. */
  32080. gradient: number;
  32081. /**
  32082. * Gets or sets first associated color
  32083. */
  32084. color1: Color4;
  32085. /**
  32086. * Gets or sets second associated color
  32087. */
  32088. color2?: Color4;
  32089. /**
  32090. * Will get a color picked randomly between color1 and color2.
  32091. * If color2 is undefined then color1 will be used
  32092. * @param result defines the target Color4 to store the result in
  32093. */
  32094. getColorToRef(result: Color4): void;
  32095. }
  32096. /** Class used to store color 3 gradient */
  32097. export class Color3Gradient implements IValueGradient {
  32098. /**
  32099. * Gets or sets the gradient value (between 0 and 1)
  32100. */
  32101. gradient: number;
  32102. /**
  32103. * Gets or sets the associated color
  32104. */
  32105. color: Color3;
  32106. }
  32107. /** Class used to store factor gradient */
  32108. export class FactorGradient implements IValueGradient {
  32109. /**
  32110. * Gets or sets the gradient value (between 0 and 1)
  32111. */
  32112. gradient: number;
  32113. /**
  32114. * Gets or sets first associated factor
  32115. */
  32116. factor1: number;
  32117. /**
  32118. * Gets or sets second associated factor
  32119. */
  32120. factor2?: number;
  32121. /**
  32122. * Will get a number picked randomly between factor1 and factor2.
  32123. * If factor2 is undefined then factor1 will be used
  32124. * @returns the picked number
  32125. */
  32126. getFactor(): number;
  32127. }
  32128. /**
  32129. * @ignore
  32130. * Application error to support additional information when loading a file
  32131. */
  32132. export class LoadFileError extends Error {
  32133. /** defines the optional XHR request */
  32134. request?: XMLHttpRequest | undefined;
  32135. private static _setPrototypeOf;
  32136. /**
  32137. * Creates a new LoadFileError
  32138. * @param message defines the message of the error
  32139. * @param request defines the optional XHR request
  32140. */
  32141. constructor(message: string,
  32142. /** defines the optional XHR request */
  32143. request?: XMLHttpRequest | undefined);
  32144. }
  32145. /**
  32146. * Class used to define a retry strategy when error happens while loading assets
  32147. */
  32148. export class RetryStrategy {
  32149. /**
  32150. * Function used to defines an exponential back off strategy
  32151. * @param maxRetries defines the maximum number of retries (3 by default)
  32152. * @param baseInterval defines the interval between retries
  32153. * @returns the strategy function to use
  32154. */
  32155. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  32156. }
  32157. /**
  32158. * File request interface
  32159. */
  32160. export interface IFileRequest {
  32161. /**
  32162. * Raised when the request is complete (success or error).
  32163. */
  32164. onCompleteObservable: Observable<IFileRequest>;
  32165. /**
  32166. * Aborts the request for a file.
  32167. */
  32168. abort: () => void;
  32169. }
  32170. /**
  32171. * Class containing a set of static utilities functions
  32172. */
  32173. export class Tools {
  32174. /**
  32175. * Gets or sets the base URL to use to load assets
  32176. */
  32177. static BaseUrl: string;
  32178. /**
  32179. * Enable/Disable Custom HTTP Request Headers globally.
  32180. * default = false
  32181. * @see CustomRequestHeaders
  32182. */
  32183. static UseCustomRequestHeaders: boolean;
  32184. /**
  32185. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32186. * i.e. when loading files, where the server/service expects an Authorization header.
  32187. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  32188. */
  32189. static CustomRequestHeaders: {
  32190. [key: string]: string;
  32191. };
  32192. /**
  32193. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32194. */
  32195. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  32196. /**
  32197. * Default behaviour for cors in the application.
  32198. * It can be a string if the expected behavior is identical in the entire app.
  32199. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32200. */
  32201. static CorsBehavior: string | ((url: string | string[]) => string);
  32202. /**
  32203. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32204. * @ignorenaming
  32205. */
  32206. static UseFallbackTexture: boolean;
  32207. /**
  32208. * Use this object to register external classes like custom textures or material
  32209. * to allow the laoders to instantiate them
  32210. */
  32211. static RegisteredExternalClasses: {
  32212. [key: string]: Object;
  32213. };
  32214. /**
  32215. * Texture content used if a texture cannot loaded
  32216. * @ignorenaming
  32217. */
  32218. static fallbackTexture: string;
  32219. /**
  32220. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32221. * @param u defines the coordinate on X axis
  32222. * @param v defines the coordinate on Y axis
  32223. * @param width defines the width of the source data
  32224. * @param height defines the height of the source data
  32225. * @param pixels defines the source byte array
  32226. * @param color defines the output color
  32227. */
  32228. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32229. /**
  32230. * Interpolates between a and b via alpha
  32231. * @param a The lower value (returned when alpha = 0)
  32232. * @param b The upper value (returned when alpha = 1)
  32233. * @param alpha The interpolation-factor
  32234. * @return The mixed value
  32235. */
  32236. static Mix(a: number, b: number, alpha: number): number;
  32237. /**
  32238. * Tries to instantiate a new object from a given class name
  32239. * @param className defines the class name to instantiate
  32240. * @returns the new object or null if the system was not able to do the instantiation
  32241. */
  32242. static Instantiate(className: string): any;
  32243. /**
  32244. * Provides a slice function that will work even on IE
  32245. * @param data defines the array to slice
  32246. * @param start defines the start of the data (optional)
  32247. * @param end defines the end of the data (optional)
  32248. * @returns the new sliced array
  32249. */
  32250. static Slice<T>(data: T, start?: number, end?: number): T;
  32251. /**
  32252. * Polyfill for setImmediate
  32253. * @param action defines the action to execute after the current execution block
  32254. */
  32255. static SetImmediate(action: () => void): void;
  32256. /**
  32257. * Function indicating if a number is an exponent of 2
  32258. * @param value defines the value to test
  32259. * @returns true if the value is an exponent of 2
  32260. */
  32261. static IsExponentOfTwo(value: number): boolean;
  32262. private static _tmpFloatArray;
  32263. /**
  32264. * Returns the nearest 32-bit single precision float representation of a Number
  32265. * @param value A Number. If the parameter is of a different type, it will get converted
  32266. * to a number or to NaN if it cannot be converted
  32267. * @returns number
  32268. */
  32269. static FloatRound(value: number): number;
  32270. /**
  32271. * Find the next highest power of two.
  32272. * @param x Number to start search from.
  32273. * @return Next highest power of two.
  32274. */
  32275. static CeilingPOT(x: number): number;
  32276. /**
  32277. * Find the next lowest power of two.
  32278. * @param x Number to start search from.
  32279. * @return Next lowest power of two.
  32280. */
  32281. static FloorPOT(x: number): number;
  32282. /**
  32283. * Find the nearest power of two.
  32284. * @param x Number to start search from.
  32285. * @return Next nearest power of two.
  32286. */
  32287. static NearestPOT(x: number): number;
  32288. /**
  32289. * Get the closest exponent of two
  32290. * @param value defines the value to approximate
  32291. * @param max defines the maximum value to return
  32292. * @param mode defines how to define the closest value
  32293. * @returns closest exponent of two of the given value
  32294. */
  32295. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32296. /**
  32297. * Extracts the filename from a path
  32298. * @param path defines the path to use
  32299. * @returns the filename
  32300. */
  32301. static GetFilename(path: string): string;
  32302. /**
  32303. * Extracts the "folder" part of a path (everything before the filename).
  32304. * @param uri The URI to extract the info from
  32305. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32306. * @returns The "folder" part of the path
  32307. */
  32308. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32309. /**
  32310. * Extracts text content from a DOM element hierarchy
  32311. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32312. */
  32313. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32314. /**
  32315. * Convert an angle in radians to degrees
  32316. * @param angle defines the angle to convert
  32317. * @returns the angle in degrees
  32318. */
  32319. static ToDegrees(angle: number): number;
  32320. /**
  32321. * Convert an angle in degrees to radians
  32322. * @param angle defines the angle to convert
  32323. * @returns the angle in radians
  32324. */
  32325. static ToRadians(angle: number): number;
  32326. /**
  32327. * Encode a buffer to a base64 string
  32328. * @param buffer defines the buffer to encode
  32329. * @returns the encoded string
  32330. */
  32331. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32332. /**
  32333. * Extracts minimum and maximum values from a list of indexed positions
  32334. * @param positions defines the positions to use
  32335. * @param indices defines the indices to the positions
  32336. * @param indexStart defines the start index
  32337. * @param indexCount defines the end index
  32338. * @param bias defines bias value to add to the result
  32339. * @return minimum and maximum values
  32340. */
  32341. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32342. minimum: Vector3;
  32343. maximum: Vector3;
  32344. };
  32345. /**
  32346. * Extracts minimum and maximum values from a list of positions
  32347. * @param positions defines the positions to use
  32348. * @param start defines the start index in the positions array
  32349. * @param count defines the number of positions to handle
  32350. * @param bias defines bias value to add to the result
  32351. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32352. * @return minimum and maximum values
  32353. */
  32354. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32355. minimum: Vector3;
  32356. maximum: Vector3;
  32357. };
  32358. /**
  32359. * Returns an array if obj is not an array
  32360. * @param obj defines the object to evaluate as an array
  32361. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32362. * @returns either obj directly if obj is an array or a new array containing obj
  32363. */
  32364. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32365. /**
  32366. * Gets the pointer prefix to use
  32367. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32368. */
  32369. static GetPointerPrefix(): string;
  32370. /**
  32371. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32372. * @param func - the function to be called
  32373. * @param requester - the object that will request the next frame. Falls back to window.
  32374. * @returns frame number
  32375. */
  32376. static QueueNewFrame(func: () => void, requester?: any): number;
  32377. /**
  32378. * Ask the browser to promote the current element to fullscreen rendering mode
  32379. * @param element defines the DOM element to promote
  32380. */
  32381. static RequestFullscreen(element: HTMLElement): void;
  32382. /**
  32383. * Asks the browser to exit fullscreen mode
  32384. */
  32385. static ExitFullscreen(): void;
  32386. /**
  32387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32388. * @param url define the url we are trying
  32389. * @param element define the dom element where to configure the cors policy
  32390. */
  32391. static SetCorsBehavior(url: string | string[], element: {
  32392. crossOrigin: string | null;
  32393. }): void;
  32394. /**
  32395. * Removes unwanted characters from an url
  32396. * @param url defines the url to clean
  32397. * @returns the cleaned url
  32398. */
  32399. static CleanUrl(url: string): string;
  32400. /**
  32401. * Gets or sets a function used to pre-process url before using them to load assets
  32402. */
  32403. static PreprocessUrl: (url: string) => string;
  32404. /**
  32405. * Loads an image as an HTMLImageElement.
  32406. * @param input url string, ArrayBuffer, or Blob to load
  32407. * @param onLoad callback called when the image successfully loads
  32408. * @param onError callback called when the image fails to load
  32409. * @param offlineProvider offline provider for caching
  32410. * @returns the HTMLImageElement of the loaded image
  32411. */
  32412. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32413. /**
  32414. * Loads a file
  32415. * @param url url string, ArrayBuffer, or Blob to load
  32416. * @param onSuccess callback called when the file successfully loads
  32417. * @param onProgress callback called while file is loading (if the server supports this mode)
  32418. * @param offlineProvider defines the offline provider for caching
  32419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32420. * @param onError callback called when the file fails to load
  32421. * @returns a file request object
  32422. */
  32423. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  32424. /**
  32425. * Load a script (identified by an url). When the url returns, the
  32426. * content of this file is added into a new script element, attached to the DOM (body element)
  32427. * @param scriptUrl defines the url of the script to laod
  32428. * @param onSuccess defines the callback called when the script is loaded
  32429. * @param onError defines the callback to call if an error occurs
  32430. */
  32431. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  32432. /**
  32433. * Loads a file from a blob
  32434. * @param fileToLoad defines the blob to use
  32435. * @param callback defines the callback to call when data is loaded
  32436. * @param progressCallback defines the callback to call during loading process
  32437. * @returns a file request object
  32438. */
  32439. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32440. /**
  32441. * Loads a file
  32442. * @param fileToLoad defines the file to load
  32443. * @param callback defines the callback to call when data is loaded
  32444. * @param progressCallBack defines the callback to call during loading process
  32445. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32446. * @returns a file request object
  32447. */
  32448. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32449. /**
  32450. * Creates a data url from a given string content
  32451. * @param content defines the content to convert
  32452. * @returns the new data url link
  32453. */
  32454. static FileAsURL(content: string): string;
  32455. /**
  32456. * Format the given number to a specific decimal format
  32457. * @param value defines the number to format
  32458. * @param decimals defines the number of decimals to use
  32459. * @returns the formatted string
  32460. */
  32461. static Format(value: number, decimals?: number): string;
  32462. /**
  32463. * Checks if a given vector is inside a specific range
  32464. * @param v defines the vector to test
  32465. * @param min defines the minimum range
  32466. * @param max defines the maximum range
  32467. */
  32468. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32469. /**
  32470. * Tries to copy an object by duplicating every property
  32471. * @param source defines the source object
  32472. * @param destination defines the target object
  32473. * @param doNotCopyList defines a list of properties to avoid
  32474. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32475. */
  32476. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32477. /**
  32478. * Gets a boolean indicating if the given object has no own property
  32479. * @param obj defines the object to test
  32480. * @returns true if object has no own property
  32481. */
  32482. static IsEmpty(obj: any): boolean;
  32483. /**
  32484. * Function used to register events at window level
  32485. * @param events defines the events to register
  32486. */
  32487. static RegisterTopRootEvents(events: {
  32488. name: string;
  32489. handler: Nullable<(e: FocusEvent) => any>;
  32490. }[]): void;
  32491. /**
  32492. * Function used to unregister events from window level
  32493. * @param events defines the events to unregister
  32494. */
  32495. static UnregisterTopRootEvents(events: {
  32496. name: string;
  32497. handler: Nullable<(e: FocusEvent) => any>;
  32498. }[]): void;
  32499. /**
  32500. * Dumps the current bound framebuffer
  32501. * @param width defines the rendering width
  32502. * @param height defines the rendering height
  32503. * @param engine defines the hosting engine
  32504. * @param successCallback defines the callback triggered once the data are available
  32505. * @param mimeType defines the mime type of the result
  32506. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32507. */
  32508. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32509. /**
  32510. * Converts the canvas data to blob.
  32511. * This acts as a polyfill for browsers not supporting the to blob function.
  32512. * @param canvas Defines the canvas to extract the data from
  32513. * @param successCallback Defines the callback triggered once the data are available
  32514. * @param mimeType Defines the mime type of the result
  32515. */
  32516. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32517. /**
  32518. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32519. * @param successCallback defines the callback triggered once the data are available
  32520. * @param mimeType defines the mime type of the result
  32521. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32522. */
  32523. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32524. /**
  32525. * Downloads a blob in the browser
  32526. * @param blob defines the blob to download
  32527. * @param fileName defines the name of the downloaded file
  32528. */
  32529. static Download(blob: Blob, fileName: string): void;
  32530. /**
  32531. * Captures a screenshot of the current rendering
  32532. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32533. * @param engine defines the rendering engine
  32534. * @param camera defines the source camera
  32535. * @param size This parameter can be set to a single number or to an object with the
  32536. * following (optional) properties: precision, width, height. If a single number is passed,
  32537. * it will be used for both width and height. If an object is passed, the screenshot size
  32538. * will be derived from the parameters. The precision property is a multiplier allowing
  32539. * rendering at a higher or lower resolution
  32540. * @param successCallback defines the callback receives a single parameter which contains the
  32541. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32542. * src parameter of an <img> to display it
  32543. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32544. * Check your browser for supported MIME types
  32545. */
  32546. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32547. /**
  32548. * Generates an image screenshot from the specified camera.
  32549. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32550. * @param engine The engine to use for rendering
  32551. * @param camera The camera to use for rendering
  32552. * @param size This parameter can be set to a single number or to an object with the
  32553. * following (optional) properties: precision, width, height. If a single number is passed,
  32554. * it will be used for both width and height. If an object is passed, the screenshot size
  32555. * will be derived from the parameters. The precision property is a multiplier allowing
  32556. * rendering at a higher or lower resolution
  32557. * @param successCallback The callback receives a single parameter which contains the
  32558. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32559. * src parameter of an <img> to display it
  32560. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32561. * Check your browser for supported MIME types
  32562. * @param samples Texture samples (default: 1)
  32563. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32564. * @param fileName A name for for the downloaded file.
  32565. */
  32566. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32567. /**
  32568. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32569. * Be aware Math.random() could cause collisions, but:
  32570. * "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"
  32571. * @returns a pseudo random id
  32572. */
  32573. static RandomId(): string;
  32574. /**
  32575. * Test if the given uri is a base64 string
  32576. * @param uri The uri to test
  32577. * @return True if the uri is a base64 string or false otherwise
  32578. */
  32579. static IsBase64(uri: string): boolean;
  32580. /**
  32581. * Decode the given base64 uri.
  32582. * @param uri The uri to decode
  32583. * @return The decoded base64 data.
  32584. */
  32585. static DecodeBase64(uri: string): ArrayBuffer;
  32586. /**
  32587. * No log
  32588. */
  32589. static readonly NoneLogLevel: number;
  32590. /**
  32591. * Only message logs
  32592. */
  32593. static readonly MessageLogLevel: number;
  32594. /**
  32595. * Only warning logs
  32596. */
  32597. static readonly WarningLogLevel: number;
  32598. /**
  32599. * Only error logs
  32600. */
  32601. static readonly ErrorLogLevel: number;
  32602. /**
  32603. * All logs
  32604. */
  32605. static readonly AllLogLevel: number;
  32606. /**
  32607. * Gets a value indicating the number of loading errors
  32608. * @ignorenaming
  32609. */
  32610. static readonly errorsCount: number;
  32611. /**
  32612. * Callback called when a new log is added
  32613. */
  32614. static OnNewCacheEntry: (entry: string) => void;
  32615. /**
  32616. * Log a message to the console
  32617. * @param message defines the message to log
  32618. */
  32619. static Log(message: string): void;
  32620. /**
  32621. * Write a warning message to the console
  32622. * @param message defines the message to log
  32623. */
  32624. static Warn(message: string): void;
  32625. /**
  32626. * Write an error message to the console
  32627. * @param message defines the message to log
  32628. */
  32629. static Error(message: string): void;
  32630. /**
  32631. * Gets current log cache (list of logs)
  32632. */
  32633. static readonly LogCache: string;
  32634. /**
  32635. * Clears the log cache
  32636. */
  32637. static ClearLogCache(): void;
  32638. /**
  32639. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32640. */
  32641. static LogLevels: number;
  32642. /**
  32643. * Checks if the loaded document was accessed via `file:`-Protocol.
  32644. * @returns boolean
  32645. */
  32646. static IsFileURL(): boolean;
  32647. /**
  32648. * Checks if the window object exists
  32649. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32650. */
  32651. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32652. /**
  32653. * No performance log
  32654. */
  32655. static readonly PerformanceNoneLogLevel: number;
  32656. /**
  32657. * Use user marks to log performance
  32658. */
  32659. static readonly PerformanceUserMarkLogLevel: number;
  32660. /**
  32661. * Log performance to the console
  32662. */
  32663. static readonly PerformanceConsoleLogLevel: number;
  32664. private static _performance;
  32665. /**
  32666. * Sets the current performance log level
  32667. */
  32668. static PerformanceLogLevel: number;
  32669. private static _StartPerformanceCounterDisabled;
  32670. private static _EndPerformanceCounterDisabled;
  32671. private static _StartUserMark;
  32672. private static _EndUserMark;
  32673. private static _StartPerformanceConsole;
  32674. private static _EndPerformanceConsole;
  32675. /**
  32676. * Injects the @see CustomRequestHeaders into the given request
  32677. * @param request the request that should be used for injection
  32678. */
  32679. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  32680. /**
  32681. * Starts a performance counter
  32682. */
  32683. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32684. /**
  32685. * Ends a specific performance coutner
  32686. */
  32687. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32688. /**
  32689. * Gets either window.performance.now() if supported or Date.now() else
  32690. */
  32691. static readonly Now: number;
  32692. /**
  32693. * This method will return the name of the class used to create the instance of the given object.
  32694. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32695. * @param object the object to get the class name from
  32696. * @param isType defines if the object is actually a type
  32697. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32698. */
  32699. static GetClassName(object: any, isType?: boolean): string;
  32700. /**
  32701. * Gets the first element of an array satisfying a given predicate
  32702. * @param array defines the array to browse
  32703. * @param predicate defines the predicate to use
  32704. * @returns null if not found or the element
  32705. */
  32706. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32707. /**
  32708. * This method will return the name of the full name of the class, including its owning module (if any).
  32709. * 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).
  32710. * @param object the object to get the class name from
  32711. * @param isType defines if the object is actually a type
  32712. * @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.
  32713. * @ignorenaming
  32714. */
  32715. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32716. /**
  32717. * Returns a promise that resolves after the given amount of time.
  32718. * @param delay Number of milliseconds to delay
  32719. * @returns Promise that resolves after the given amount of time
  32720. */
  32721. static DelayAsync(delay: number): Promise<void>;
  32722. /**
  32723. * Gets the current gradient from an array of IValueGradient
  32724. * @param ratio defines the current ratio to get
  32725. * @param gradients defines the array of IValueGradient
  32726. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32727. */
  32728. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32729. }
  32730. /**
  32731. * This class is used to track a performance counter which is number based.
  32732. * The user has access to many properties which give statistics of different nature.
  32733. *
  32734. * The implementer can track two kinds of Performance Counter: time and count.
  32735. * 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.
  32736. * 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.
  32737. */
  32738. export class PerfCounter {
  32739. /**
  32740. * Gets or sets a global boolean to turn on and off all the counters
  32741. */
  32742. static Enabled: boolean;
  32743. /**
  32744. * Returns the smallest value ever
  32745. */
  32746. readonly min: number;
  32747. /**
  32748. * Returns the biggest value ever
  32749. */
  32750. readonly max: number;
  32751. /**
  32752. * Returns the average value since the performance counter is running
  32753. */
  32754. readonly average: number;
  32755. /**
  32756. * Returns the average value of the last second the counter was monitored
  32757. */
  32758. readonly lastSecAverage: number;
  32759. /**
  32760. * Returns the current value
  32761. */
  32762. readonly current: number;
  32763. /**
  32764. * Gets the accumulated total
  32765. */
  32766. readonly total: number;
  32767. /**
  32768. * Gets the total value count
  32769. */
  32770. readonly count: number;
  32771. /**
  32772. * Creates a new counter
  32773. */
  32774. constructor();
  32775. /**
  32776. * Call this method to start monitoring a new frame.
  32777. * 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.
  32778. */
  32779. fetchNewFrame(): void;
  32780. /**
  32781. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32782. * @param newCount the count value to add to the monitored count
  32783. * @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.
  32784. */
  32785. addCount(newCount: number, fetchResult: boolean): void;
  32786. /**
  32787. * Start monitoring this performance counter
  32788. */
  32789. beginMonitoring(): void;
  32790. /**
  32791. * Compute the time lapsed since the previous beginMonitoring() call.
  32792. * @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
  32793. */
  32794. endMonitoring(newFrame?: boolean): void;
  32795. private _fetchResult;
  32796. private _startMonitoringTime;
  32797. private _min;
  32798. private _max;
  32799. private _average;
  32800. private _current;
  32801. private _totalValueCount;
  32802. private _totalAccumulated;
  32803. private _lastSecAverage;
  32804. private _lastSecAccumulated;
  32805. private _lastSecTime;
  32806. private _lastSecValueCount;
  32807. }
  32808. /**
  32809. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32810. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32811. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32812. * @param name The name of the class, case should be preserved
  32813. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32814. */
  32815. export function className(name: string, module?: string): (target: Object) => void;
  32816. /**
  32817. * An implementation of a loop for asynchronous functions.
  32818. */
  32819. export class AsyncLoop {
  32820. /**
  32821. * Defines the number of iterations for the loop
  32822. */
  32823. iterations: number;
  32824. /**
  32825. * Defines the current index of the loop.
  32826. */
  32827. index: number;
  32828. private _done;
  32829. private _fn;
  32830. private _successCallback;
  32831. /**
  32832. * Constructor.
  32833. * @param iterations the number of iterations.
  32834. * @param func the function to run each iteration
  32835. * @param successCallback the callback that will be called upon succesful execution
  32836. * @param offset starting offset.
  32837. */
  32838. constructor(
  32839. /**
  32840. * Defines the number of iterations for the loop
  32841. */
  32842. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32843. /**
  32844. * Execute the next iteration. Must be called after the last iteration was finished.
  32845. */
  32846. executeNext(): void;
  32847. /**
  32848. * Break the loop and run the success callback.
  32849. */
  32850. breakLoop(): void;
  32851. /**
  32852. * Create and run an async loop.
  32853. * @param iterations the number of iterations.
  32854. * @param fn the function to run each iteration
  32855. * @param successCallback the callback that will be called upon succesful execution
  32856. * @param offset starting offset.
  32857. * @returns the created async loop object
  32858. */
  32859. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32860. /**
  32861. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32862. * @param iterations total number of iterations
  32863. * @param syncedIterations number of synchronous iterations in each async iteration.
  32864. * @param fn the function to call each iteration.
  32865. * @param callback a success call back that will be called when iterating stops.
  32866. * @param breakFunction a break condition (optional)
  32867. * @param timeout timeout settings for the setTimeout function. default - 0.
  32868. * @returns the created async loop object
  32869. */
  32870. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32871. }
  32872. }
  32873. declare module "babylonjs/Animations/animationGroup" {
  32874. import { Animatable } from "babylonjs/Animations/animatable";
  32875. import { Animation } from "babylonjs/Animations/animation";
  32876. import { Scene, IDisposable } from "babylonjs/scene";
  32877. import { Observable } from "babylonjs/Misc/observable";
  32878. import { Nullable } from "babylonjs/types";
  32879. /**
  32880. * This class defines the direct association between an animation and a target
  32881. */
  32882. export class TargetedAnimation {
  32883. /**
  32884. * Animation to perform
  32885. */
  32886. animation: Animation;
  32887. /**
  32888. * Target to animate
  32889. */
  32890. target: any;
  32891. }
  32892. /**
  32893. * Use this class to create coordinated animations on multiple targets
  32894. */
  32895. export class AnimationGroup implements IDisposable {
  32896. /** The name of the animation group */
  32897. name: string;
  32898. private _scene;
  32899. private _targetedAnimations;
  32900. private _animatables;
  32901. private _from;
  32902. private _to;
  32903. private _isStarted;
  32904. private _isPaused;
  32905. private _speedRatio;
  32906. /**
  32907. * Gets or sets the unique id of the node
  32908. */
  32909. uniqueId: number;
  32910. /**
  32911. * This observable will notify when one animation have ended
  32912. */
  32913. onAnimationEndObservable: Observable<TargetedAnimation>;
  32914. /**
  32915. * Observer raised when one animation loops
  32916. */
  32917. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32918. /**
  32919. * This observable will notify when all animations have ended.
  32920. */
  32921. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32922. /**
  32923. * This observable will notify when all animations have paused.
  32924. */
  32925. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32926. /**
  32927. * This observable will notify when all animations are playing.
  32928. */
  32929. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32930. /**
  32931. * Gets the first frame
  32932. */
  32933. readonly from: number;
  32934. /**
  32935. * Gets the last frame
  32936. */
  32937. readonly to: number;
  32938. /**
  32939. * Define if the animations are started
  32940. */
  32941. readonly isStarted: boolean;
  32942. /**
  32943. * Gets a value indicating that the current group is playing
  32944. */
  32945. readonly isPlaying: boolean;
  32946. /**
  32947. * Gets or sets the speed ratio to use for all animations
  32948. */
  32949. /**
  32950. * Gets or sets the speed ratio to use for all animations
  32951. */
  32952. speedRatio: number;
  32953. /**
  32954. * Gets the targeted animations for this animation group
  32955. */
  32956. readonly targetedAnimations: Array<TargetedAnimation>;
  32957. /**
  32958. * returning the list of animatables controlled by this animation group.
  32959. */
  32960. readonly animatables: Array<Animatable>;
  32961. /**
  32962. * Instantiates a new Animation Group.
  32963. * This helps managing several animations at once.
  32964. * @see http://doc.babylonjs.com/how_to/group
  32965. * @param name Defines the name of the group
  32966. * @param scene Defines the scene the group belongs to
  32967. */
  32968. constructor(
  32969. /** The name of the animation group */
  32970. name: string, scene?: Nullable<Scene>);
  32971. /**
  32972. * Add an animation (with its target) in the group
  32973. * @param animation defines the animation we want to add
  32974. * @param target defines the target of the animation
  32975. * @returns the TargetedAnimation object
  32976. */
  32977. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32978. /**
  32979. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32980. * It can add constant keys at begin or end
  32981. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32982. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32983. * @returns the animation group
  32984. */
  32985. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32986. /**
  32987. * Start all animations on given targets
  32988. * @param loop defines if animations must loop
  32989. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32990. * @param from defines the from key (optional)
  32991. * @param to defines the to key (optional)
  32992. * @returns the current animation group
  32993. */
  32994. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32995. /**
  32996. * Pause all animations
  32997. * @returns the animation group
  32998. */
  32999. pause(): AnimationGroup;
  33000. /**
  33001. * Play all animations to initial state
  33002. * This function will start() the animations if they were not started or will restart() them if they were paused
  33003. * @param loop defines if animations must loop
  33004. * @returns the animation group
  33005. */
  33006. play(loop?: boolean): AnimationGroup;
  33007. /**
  33008. * Reset all animations to initial state
  33009. * @returns the animation group
  33010. */
  33011. reset(): AnimationGroup;
  33012. /**
  33013. * Restart animations from key 0
  33014. * @returns the animation group
  33015. */
  33016. restart(): AnimationGroup;
  33017. /**
  33018. * Stop all animations
  33019. * @returns the animation group
  33020. */
  33021. stop(): AnimationGroup;
  33022. /**
  33023. * Set animation weight for all animatables
  33024. * @param weight defines the weight to use
  33025. * @return the animationGroup
  33026. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33027. */
  33028. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33029. /**
  33030. * Synchronize and normalize all animatables with a source animatable
  33031. * @param root defines the root animatable to synchronize with
  33032. * @return the animationGroup
  33033. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33034. */
  33035. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33036. /**
  33037. * Goes to a specific frame in this animation group
  33038. * @param frame the frame number to go to
  33039. * @return the animationGroup
  33040. */
  33041. goToFrame(frame: number): AnimationGroup;
  33042. /**
  33043. * Dispose all associated resources
  33044. */
  33045. dispose(): void;
  33046. private _checkAnimationGroupEnded;
  33047. /**
  33048. * Returns a new AnimationGroup object parsed from the source provided.
  33049. * @param parsedAnimationGroup defines the source
  33050. * @param scene defines the scene that will receive the animationGroup
  33051. * @returns a new AnimationGroup
  33052. */
  33053. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33054. /**
  33055. * Returns the string "AnimationGroup"
  33056. * @returns "AnimationGroup"
  33057. */
  33058. getClassName(): string;
  33059. /**
  33060. * Creates a detailled string about the object
  33061. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33062. * @returns a string representing the object
  33063. */
  33064. toString(fullDetails?: boolean): string;
  33065. }
  33066. }
  33067. declare module "babylonjs/Collisions/collisionCoordinator" {
  33068. import { Nullable } from "babylonjs/types";
  33069. import { Scene } from "babylonjs/scene";
  33070. import { Vector3 } from "babylonjs/Maths/math";
  33071. import { Collider } from "babylonjs/Collisions/collider";
  33072. import { Geometry } from "babylonjs/Meshes/geometry";
  33073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33074. /** @hidden */
  33075. export interface ICollisionCoordinator {
  33076. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33077. init(scene: Scene): void;
  33078. destroy(): void;
  33079. onMeshAdded(mesh: AbstractMesh): void;
  33080. onMeshUpdated(mesh: AbstractMesh): void;
  33081. onMeshRemoved(mesh: AbstractMesh): void;
  33082. onGeometryAdded(geometry: Geometry): void;
  33083. onGeometryUpdated(geometry: Geometry): void;
  33084. onGeometryDeleted(geometry: Geometry): void;
  33085. }
  33086. /** @hidden */
  33087. export class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  33088. private _scene;
  33089. private _scaledPosition;
  33090. private _scaledVelocity;
  33091. private _finalPosition;
  33092. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33093. init(scene: Scene): void;
  33094. destroy(): void;
  33095. onMeshAdded(mesh: AbstractMesh): void;
  33096. onMeshUpdated(mesh: AbstractMesh): void;
  33097. onMeshRemoved(mesh: AbstractMesh): void;
  33098. onGeometryAdded(geometry: Geometry): void;
  33099. onGeometryUpdated(geometry: Geometry): void;
  33100. onGeometryDeleted(geometry: Geometry): void;
  33101. private _collideWithWorld;
  33102. }
  33103. }
  33104. declare module "babylonjs/scene" {
  33105. import { Nullable } from "babylonjs/types";
  33106. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  33107. import { Observable } from "babylonjs/Misc/observable";
  33108. import { SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33109. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  33110. import { Geometry } from "babylonjs/Meshes/geometry";
  33111. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33112. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33114. import { Mesh } from "babylonjs/Meshes/mesh";
  33115. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33116. import { Bone } from "babylonjs/Bones/bone";
  33117. import { Skeleton } from "babylonjs/Bones/skeleton";
  33118. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33119. import { Camera } from "babylonjs/Cameras/camera";
  33120. import { AbstractScene } from "babylonjs/abstractScene";
  33121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33122. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33123. import { Material } from "babylonjs/Materials/material";
  33124. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33125. import { Effect } from "babylonjs/Materials/effect";
  33126. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33127. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33128. import { Animation } from "babylonjs/Animations/animation";
  33129. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33130. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33131. import { Animatable } from "babylonjs/Animations/animatable";
  33132. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33133. import { Light } from "babylonjs/Lights/light";
  33134. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33135. import { Collider } from "babylonjs/Collisions/collider";
  33136. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33137. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33138. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33139. import { ActionManager } from "babylonjs/Actions/actionManager";
  33140. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33141. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33142. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33143. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33144. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  33145. import { Engine } from "babylonjs/Engines/engine";
  33146. import { Ray } from "babylonjs/Culling/ray";
  33147. import { Node } from "babylonjs/node";
  33148. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33149. /**
  33150. * Define an interface for all classes that will hold resources
  33151. */
  33152. export interface IDisposable {
  33153. /**
  33154. * Releases all held resources
  33155. */
  33156. dispose(): void;
  33157. }
  33158. /** Interface defining initialization parameters for Scene class */
  33159. export interface SceneOptions {
  33160. /**
  33161. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33162. * It will improve performance when the number of geometries becomes important.
  33163. */
  33164. useGeometryUniqueIdsMap?: boolean;
  33165. /**
  33166. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33167. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33168. */
  33169. useMaterialMeshMap?: boolean;
  33170. /**
  33171. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33172. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33173. */
  33174. useClonedMeshhMap?: boolean;
  33175. }
  33176. /**
  33177. * Represents a scene to be rendered by the engine.
  33178. * @see http://doc.babylonjs.com/features/scene
  33179. */
  33180. export class Scene extends AbstractScene implements IAnimatable {
  33181. private static _uniqueIdCounter;
  33182. /** The fog is deactivated */
  33183. static readonly FOGMODE_NONE: number;
  33184. /** The fog density is following an exponential function */
  33185. static readonly FOGMODE_EXP: number;
  33186. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33187. static readonly FOGMODE_EXP2: number;
  33188. /** The fog density is following a linear function. */
  33189. static readonly FOGMODE_LINEAR: number;
  33190. /**
  33191. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33192. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33193. */
  33194. static MinDeltaTime: number;
  33195. /**
  33196. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33197. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33198. */
  33199. static MaxDeltaTime: number;
  33200. /**
  33201. * Factory used to create the default material.
  33202. * @param name The name of the material to create
  33203. * @param scene The scene to create the material for
  33204. * @returns The default material
  33205. */
  33206. static DefaultMaterialFactory(scene: Scene): Material;
  33207. /** @hidden */
  33208. readonly _isScene: boolean;
  33209. /**
  33210. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33211. */
  33212. autoClear: boolean;
  33213. /**
  33214. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33215. */
  33216. autoClearDepthAndStencil: boolean;
  33217. /**
  33218. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33219. */
  33220. clearColor: Color4;
  33221. /**
  33222. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33223. */
  33224. ambientColor: Color3;
  33225. /** @hidden */
  33226. _environmentBRDFTexture: BaseTexture;
  33227. /** @hidden */
  33228. protected _environmentTexture: Nullable<BaseTexture>;
  33229. /**
  33230. * Texture used in all pbr material as the reflection texture.
  33231. * As in the majority of the scene they are the same (exception for multi room and so on),
  33232. * this is easier to reference from here than from all the materials.
  33233. */
  33234. /**
  33235. * Texture used in all pbr material as the reflection texture.
  33236. * As in the majority of the scene they are the same (exception for multi room and so on),
  33237. * this is easier to set here than in all the materials.
  33238. */
  33239. environmentTexture: Nullable<BaseTexture>;
  33240. /** @hidden */
  33241. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33242. /**
  33243. * Default image processing configuration used either in the rendering
  33244. * Forward main pass or through the imageProcessingPostProcess if present.
  33245. * As in the majority of the scene they are the same (exception for multi camera),
  33246. * this is easier to reference from here than from all the materials and post process.
  33247. *
  33248. * No setter as we it is a shared configuration, you can set the values instead.
  33249. */
  33250. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33251. private _forceWireframe;
  33252. /**
  33253. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33254. */
  33255. forceWireframe: boolean;
  33256. private _forcePointsCloud;
  33257. /**
  33258. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33259. */
  33260. forcePointsCloud: boolean;
  33261. /**
  33262. * Gets or sets the active clipplane 1
  33263. */
  33264. clipPlane: Nullable<Plane>;
  33265. /**
  33266. * Gets or sets the active clipplane 2
  33267. */
  33268. clipPlane2: Nullable<Plane>;
  33269. /**
  33270. * Gets or sets the active clipplane 3
  33271. */
  33272. clipPlane3: Nullable<Plane>;
  33273. /**
  33274. * Gets or sets the active clipplane 4
  33275. */
  33276. clipPlane4: Nullable<Plane>;
  33277. /**
  33278. * Gets or sets a boolean indicating if animations are enabled
  33279. */
  33280. animationsEnabled: boolean;
  33281. private _animationPropertiesOverride;
  33282. /**
  33283. * Gets or sets the animation properties override
  33284. */
  33285. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33286. /**
  33287. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33288. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33289. */
  33290. useConstantAnimationDeltaTime: boolean;
  33291. /**
  33292. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33293. * Please note that it requires to run a ray cast through the scene on every frame
  33294. */
  33295. constantlyUpdateMeshUnderPointer: boolean;
  33296. /**
  33297. * Defines the HTML cursor to use when hovering over interactive elements
  33298. */
  33299. hoverCursor: string;
  33300. /**
  33301. * Defines the HTML default cursor to use (empty by default)
  33302. */
  33303. defaultCursor: string;
  33304. /**
  33305. * This is used to call preventDefault() on pointer down
  33306. * in order to block unwanted artifacts like system double clicks
  33307. */
  33308. preventDefaultOnPointerDown: boolean;
  33309. /**
  33310. * This is used to call preventDefault() on pointer up
  33311. * in order to block unwanted artifacts like system double clicks
  33312. */
  33313. preventDefaultOnPointerUp: boolean;
  33314. /**
  33315. * Gets or sets user defined metadata
  33316. */
  33317. metadata: any;
  33318. /**
  33319. * For internal use only. Please do not use.
  33320. */
  33321. reservedDataStore: any;
  33322. /**
  33323. * Gets the name of the plugin used to load this scene (null by default)
  33324. */
  33325. loadingPluginName: string;
  33326. /**
  33327. * Use this array to add regular expressions used to disable offline support for specific urls
  33328. */
  33329. disableOfflineSupportExceptionRules: RegExp[];
  33330. /**
  33331. * An event triggered when the scene is disposed.
  33332. */
  33333. onDisposeObservable: Observable<Scene>;
  33334. private _onDisposeObserver;
  33335. /** Sets a function to be executed when this scene is disposed. */
  33336. onDispose: () => void;
  33337. /**
  33338. * An event triggered before rendering the scene (right after animations and physics)
  33339. */
  33340. onBeforeRenderObservable: Observable<Scene>;
  33341. private _onBeforeRenderObserver;
  33342. /** Sets a function to be executed before rendering this scene */
  33343. beforeRender: Nullable<() => void>;
  33344. /**
  33345. * An event triggered after rendering the scene
  33346. */
  33347. onAfterRenderObservable: Observable<Scene>;
  33348. private _onAfterRenderObserver;
  33349. /** Sets a function to be executed after rendering this scene */
  33350. afterRender: Nullable<() => void>;
  33351. /**
  33352. * An event triggered before animating the scene
  33353. */
  33354. onBeforeAnimationsObservable: Observable<Scene>;
  33355. /**
  33356. * An event triggered after animations processing
  33357. */
  33358. onAfterAnimationsObservable: Observable<Scene>;
  33359. /**
  33360. * An event triggered before draw calls are ready to be sent
  33361. */
  33362. onBeforeDrawPhaseObservable: Observable<Scene>;
  33363. /**
  33364. * An event triggered after draw calls have been sent
  33365. */
  33366. onAfterDrawPhaseObservable: Observable<Scene>;
  33367. /**
  33368. * An event triggered when the scene is ready
  33369. */
  33370. onReadyObservable: Observable<Scene>;
  33371. /**
  33372. * An event triggered before rendering a camera
  33373. */
  33374. onBeforeCameraRenderObservable: Observable<Camera>;
  33375. private _onBeforeCameraRenderObserver;
  33376. /** Sets a function to be executed before rendering a camera*/
  33377. beforeCameraRender: () => void;
  33378. /**
  33379. * An event triggered after rendering a camera
  33380. */
  33381. onAfterCameraRenderObservable: Observable<Camera>;
  33382. private _onAfterCameraRenderObserver;
  33383. /** Sets a function to be executed after rendering a camera*/
  33384. afterCameraRender: () => void;
  33385. /**
  33386. * An event triggered when active meshes evaluation is about to start
  33387. */
  33388. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33389. /**
  33390. * An event triggered when active meshes evaluation is done
  33391. */
  33392. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33393. /**
  33394. * An event triggered when particles rendering is about to start
  33395. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33396. */
  33397. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33398. /**
  33399. * An event triggered when particles rendering is done
  33400. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33401. */
  33402. onAfterParticlesRenderingObservable: Observable<Scene>;
  33403. /**
  33404. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33405. */
  33406. onDataLoadedObservable: Observable<Scene>;
  33407. /**
  33408. * An event triggered when a camera is created
  33409. */
  33410. onNewCameraAddedObservable: Observable<Camera>;
  33411. /**
  33412. * An event triggered when a camera is removed
  33413. */
  33414. onCameraRemovedObservable: Observable<Camera>;
  33415. /**
  33416. * An event triggered when a light is created
  33417. */
  33418. onNewLightAddedObservable: Observable<Light>;
  33419. /**
  33420. * An event triggered when a light is removed
  33421. */
  33422. onLightRemovedObservable: Observable<Light>;
  33423. /**
  33424. * An event triggered when a geometry is created
  33425. */
  33426. onNewGeometryAddedObservable: Observable<Geometry>;
  33427. /**
  33428. * An event triggered when a geometry is removed
  33429. */
  33430. onGeometryRemovedObservable: Observable<Geometry>;
  33431. /**
  33432. * An event triggered when a transform node is created
  33433. */
  33434. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33435. /**
  33436. * An event triggered when a transform node is removed
  33437. */
  33438. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33439. /**
  33440. * An event triggered when a mesh is created
  33441. */
  33442. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33443. /**
  33444. * An event triggered when a mesh is removed
  33445. */
  33446. onMeshRemovedObservable: Observable<AbstractMesh>;
  33447. /**
  33448. * An event triggered when a material is created
  33449. */
  33450. onNewMaterialAddedObservable: Observable<Material>;
  33451. /**
  33452. * An event triggered when a material is removed
  33453. */
  33454. onMaterialRemovedObservable: Observable<Material>;
  33455. /**
  33456. * An event triggered when a texture is created
  33457. */
  33458. onNewTextureAddedObservable: Observable<BaseTexture>;
  33459. /**
  33460. * An event triggered when a texture is removed
  33461. */
  33462. onTextureRemovedObservable: Observable<BaseTexture>;
  33463. /**
  33464. * An event triggered when render targets are about to be rendered
  33465. * Can happen multiple times per frame.
  33466. */
  33467. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33468. /**
  33469. * An event triggered when render targets were rendered.
  33470. * Can happen multiple times per frame.
  33471. */
  33472. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33473. /**
  33474. * An event triggered before calculating deterministic simulation step
  33475. */
  33476. onBeforeStepObservable: Observable<Scene>;
  33477. /**
  33478. * An event triggered after calculating deterministic simulation step
  33479. */
  33480. onAfterStepObservable: Observable<Scene>;
  33481. /**
  33482. * An event triggered when the activeCamera property is updated
  33483. */
  33484. onActiveCameraChanged: Observable<Scene>;
  33485. /**
  33486. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33487. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33488. * 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)
  33489. */
  33490. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33491. /**
  33492. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33493. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33494. * 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)
  33495. */
  33496. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33497. /**
  33498. * This Observable will when a mesh has been imported into the scene.
  33499. */
  33500. onMeshImportedObservable: Observable<AbstractMesh>;
  33501. private _registeredForLateAnimationBindings;
  33502. /**
  33503. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33504. */
  33505. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33506. /**
  33507. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33508. */
  33509. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33510. /**
  33511. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33512. */
  33513. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33514. private _onPointerMove;
  33515. private _onPointerDown;
  33516. private _onPointerUp;
  33517. /** Callback called when a pointer move is detected */
  33518. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33519. /** Callback called when a pointer down is detected */
  33520. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33521. /** Callback called when a pointer up is detected */
  33522. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33523. /** Callback called when a pointer pick is detected */
  33524. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33525. /**
  33526. * 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).
  33527. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33528. */
  33529. onPrePointerObservable: Observable<PointerInfoPre>;
  33530. /**
  33531. * Observable event triggered each time an input event is received from the rendering canvas
  33532. */
  33533. onPointerObservable: Observable<PointerInfo>;
  33534. /**
  33535. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33536. */
  33537. readonly unTranslatedPointer: Vector2;
  33538. /** The distance in pixel that you have to move to prevent some events */
  33539. static DragMovementThreshold: number;
  33540. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33541. static LongPressDelay: number;
  33542. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33543. static DoubleClickDelay: number;
  33544. /** If you need to check double click without raising a single click at first click, enable this flag */
  33545. static ExclusiveDoubleClickMode: boolean;
  33546. private _initClickEvent;
  33547. private _initActionManager;
  33548. private _delayedSimpleClick;
  33549. private _delayedSimpleClickTimeout;
  33550. private _previousDelayedSimpleClickTimeout;
  33551. private _meshPickProceed;
  33552. private _previousButtonPressed;
  33553. private _currentPickResult;
  33554. private _previousPickResult;
  33555. private _totalPointersPressed;
  33556. private _doubleClickOccured;
  33557. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33558. cameraToUseForPointers: Nullable<Camera>;
  33559. private _pointerX;
  33560. private _pointerY;
  33561. private _unTranslatedPointerX;
  33562. private _unTranslatedPointerY;
  33563. private _startingPointerPosition;
  33564. private _previousStartingPointerPosition;
  33565. private _startingPointerTime;
  33566. private _previousStartingPointerTime;
  33567. private _pointerCaptures;
  33568. private _timeAccumulator;
  33569. private _currentStepId;
  33570. private _currentInternalStep;
  33571. /** @hidden */
  33572. _mirroredCameraPosition: Nullable<Vector3>;
  33573. /**
  33574. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33575. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33576. */
  33577. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33578. /**
  33579. * Observable event triggered each time an keyboard event is received from the hosting window
  33580. */
  33581. onKeyboardObservable: Observable<KeyboardInfo>;
  33582. private _onKeyDown;
  33583. private _onKeyUp;
  33584. private _onCanvasFocusObserver;
  33585. private _onCanvasBlurObserver;
  33586. private _useRightHandedSystem;
  33587. /**
  33588. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33589. */
  33590. useRightHandedSystem: boolean;
  33591. /**
  33592. * Sets the step Id used by deterministic lock step
  33593. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33594. * @param newStepId defines the step Id
  33595. */
  33596. setStepId(newStepId: number): void;
  33597. /**
  33598. * Gets the step Id used by deterministic lock step
  33599. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33600. * @returns the step Id
  33601. */
  33602. getStepId(): number;
  33603. /**
  33604. * Gets the internal step used by deterministic lock step
  33605. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33606. * @returns the internal step
  33607. */
  33608. getInternalStep(): number;
  33609. private _fogEnabled;
  33610. /**
  33611. * Gets or sets a boolean indicating if fog is enabled on this scene
  33612. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33613. * (Default is true)
  33614. */
  33615. fogEnabled: boolean;
  33616. private _fogMode;
  33617. /**
  33618. * Gets or sets the fog mode to use
  33619. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33620. * | mode | value |
  33621. * | --- | --- |
  33622. * | FOGMODE_NONE | 0 |
  33623. * | FOGMODE_EXP | 1 |
  33624. * | FOGMODE_EXP2 | 2 |
  33625. * | FOGMODE_LINEAR | 3 |
  33626. */
  33627. fogMode: number;
  33628. /**
  33629. * Gets or sets the fog color to use
  33630. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33631. * (Default is Color3(0.2, 0.2, 0.3))
  33632. */
  33633. fogColor: Color3;
  33634. /**
  33635. * Gets or sets the fog density to use
  33636. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33637. * (Default is 0.1)
  33638. */
  33639. fogDensity: number;
  33640. /**
  33641. * Gets or sets the fog start distance to use
  33642. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33643. * (Default is 0)
  33644. */
  33645. fogStart: number;
  33646. /**
  33647. * Gets or sets the fog end distance to use
  33648. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33649. * (Default is 1000)
  33650. */
  33651. fogEnd: number;
  33652. private _shadowsEnabled;
  33653. /**
  33654. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33655. */
  33656. shadowsEnabled: boolean;
  33657. private _lightsEnabled;
  33658. /**
  33659. * Gets or sets a boolean indicating if lights are enabled on this scene
  33660. */
  33661. lightsEnabled: boolean;
  33662. /** All of the active cameras added to this scene. */
  33663. activeCameras: Camera[];
  33664. private _activeCamera;
  33665. /** Gets or sets the current active camera */
  33666. activeCamera: Nullable<Camera>;
  33667. private _defaultMaterial;
  33668. /** The default material used on meshes when no material is affected */
  33669. /** The default material used on meshes when no material is affected */
  33670. defaultMaterial: Material;
  33671. private _texturesEnabled;
  33672. /**
  33673. * Gets or sets a boolean indicating if textures are enabled on this scene
  33674. */
  33675. texturesEnabled: boolean;
  33676. /**
  33677. * Gets or sets a boolean indicating if particles are enabled on this scene
  33678. */
  33679. particlesEnabled: boolean;
  33680. /**
  33681. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33682. */
  33683. spritesEnabled: boolean;
  33684. private _skeletonsEnabled;
  33685. /**
  33686. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33687. */
  33688. skeletonsEnabled: boolean;
  33689. /**
  33690. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33691. */
  33692. lensFlaresEnabled: boolean;
  33693. /**
  33694. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33695. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33696. */
  33697. collisionsEnabled: boolean;
  33698. /** @hidden */
  33699. collisionCoordinator: ICollisionCoordinator;
  33700. /**
  33701. * Defines the gravity applied to this scene (used only for collisions)
  33702. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33703. */
  33704. gravity: Vector3;
  33705. /**
  33706. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33707. */
  33708. postProcessesEnabled: boolean;
  33709. /**
  33710. * The list of postprocesses added to the scene
  33711. */
  33712. postProcesses: PostProcess[];
  33713. /**
  33714. * Gets the current postprocess manager
  33715. */
  33716. postProcessManager: PostProcessManager;
  33717. /**
  33718. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33719. */
  33720. renderTargetsEnabled: boolean;
  33721. /**
  33722. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33723. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33724. */
  33725. dumpNextRenderTargets: boolean;
  33726. /**
  33727. * The list of user defined render targets added to the scene
  33728. */
  33729. customRenderTargets: RenderTargetTexture[];
  33730. /**
  33731. * Defines if texture loading must be delayed
  33732. * If true, textures will only be loaded when they need to be rendered
  33733. */
  33734. useDelayedTextureLoading: boolean;
  33735. /**
  33736. * Gets the list of meshes imported to the scene through SceneLoader
  33737. */
  33738. importedMeshesFiles: String[];
  33739. /**
  33740. * Gets or sets a boolean indicating if probes are enabled on this scene
  33741. */
  33742. probesEnabled: boolean;
  33743. /**
  33744. * Gets or sets the current offline provider to use to store scene data
  33745. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33746. */
  33747. offlineProvider: IOfflineProvider;
  33748. /**
  33749. * Gets or sets the action manager associated with the scene
  33750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33751. */
  33752. actionManager: ActionManager;
  33753. private _meshesForIntersections;
  33754. /**
  33755. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33756. */
  33757. proceduralTexturesEnabled: boolean;
  33758. private _engine;
  33759. private _totalVertices;
  33760. /** @hidden */
  33761. _activeIndices: PerfCounter;
  33762. /** @hidden */
  33763. _activeParticles: PerfCounter;
  33764. /** @hidden */
  33765. _activeBones: PerfCounter;
  33766. private _animationRatio;
  33767. private _animationTimeLast;
  33768. private _animationTime;
  33769. /**
  33770. * Gets or sets a general scale for animation speed
  33771. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33772. */
  33773. animationTimeScale: number;
  33774. /** @hidden */
  33775. _cachedMaterial: Nullable<Material>;
  33776. /** @hidden */
  33777. _cachedEffect: Nullable<Effect>;
  33778. /** @hidden */
  33779. _cachedVisibility: Nullable<number>;
  33780. private _renderId;
  33781. private _frameId;
  33782. private _executeWhenReadyTimeoutId;
  33783. private _intermediateRendering;
  33784. private _viewUpdateFlag;
  33785. private _projectionUpdateFlag;
  33786. private _alternateViewUpdateFlag;
  33787. private _alternateProjectionUpdateFlag;
  33788. /** @hidden */
  33789. _toBeDisposed: Nullable<IDisposable>[];
  33790. private _activeRequests;
  33791. private _pendingData;
  33792. private _isDisposed;
  33793. /**
  33794. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33795. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33796. */
  33797. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33798. private _activeMeshes;
  33799. private _processedMaterials;
  33800. private _renderTargets;
  33801. /** @hidden */
  33802. _activeParticleSystems: SmartArray<IParticleSystem>;
  33803. private _activeSkeletons;
  33804. private _softwareSkinnedMeshes;
  33805. private _renderingManager;
  33806. /** @hidden */
  33807. _activeAnimatables: Animatable[];
  33808. private _transformMatrix;
  33809. private _sceneUbo;
  33810. private _alternateSceneUbo;
  33811. private _pickWithRayInverseMatrix;
  33812. private _viewMatrix;
  33813. private _projectionMatrix;
  33814. private _alternateViewMatrix;
  33815. private _alternateProjectionMatrix;
  33816. private _alternateTransformMatrix;
  33817. private _useAlternateCameraConfiguration;
  33818. private _alternateRendering;
  33819. private _wheelEventName;
  33820. /** @hidden */
  33821. _forcedViewPosition: Nullable<Vector3>;
  33822. /** @hidden */
  33823. readonly _isAlternateRenderingEnabled: boolean;
  33824. private _frustumPlanes;
  33825. /**
  33826. * Gets the list of frustum planes (built from the active camera)
  33827. */
  33828. readonly frustumPlanes: Plane[];
  33829. /**
  33830. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33831. * This is useful if there are more lights that the maximum simulteanous authorized
  33832. */
  33833. requireLightSorting: boolean;
  33834. /** @hidden */
  33835. readonly useMaterialMeshMap: boolean;
  33836. /** @hidden */
  33837. readonly useClonedMeshhMap: boolean;
  33838. private _pointerOverMesh;
  33839. private _pickedDownMesh;
  33840. private _pickedUpMesh;
  33841. private _externalData;
  33842. private _uid;
  33843. /**
  33844. * @hidden
  33845. * Backing store of defined scene components.
  33846. */
  33847. _components: ISceneComponent[];
  33848. /**
  33849. * @hidden
  33850. * Backing store of defined scene components.
  33851. */
  33852. _serializableComponents: ISceneSerializableComponent[];
  33853. /**
  33854. * List of components to register on the next registration step.
  33855. */
  33856. private _transientComponents;
  33857. /**
  33858. * Registers the transient components if needed.
  33859. */
  33860. private _registerTransientComponents;
  33861. /**
  33862. * @hidden
  33863. * Add a component to the scene.
  33864. * Note that the ccomponent could be registered on th next frame if this is called after
  33865. * the register component stage.
  33866. * @param component Defines the component to add to the scene
  33867. */
  33868. _addComponent(component: ISceneComponent): void;
  33869. /**
  33870. * @hidden
  33871. * Gets a component from the scene.
  33872. * @param name defines the name of the component to retrieve
  33873. * @returns the component or null if not present
  33874. */
  33875. _getComponent(name: string): Nullable<ISceneComponent>;
  33876. /**
  33877. * @hidden
  33878. * Defines the actions happening before camera updates.
  33879. */
  33880. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33881. /**
  33882. * @hidden
  33883. * Defines the actions happening before clear the canvas.
  33884. */
  33885. _beforeClearStage: Stage<SimpleStageAction>;
  33886. /**
  33887. * @hidden
  33888. * Defines the actions when collecting render targets for the frame.
  33889. */
  33890. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33891. /**
  33892. * @hidden
  33893. * Defines the actions happening for one camera in the frame.
  33894. */
  33895. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33896. /**
  33897. * @hidden
  33898. * Defines the actions happening during the per mesh ready checks.
  33899. */
  33900. _isReadyForMeshStage: Stage<MeshStageAction>;
  33901. /**
  33902. * @hidden
  33903. * Defines the actions happening before evaluate active mesh checks.
  33904. */
  33905. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33906. /**
  33907. * @hidden
  33908. * Defines the actions happening during the evaluate sub mesh checks.
  33909. */
  33910. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33911. /**
  33912. * @hidden
  33913. * Defines the actions happening during the active mesh stage.
  33914. */
  33915. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33916. /**
  33917. * @hidden
  33918. * Defines the actions happening during the per camera render target step.
  33919. */
  33920. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33921. /**
  33922. * @hidden
  33923. * Defines the actions happening just before the active camera is drawing.
  33924. */
  33925. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33926. /**
  33927. * @hidden
  33928. * Defines the actions happening just before a render target is drawing.
  33929. */
  33930. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33931. /**
  33932. * @hidden
  33933. * Defines the actions happening just before a rendering group is drawing.
  33934. */
  33935. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33936. /**
  33937. * @hidden
  33938. * Defines the actions happening just before a mesh is drawing.
  33939. */
  33940. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33941. /**
  33942. * @hidden
  33943. * Defines the actions happening just after a mesh has been drawn.
  33944. */
  33945. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33946. /**
  33947. * @hidden
  33948. * Defines the actions happening just after a rendering group has been drawn.
  33949. */
  33950. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33951. /**
  33952. * @hidden
  33953. * Defines the actions happening just after the active camera has been drawn.
  33954. */
  33955. _afterCameraDrawStage: Stage<CameraStageAction>;
  33956. /**
  33957. * @hidden
  33958. * Defines the actions happening just after a render target has been drawn.
  33959. */
  33960. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33961. /**
  33962. * @hidden
  33963. * Defines the actions happening just after rendering all cameras and computing intersections.
  33964. */
  33965. _afterRenderStage: Stage<SimpleStageAction>;
  33966. /**
  33967. * @hidden
  33968. * Defines the actions happening when a pointer move event happens.
  33969. */
  33970. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33971. /**
  33972. * @hidden
  33973. * Defines the actions happening when a pointer down event happens.
  33974. */
  33975. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33976. /**
  33977. * @hidden
  33978. * Defines the actions happening when a pointer up event happens.
  33979. */
  33980. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33981. /**
  33982. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33983. */
  33984. private geometriesByUniqueId;
  33985. /**
  33986. * Creates a new Scene
  33987. * @param engine defines the engine to use to render this scene
  33988. */
  33989. constructor(engine: Engine, options?: SceneOptions);
  33990. private _defaultMeshCandidates;
  33991. /**
  33992. * @hidden
  33993. */
  33994. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33995. private _defaultSubMeshCandidates;
  33996. /**
  33997. * @hidden
  33998. */
  33999. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34000. /**
  34001. * Sets the default candidate providers for the scene.
  34002. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34003. * and getCollidingSubMeshCandidates to their default function
  34004. */
  34005. setDefaultCandidateProviders(): void;
  34006. /**
  34007. * Gets a boolean indicating if collisions are processed on a web worker
  34008. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  34009. */
  34010. workerCollisions: boolean;
  34011. /**
  34012. * Gets the mesh that is currently under the pointer
  34013. */
  34014. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34015. /**
  34016. * Gets or sets the current on-screen X position of the pointer
  34017. */
  34018. pointerX: number;
  34019. /**
  34020. * Gets or sets the current on-screen Y position of the pointer
  34021. */
  34022. pointerY: number;
  34023. /**
  34024. * Gets the cached material (ie. the latest rendered one)
  34025. * @returns the cached material
  34026. */
  34027. getCachedMaterial(): Nullable<Material>;
  34028. /**
  34029. * Gets the cached effect (ie. the latest rendered one)
  34030. * @returns the cached effect
  34031. */
  34032. getCachedEffect(): Nullable<Effect>;
  34033. /**
  34034. * Gets the cached visibility state (ie. the latest rendered one)
  34035. * @returns the cached visibility state
  34036. */
  34037. getCachedVisibility(): Nullable<number>;
  34038. /**
  34039. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34040. * @param material defines the current material
  34041. * @param effect defines the current effect
  34042. * @param visibility defines the current visibility state
  34043. * @returns true if one parameter is not cached
  34044. */
  34045. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34046. /**
  34047. * Gets the engine associated with the scene
  34048. * @returns an Engine
  34049. */
  34050. getEngine(): Engine;
  34051. /**
  34052. * Gets the total number of vertices rendered per frame
  34053. * @returns the total number of vertices rendered per frame
  34054. */
  34055. getTotalVertices(): number;
  34056. /**
  34057. * Gets the performance counter for total vertices
  34058. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34059. */
  34060. readonly totalVerticesPerfCounter: PerfCounter;
  34061. /**
  34062. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34063. * @returns the total number of active indices rendered per frame
  34064. */
  34065. getActiveIndices(): number;
  34066. /**
  34067. * Gets the performance counter for active indices
  34068. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34069. */
  34070. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34071. /**
  34072. * Gets the total number of active particles rendered per frame
  34073. * @returns the total number of active particles rendered per frame
  34074. */
  34075. getActiveParticles(): number;
  34076. /**
  34077. * Gets the performance counter for active particles
  34078. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34079. */
  34080. readonly activeParticlesPerfCounter: PerfCounter;
  34081. /**
  34082. * Gets the total number of active bones rendered per frame
  34083. * @returns the total number of active bones rendered per frame
  34084. */
  34085. getActiveBones(): number;
  34086. /**
  34087. * Gets the performance counter for active bones
  34088. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34089. */
  34090. readonly activeBonesPerfCounter: PerfCounter;
  34091. /**
  34092. * Gets the array of active meshes
  34093. * @returns an array of AbstractMesh
  34094. */
  34095. getActiveMeshes(): SmartArray<AbstractMesh>;
  34096. /**
  34097. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34098. * @returns a number
  34099. */
  34100. getAnimationRatio(): number;
  34101. /**
  34102. * Gets an unique Id for the current render phase
  34103. * @returns a number
  34104. */
  34105. getRenderId(): number;
  34106. /**
  34107. * Gets an unique Id for the current frame
  34108. * @returns a number
  34109. */
  34110. getFrameId(): number;
  34111. /** Call this function if you want to manually increment the render Id*/
  34112. incrementRenderId(): void;
  34113. private _updatePointerPosition;
  34114. private _createUbo;
  34115. private _createAlternateUbo;
  34116. private _setRayOnPointerInfo;
  34117. /**
  34118. * Use this method to simulate a pointer move on a mesh
  34119. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34120. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34121. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34122. * @returns the current scene
  34123. */
  34124. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34125. private _processPointerMove;
  34126. private _checkPrePointerObservable;
  34127. /**
  34128. * Use this method to simulate a pointer down on a mesh
  34129. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34130. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34131. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34132. * @returns the current scene
  34133. */
  34134. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34135. private _processPointerDown;
  34136. /**
  34137. * Use this method to simulate a pointer up on a mesh
  34138. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34139. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34140. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34141. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34142. * @returns the current scene
  34143. */
  34144. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34145. private _processPointerUp;
  34146. /**
  34147. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34148. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34149. * @returns true if the pointer was captured
  34150. */
  34151. isPointerCaptured(pointerId?: number): boolean;
  34152. /** @hidden */
  34153. _isPointerSwiping(): boolean;
  34154. /**
  34155. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34156. * @param attachUp defines if you want to attach events to pointerup
  34157. * @param attachDown defines if you want to attach events to pointerdown
  34158. * @param attachMove defines if you want to attach events to pointermove
  34159. */
  34160. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34161. /** Detaches all event handlers*/
  34162. detachControl(): void;
  34163. /**
  34164. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34165. * Delay loaded resources are not taking in account
  34166. * @return true if all required resources are ready
  34167. */
  34168. isReady(): boolean;
  34169. /** Resets all cached information relative to material (including effect and visibility) */
  34170. resetCachedMaterial(): void;
  34171. /**
  34172. * Registers a function to be called before every frame render
  34173. * @param func defines the function to register
  34174. */
  34175. registerBeforeRender(func: () => void): void;
  34176. /**
  34177. * Unregisters a function called before every frame render
  34178. * @param func defines the function to unregister
  34179. */
  34180. unregisterBeforeRender(func: () => void): void;
  34181. /**
  34182. * Registers a function to be called after every frame render
  34183. * @param func defines the function to register
  34184. */
  34185. registerAfterRender(func: () => void): void;
  34186. /**
  34187. * Unregisters a function called after every frame render
  34188. * @param func defines the function to unregister
  34189. */
  34190. unregisterAfterRender(func: () => void): void;
  34191. private _executeOnceBeforeRender;
  34192. /**
  34193. * The provided function will run before render once and will be disposed afterwards.
  34194. * A timeout delay can be provided so that the function will be executed in N ms.
  34195. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34196. * @param func The function to be executed.
  34197. * @param timeout optional delay in ms
  34198. */
  34199. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34200. /** @hidden */
  34201. _addPendingData(data: any): void;
  34202. /** @hidden */
  34203. _removePendingData(data: any): void;
  34204. /**
  34205. * Returns the number of items waiting to be loaded
  34206. * @returns the number of items waiting to be loaded
  34207. */
  34208. getWaitingItemsCount(): number;
  34209. /**
  34210. * Returns a boolean indicating if the scene is still loading data
  34211. */
  34212. readonly isLoading: boolean;
  34213. /**
  34214. * Registers a function to be executed when the scene is ready
  34215. * @param {Function} func - the function to be executed
  34216. */
  34217. executeWhenReady(func: () => void): void;
  34218. /**
  34219. * Returns a promise that resolves when the scene is ready
  34220. * @returns A promise that resolves when the scene is ready
  34221. */
  34222. whenReadyAsync(): Promise<void>;
  34223. /** @hidden */
  34224. _checkIsReady(): void;
  34225. /**
  34226. * Will start the animation sequence of a given target
  34227. * @param target defines the target
  34228. * @param from defines from which frame should animation start
  34229. * @param to defines until which frame should animation run.
  34230. * @param weight defines the weight to apply to the animation (1.0 by default)
  34231. * @param loop defines if the animation loops
  34232. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  34233. * @param onAnimationEnd defines the function to be executed when the animation ends
  34234. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  34235. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  34236. * @param onAnimationLoop defines the callback to call when an animation loops
  34237. * @returns the animatable object created for this animation
  34238. */
  34239. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  34240. /**
  34241. * Will start the animation sequence of a given target
  34242. * @param target defines the target
  34243. * @param from defines from which frame should animation start
  34244. * @param to defines until which frame should animation run.
  34245. * @param loop defines if the animation loops
  34246. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  34247. * @param onAnimationEnd defines the function to be executed when the animation ends
  34248. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  34249. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  34250. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  34251. * @param onAnimationLoop defines the callback to call when an animation loops
  34252. * @returns the animatable object created for this animation
  34253. */
  34254. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  34255. /**
  34256. * Will start the animation sequence of a given target and its hierarchy
  34257. * @param target defines the target
  34258. * @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.
  34259. * @param from defines from which frame should animation start
  34260. * @param to defines until which frame should animation run.
  34261. * @param loop defines if the animation loops
  34262. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  34263. * @param onAnimationEnd defines the function to be executed when the animation ends
  34264. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  34265. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  34266. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  34267. * @param onAnimationLoop defines the callback to call when an animation loops
  34268. * @returns the list of created animatables
  34269. */
  34270. 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): Animatable[];
  34271. /**
  34272. * Begin a new animation on a given node
  34273. * @param target defines the target where the animation will take place
  34274. * @param animations defines the list of animations to start
  34275. * @param from defines the initial value
  34276. * @param to defines the final value
  34277. * @param loop defines if you want animation to loop (off by default)
  34278. * @param speedRatio defines the speed ratio to apply to all animations
  34279. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34280. * @param onAnimationLoop defines the callback to call when an animation loops
  34281. * @returns the list of created animatables
  34282. */
  34283. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  34284. /**
  34285. * Begin a new animation on a given node and its hierarchy
  34286. * @param target defines the root node where the animation will take place
  34287. * @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.
  34288. * @param animations defines the list of animations to start
  34289. * @param from defines the initial value
  34290. * @param to defines the final value
  34291. * @param loop defines if you want animation to loop (off by default)
  34292. * @param speedRatio defines the speed ratio to apply to all animations
  34293. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34294. * @param onAnimationLoop defines the callback to call when an animation loops
  34295. * @returns the list of animatables created for all nodes
  34296. */
  34297. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  34298. /**
  34299. * Gets the animatable associated with a specific target
  34300. * @param target defines the target of the animatable
  34301. * @returns the required animatable if found
  34302. */
  34303. getAnimatableByTarget(target: any): Nullable<Animatable>;
  34304. /**
  34305. * Gets all animatables associated with a given target
  34306. * @param target defines the target to look animatables for
  34307. * @returns an array of Animatables
  34308. */
  34309. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  34310. /**
  34311. * Gets all animatable attached to the scene
  34312. */
  34313. readonly animatables: Animatable[];
  34314. /**
  34315. * Will stop the animation of the given target
  34316. * @param target - the target
  34317. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34318. * @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)
  34319. */
  34320. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34321. /**
  34322. * Stops and removes all animations that have been applied to the scene
  34323. */
  34324. stopAllAnimations(): void;
  34325. /**
  34326. * Resets the last animation time frame.
  34327. * Useful to override when animations start running when loading a scene for the first time.
  34328. */
  34329. resetLastAnimationTimeFrame(): void;
  34330. private _animate;
  34331. /** @hidden */
  34332. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  34333. private _processLateAnimationBindingsForMatrices;
  34334. private _processLateAnimationBindingsForQuaternions;
  34335. private _processLateAnimationBindings;
  34336. /** @hidden */
  34337. _switchToAlternateCameraConfiguration(active: boolean): void;
  34338. /**
  34339. * Gets the current view matrix
  34340. * @returns a Matrix
  34341. */
  34342. getViewMatrix(): Matrix;
  34343. /**
  34344. * Gets the current projection matrix
  34345. * @returns a Matrix
  34346. */
  34347. getProjectionMatrix(): Matrix;
  34348. /**
  34349. * Gets the current transform matrix
  34350. * @returns a Matrix made of View * Projection
  34351. */
  34352. getTransformMatrix(): Matrix;
  34353. /**
  34354. * Sets the current transform matrix
  34355. * @param view defines the View matrix to use
  34356. * @param projection defines the Projection matrix to use
  34357. */
  34358. setTransformMatrix(view: Matrix, projection: Matrix): void;
  34359. /** @hidden */
  34360. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  34361. /**
  34362. * Gets the uniform buffer used to store scene data
  34363. * @returns a UniformBuffer
  34364. */
  34365. getSceneUniformBuffer(): UniformBuffer;
  34366. /**
  34367. * Gets an unique (relatively to the current scene) Id
  34368. * @returns an unique number for the scene
  34369. */
  34370. getUniqueId(): number;
  34371. /**
  34372. * Add a mesh to the list of scene's meshes
  34373. * @param newMesh defines the mesh to add
  34374. * @param recursive if all child meshes should also be added to the scene
  34375. */
  34376. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34377. /**
  34378. * Remove a mesh for the list of scene's meshes
  34379. * @param toRemove defines the mesh to remove
  34380. * @param recursive if all child meshes should also be removed from the scene
  34381. * @returns the index where the mesh was in the mesh list
  34382. */
  34383. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34384. /**
  34385. * Add a transform node to the list of scene's transform nodes
  34386. * @param newTransformNode defines the transform node to add
  34387. */
  34388. addTransformNode(newTransformNode: TransformNode): void;
  34389. /**
  34390. * Remove a transform node for the list of scene's transform nodes
  34391. * @param toRemove defines the transform node to remove
  34392. * @returns the index where the transform node was in the transform node list
  34393. */
  34394. removeTransformNode(toRemove: TransformNode): number;
  34395. /**
  34396. * Remove a skeleton for the list of scene's skeletons
  34397. * @param toRemove defines the skeleton to remove
  34398. * @returns the index where the skeleton was in the skeleton list
  34399. */
  34400. removeSkeleton(toRemove: Skeleton): number;
  34401. /**
  34402. * Remove a morph target for the list of scene's morph targets
  34403. * @param toRemove defines the morph target to remove
  34404. * @returns the index where the morph target was in the morph target list
  34405. */
  34406. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34407. /**
  34408. * Remove a light for the list of scene's lights
  34409. * @param toRemove defines the light to remove
  34410. * @returns the index where the light was in the light list
  34411. */
  34412. removeLight(toRemove: Light): number;
  34413. /**
  34414. * Remove a camera for the list of scene's cameras
  34415. * @param toRemove defines the camera to remove
  34416. * @returns the index where the camera was in the camera list
  34417. */
  34418. removeCamera(toRemove: Camera): number;
  34419. /**
  34420. * Remove a particle system for the list of scene's particle systems
  34421. * @param toRemove defines the particle system to remove
  34422. * @returns the index where the particle system was in the particle system list
  34423. */
  34424. removeParticleSystem(toRemove: IParticleSystem): number;
  34425. /**
  34426. * Remove a animation for the list of scene's animations
  34427. * @param toRemove defines the animation to remove
  34428. * @returns the index where the animation was in the animation list
  34429. */
  34430. removeAnimation(toRemove: Animation): number;
  34431. /**
  34432. * Removes the given animation group from this scene.
  34433. * @param toRemove The animation group to remove
  34434. * @returns The index of the removed animation group
  34435. */
  34436. removeAnimationGroup(toRemove: AnimationGroup): number;
  34437. /**
  34438. * Removes the given multi-material from this scene.
  34439. * @param toRemove The multi-material to remove
  34440. * @returns The index of the removed multi-material
  34441. */
  34442. removeMultiMaterial(toRemove: MultiMaterial): number;
  34443. /**
  34444. * Removes the given material from this scene.
  34445. * @param toRemove The material to remove
  34446. * @returns The index of the removed material
  34447. */
  34448. removeMaterial(toRemove: Material): number;
  34449. /**
  34450. * Removes the given action manager from this scene.
  34451. * @param toRemove The action manager to remove
  34452. * @returns The index of the removed action manager
  34453. */
  34454. removeActionManager(toRemove: ActionManager): number;
  34455. /**
  34456. * Removes the given texture from this scene.
  34457. * @param toRemove The texture to remove
  34458. * @returns The index of the removed texture
  34459. */
  34460. removeTexture(toRemove: BaseTexture): number;
  34461. /**
  34462. * Adds the given light to this scene
  34463. * @param newLight The light to add
  34464. */
  34465. addLight(newLight: Light): void;
  34466. /**
  34467. * Sorts the list list based on light priorities
  34468. */
  34469. sortLightsByPriority(): void;
  34470. /**
  34471. * Adds the given camera to this scene
  34472. * @param newCamera The camera to add
  34473. */
  34474. addCamera(newCamera: Camera): void;
  34475. /**
  34476. * Adds the given skeleton to this scene
  34477. * @param newSkeleton The skeleton to add
  34478. */
  34479. addSkeleton(newSkeleton: Skeleton): void;
  34480. /**
  34481. * Adds the given particle system to this scene
  34482. * @param newParticleSystem The particle system to add
  34483. */
  34484. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34485. /**
  34486. * Adds the given animation to this scene
  34487. * @param newAnimation The animation to add
  34488. */
  34489. addAnimation(newAnimation: Animation): void;
  34490. /**
  34491. * Adds the given animation group to this scene.
  34492. * @param newAnimationGroup The animation group to add
  34493. */
  34494. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34495. /**
  34496. * Adds the given multi-material to this scene
  34497. * @param newMultiMaterial The multi-material to add
  34498. */
  34499. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34500. /**
  34501. * Adds the given material to this scene
  34502. * @param newMaterial The material to add
  34503. */
  34504. addMaterial(newMaterial: Material): void;
  34505. /**
  34506. * Adds the given morph target to this scene
  34507. * @param newMorphTargetManager The morph target to add
  34508. */
  34509. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34510. /**
  34511. * Adds the given geometry to this scene
  34512. * @param newGeometry The geometry to add
  34513. */
  34514. addGeometry(newGeometry: Geometry): void;
  34515. /**
  34516. * Adds the given action manager to this scene
  34517. * @param newActionManager The action manager to add
  34518. */
  34519. addActionManager(newActionManager: ActionManager): void;
  34520. /**
  34521. * Adds the given texture to this scene.
  34522. * @param newTexture The texture to add
  34523. */
  34524. addTexture(newTexture: BaseTexture): void;
  34525. /**
  34526. * Switch active camera
  34527. * @param newCamera defines the new active camera
  34528. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34529. */
  34530. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34531. /**
  34532. * sets the active camera of the scene using its ID
  34533. * @param id defines the camera's ID
  34534. * @return the new active camera or null if none found.
  34535. */
  34536. setActiveCameraByID(id: string): Nullable<Camera>;
  34537. /**
  34538. * sets the active camera of the scene using its name
  34539. * @param name defines the camera's name
  34540. * @returns the new active camera or null if none found.
  34541. */
  34542. setActiveCameraByName(name: string): Nullable<Camera>;
  34543. /**
  34544. * get an animation group using its name
  34545. * @param name defines the material's name
  34546. * @return the animation group or null if none found.
  34547. */
  34548. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34549. /**
  34550. * get a material using its id
  34551. * @param id defines the material's ID
  34552. * @return the material or null if none found.
  34553. */
  34554. getMaterialByID(id: string): Nullable<Material>;
  34555. /**
  34556. * Gets a material using its name
  34557. * @param name defines the material's name
  34558. * @return the material or null if none found.
  34559. */
  34560. getMaterialByName(name: string): Nullable<Material>;
  34561. /**
  34562. * Gets a camera using its id
  34563. * @param id defines the id to look for
  34564. * @returns the camera or null if not found
  34565. */
  34566. getCameraByID(id: string): Nullable<Camera>;
  34567. /**
  34568. * Gets a camera using its unique id
  34569. * @param uniqueId defines the unique id to look for
  34570. * @returns the camera or null if not found
  34571. */
  34572. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34573. /**
  34574. * Gets a camera using its name
  34575. * @param name defines the camera's name
  34576. * @return the camera or null if none found.
  34577. */
  34578. getCameraByName(name: string): Nullable<Camera>;
  34579. /**
  34580. * Gets a bone using its id
  34581. * @param id defines the bone's id
  34582. * @return the bone or null if not found
  34583. */
  34584. getBoneByID(id: string): Nullable<Bone>;
  34585. /**
  34586. * Gets a bone using its id
  34587. * @param name defines the bone's name
  34588. * @return the bone or null if not found
  34589. */
  34590. getBoneByName(name: string): Nullable<Bone>;
  34591. /**
  34592. * Gets a light node using its name
  34593. * @param name defines the the light's name
  34594. * @return the light or null if none found.
  34595. */
  34596. getLightByName(name: string): Nullable<Light>;
  34597. /**
  34598. * Gets a light node using its id
  34599. * @param id defines the light's id
  34600. * @return the light or null if none found.
  34601. */
  34602. getLightByID(id: string): Nullable<Light>;
  34603. /**
  34604. * Gets a light node using its scene-generated unique ID
  34605. * @param uniqueId defines the light's unique id
  34606. * @return the light or null if none found.
  34607. */
  34608. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34609. /**
  34610. * Gets a particle system by id
  34611. * @param id defines the particle system id
  34612. * @return the corresponding system or null if none found
  34613. */
  34614. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34615. /**
  34616. * Gets a geometry using its ID
  34617. * @param id defines the geometry's id
  34618. * @return the geometry or null if none found.
  34619. */
  34620. getGeometryByID(id: string): Nullable<Geometry>;
  34621. private _getGeometryByUniqueID;
  34622. /**
  34623. * Add a new geometry to this scene
  34624. * @param geometry defines the geometry to be added to the scene.
  34625. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34626. * @return a boolean defining if the geometry was added or not
  34627. */
  34628. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34629. /**
  34630. * Removes an existing geometry
  34631. * @param geometry defines the geometry to be removed from the scene
  34632. * @return a boolean defining if the geometry was removed or not
  34633. */
  34634. removeGeometry(geometry: Geometry): boolean;
  34635. /**
  34636. * Gets the list of geometries attached to the scene
  34637. * @returns an array of Geometry
  34638. */
  34639. getGeometries(): Geometry[];
  34640. /**
  34641. * Gets the first added mesh found of a given ID
  34642. * @param id defines the id to search for
  34643. * @return the mesh found or null if not found at all
  34644. */
  34645. getMeshByID(id: string): Nullable<AbstractMesh>;
  34646. /**
  34647. * Gets a list of meshes using their id
  34648. * @param id defines the id to search for
  34649. * @returns a list of meshes
  34650. */
  34651. getMeshesByID(id: string): Array<AbstractMesh>;
  34652. /**
  34653. * Gets the first added transform node found of a given ID
  34654. * @param id defines the id to search for
  34655. * @return the found transform node or null if not found at all.
  34656. */
  34657. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34658. /**
  34659. * Gets a list of transform nodes using their id
  34660. * @param id defines the id to search for
  34661. * @returns a list of transform nodes
  34662. */
  34663. getTransformNodesByID(id: string): Array<TransformNode>;
  34664. /**
  34665. * Gets a mesh with its auto-generated unique id
  34666. * @param uniqueId defines the unique id to search for
  34667. * @return the found mesh or null if not found at all.
  34668. */
  34669. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34670. /**
  34671. * Gets a the last added mesh using a given id
  34672. * @param id defines the id to search for
  34673. * @return the found mesh or null if not found at all.
  34674. */
  34675. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34676. /**
  34677. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34678. * @param id defines the id to search for
  34679. * @return the found node or null if not found at all
  34680. */
  34681. getLastEntryByID(id: string): Nullable<Node>;
  34682. /**
  34683. * Gets a node (Mesh, Camera, Light) using a given id
  34684. * @param id defines the id to search for
  34685. * @return the found node or null if not found at all
  34686. */
  34687. getNodeByID(id: string): Nullable<Node>;
  34688. /**
  34689. * Gets a node (Mesh, Camera, Light) using a given name
  34690. * @param name defines the name to search for
  34691. * @return the found node or null if not found at all.
  34692. */
  34693. getNodeByName(name: string): Nullable<Node>;
  34694. /**
  34695. * Gets a mesh using a given name
  34696. * @param name defines the name to search for
  34697. * @return the found mesh or null if not found at all.
  34698. */
  34699. getMeshByName(name: string): Nullable<AbstractMesh>;
  34700. /**
  34701. * Gets a transform node using a given name
  34702. * @param name defines the name to search for
  34703. * @return the found transform node or null if not found at all.
  34704. */
  34705. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34706. /**
  34707. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34708. * @param id defines the id to search for
  34709. * @return the found skeleton or null if not found at all.
  34710. */
  34711. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34712. /**
  34713. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34714. * @param id defines the id to search for
  34715. * @return the found skeleton or null if not found at all.
  34716. */
  34717. getSkeletonById(id: string): Nullable<Skeleton>;
  34718. /**
  34719. * Gets a skeleton using a given name
  34720. * @param name defines the name to search for
  34721. * @return the found skeleton or null if not found at all.
  34722. */
  34723. getSkeletonByName(name: string): Nullable<Skeleton>;
  34724. /**
  34725. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34726. * @param id defines the id to search for
  34727. * @return the found morph target manager or null if not found at all.
  34728. */
  34729. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34730. /**
  34731. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34732. * @param id defines the id to search for
  34733. * @return the found morph target or null if not found at all.
  34734. */
  34735. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34736. /**
  34737. * Gets a boolean indicating if the given mesh is active
  34738. * @param mesh defines the mesh to look for
  34739. * @returns true if the mesh is in the active list
  34740. */
  34741. isActiveMesh(mesh: AbstractMesh): boolean;
  34742. /**
  34743. * Return a unique id as a string which can serve as an identifier for the scene
  34744. */
  34745. readonly uid: string;
  34746. /**
  34747. * Add an externaly attached data from its key.
  34748. * This method call will fail and return false, if such key already exists.
  34749. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34750. * @param key the unique key that identifies the data
  34751. * @param data the data object to associate to the key for this Engine instance
  34752. * @return true if no such key were already present and the data was added successfully, false otherwise
  34753. */
  34754. addExternalData<T>(key: string, data: T): boolean;
  34755. /**
  34756. * Get an externaly attached data from its key
  34757. * @param key the unique key that identifies the data
  34758. * @return the associated data, if present (can be null), or undefined if not present
  34759. */
  34760. getExternalData<T>(key: string): Nullable<T>;
  34761. /**
  34762. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34763. * @param key the unique key that identifies the data
  34764. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34765. * @return the associated data, can be null if the factory returned null.
  34766. */
  34767. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34768. /**
  34769. * Remove an externaly attached data from the Engine instance
  34770. * @param key the unique key that identifies the data
  34771. * @return true if the data was successfully removed, false if it doesn't exist
  34772. */
  34773. removeExternalData(key: string): boolean;
  34774. private _evaluateSubMesh;
  34775. /**
  34776. * Clear the processed materials smart array preventing retention point in material dispose.
  34777. */
  34778. freeProcessedMaterials(): void;
  34779. private _preventFreeActiveMeshesAndRenderingGroups;
  34780. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34781. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34782. * when disposing several meshes in a row or a hierarchy of meshes.
  34783. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34784. */
  34785. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34786. /**
  34787. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34788. */
  34789. freeActiveMeshes(): void;
  34790. /**
  34791. * Clear the info related to rendering groups preventing retention points during dispose.
  34792. */
  34793. freeRenderingGroups(): void;
  34794. /** @hidden */
  34795. _isInIntermediateRendering(): boolean;
  34796. /**
  34797. * Lambda returning the list of potentially active meshes.
  34798. */
  34799. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34800. /**
  34801. * Lambda returning the list of potentially active sub meshes.
  34802. */
  34803. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34804. /**
  34805. * Lambda returning the list of potentially intersecting sub meshes.
  34806. */
  34807. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34808. /**
  34809. * Lambda returning the list of potentially colliding sub meshes.
  34810. */
  34811. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34812. private _activeMeshesFrozen;
  34813. /**
  34814. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34815. * @returns the current scene
  34816. */
  34817. freezeActiveMeshes(): Scene;
  34818. /**
  34819. * Use this function to restart evaluating active meshes on every frame
  34820. * @returns the current scene
  34821. */
  34822. unfreezeActiveMeshes(): Scene;
  34823. private _evaluateActiveMeshes;
  34824. private _activeMesh;
  34825. /**
  34826. * Update the transform matrix to update from the current active camera
  34827. * @param force defines a boolean used to force the update even if cache is up to date
  34828. */
  34829. updateTransformMatrix(force?: boolean): void;
  34830. /**
  34831. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  34832. * @param alternateCamera defines the camera to use
  34833. */
  34834. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  34835. /** @hidden */
  34836. _allowPostProcessClearColor: boolean;
  34837. private _renderForCamera;
  34838. private _processSubCameras;
  34839. private _checkIntersections;
  34840. /** @hidden */
  34841. _advancePhysicsEngineStep(step: number): void;
  34842. /**
  34843. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34844. */
  34845. getDeterministicFrameTime: () => number;
  34846. /**
  34847. * Render the scene
  34848. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34849. */
  34850. render(updateCameras?: boolean): void;
  34851. /**
  34852. * Freeze all materials
  34853. * A frozen material will not be updatable but should be faster to render
  34854. */
  34855. freezeMaterials(): void;
  34856. /**
  34857. * Unfreeze all materials
  34858. * A frozen material will not be updatable but should be faster to render
  34859. */
  34860. unfreezeMaterials(): void;
  34861. /**
  34862. * Releases all held ressources
  34863. */
  34864. dispose(): void;
  34865. /**
  34866. * Gets if the scene is already disposed
  34867. */
  34868. readonly isDisposed: boolean;
  34869. /**
  34870. * Call this function to reduce memory footprint of the scene.
  34871. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34872. */
  34873. clearCachedVertexData(): void;
  34874. /**
  34875. * This function will remove the local cached buffer data from texture.
  34876. * It will save memory but will prevent the texture from being rebuilt
  34877. */
  34878. cleanCachedTextureBuffer(): void;
  34879. /**
  34880. * Get the world extend vectors with an optional filter
  34881. *
  34882. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34883. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34884. */
  34885. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34886. min: Vector3;
  34887. max: Vector3;
  34888. };
  34889. /**
  34890. * Creates a ray that can be used to pick in the scene
  34891. * @param x defines the x coordinate of the origin (on-screen)
  34892. * @param y defines the y coordinate of the origin (on-screen)
  34893. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34894. * @param camera defines the camera to use for the picking
  34895. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34896. * @returns a Ray
  34897. */
  34898. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34899. /**
  34900. * Creates a ray that can be used to pick in the scene
  34901. * @param x defines the x coordinate of the origin (on-screen)
  34902. * @param y defines the y coordinate of the origin (on-screen)
  34903. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34904. * @param result defines the ray where to store the picking ray
  34905. * @param camera defines the camera to use for the picking
  34906. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34907. * @returns the current scene
  34908. */
  34909. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34910. /**
  34911. * Creates a ray that can be used to pick in the scene
  34912. * @param x defines the x coordinate of the origin (on-screen)
  34913. * @param y defines the y coordinate of the origin (on-screen)
  34914. * @param camera defines the camera to use for the picking
  34915. * @returns a Ray
  34916. */
  34917. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34918. /**
  34919. * Creates a ray that can be used to pick in the scene
  34920. * @param x defines the x coordinate of the origin (on-screen)
  34921. * @param y defines the y coordinate of the origin (on-screen)
  34922. * @param result defines the ray where to store the picking ray
  34923. * @param camera defines the camera to use for the picking
  34924. * @returns the current scene
  34925. */
  34926. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34927. private _internalPick;
  34928. private _internalMultiPick;
  34929. private _tempPickingRay;
  34930. /** Launch a ray to try to pick a mesh in the scene
  34931. * @param x position on screen
  34932. * @param y position on screen
  34933. * @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
  34934. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34935. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34936. * @returns a PickingInfo
  34937. */
  34938. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  34939. private _cachedRayForTransform;
  34940. /** Use the given ray to pick a mesh in the scene
  34941. * @param ray The ray to use to pick meshes
  34942. * @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
  34943. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34944. * @returns a PickingInfo
  34945. */
  34946. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  34947. /**
  34948. * Launch a ray to try to pick a mesh in the scene
  34949. * @param x X position on screen
  34950. * @param y Y position on screen
  34951. * @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
  34952. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34953. * @returns an array of PickingInfo
  34954. */
  34955. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  34956. /**
  34957. * Launch a ray to try to pick a mesh in the scene
  34958. * @param ray Ray to use
  34959. * @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
  34960. * @returns an array of PickingInfo
  34961. */
  34962. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  34963. /**
  34964. * Force the value of meshUnderPointer
  34965. * @param mesh defines the mesh to use
  34966. */
  34967. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34968. /**
  34969. * Gets the mesh under the pointer
  34970. * @returns a Mesh or null if no mesh is under the pointer
  34971. */
  34972. getPointerOverMesh(): Nullable<AbstractMesh>;
  34973. /** @hidden */
  34974. _rebuildGeometries(): void;
  34975. /** @hidden */
  34976. _rebuildTextures(): void;
  34977. private _getByTags;
  34978. /**
  34979. * Get a list of meshes by tags
  34980. * @param tagsQuery defines the tags query to use
  34981. * @param forEach defines a predicate used to filter results
  34982. * @returns an array of Mesh
  34983. */
  34984. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34985. /**
  34986. * Get a list of cameras by tags
  34987. * @param tagsQuery defines the tags query to use
  34988. * @param forEach defines a predicate used to filter results
  34989. * @returns an array of Camera
  34990. */
  34991. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34992. /**
  34993. * Get a list of lights by tags
  34994. * @param tagsQuery defines the tags query to use
  34995. * @param forEach defines a predicate used to filter results
  34996. * @returns an array of Light
  34997. */
  34998. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34999. /**
  35000. * Get a list of materials by tags
  35001. * @param tagsQuery defines the tags query to use
  35002. * @param forEach defines a predicate used to filter results
  35003. * @returns an array of Material
  35004. */
  35005. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35006. /**
  35007. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35008. * This allowed control for front to back rendering or reversly depending of the special needs.
  35009. *
  35010. * @param renderingGroupId The rendering group id corresponding to its index
  35011. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35012. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35013. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35014. */
  35015. 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;
  35016. /**
  35017. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35018. *
  35019. * @param renderingGroupId The rendering group id corresponding to its index
  35020. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35021. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35022. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35023. */
  35024. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35025. /**
  35026. * Gets the current auto clear configuration for one rendering group of the rendering
  35027. * manager.
  35028. * @param index the rendering group index to get the information for
  35029. * @returns The auto clear setup for the requested rendering group
  35030. */
  35031. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35032. private _blockMaterialDirtyMechanism;
  35033. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35034. blockMaterialDirtyMechanism: boolean;
  35035. /**
  35036. * Will flag all materials as dirty to trigger new shader compilation
  35037. * @param flag defines the flag used to specify which material part must be marked as dirty
  35038. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35039. */
  35040. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35041. /** @hidden */
  35042. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  35043. /** @hidden */
  35044. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35045. }
  35046. }
  35047. declare module "babylonjs/assetContainer" {
  35048. import { AbstractScene } from "babylonjs/abstractScene";
  35049. import { Scene } from "babylonjs/scene";
  35050. import { Mesh } from "babylonjs/Meshes/mesh";
  35051. /**
  35052. * Set of assets to keep when moving a scene into an asset container.
  35053. */
  35054. export class KeepAssets extends AbstractScene {
  35055. }
  35056. /**
  35057. * Container with a set of assets that can be added or removed from a scene.
  35058. */
  35059. export class AssetContainer extends AbstractScene {
  35060. /**
  35061. * The scene the AssetContainer belongs to.
  35062. */
  35063. scene: Scene;
  35064. /**
  35065. * Instantiates an AssetContainer.
  35066. * @param scene The scene the AssetContainer belongs to.
  35067. */
  35068. constructor(scene: Scene);
  35069. /**
  35070. * Adds all the assets from the container to the scene.
  35071. */
  35072. addAllToScene(): void;
  35073. /**
  35074. * Removes all the assets in the container from the scene
  35075. */
  35076. removeAllFromScene(): void;
  35077. /**
  35078. * Disposes all the assets in the container
  35079. */
  35080. dispose(): void;
  35081. private _moveAssets;
  35082. /**
  35083. * Removes all the assets contained in the scene and adds them to the container.
  35084. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35085. */
  35086. moveAllFromScene(keepAssets?: KeepAssets): void;
  35087. /**
  35088. * 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.
  35089. * @returns the root mesh
  35090. */
  35091. createRootMesh(): Mesh;
  35092. }
  35093. }
  35094. declare module "babylonjs/abstractScene" {
  35095. import { Scene } from "babylonjs/scene";
  35096. import { Nullable } from "babylonjs/types";
  35097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35098. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35099. import { Geometry } from "babylonjs/Meshes/geometry";
  35100. import { Skeleton } from "babylonjs/Bones/skeleton";
  35101. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35102. import { AssetContainer } from "babylonjs/assetContainer";
  35103. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35104. import { Animation } from "babylonjs/Animations/animation";
  35105. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35107. import { Material } from "babylonjs/Materials/material";
  35108. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35109. import { ActionManager } from "babylonjs/Actions/actionManager";
  35110. import { Camera } from "babylonjs/Cameras/camera";
  35111. import { Light } from "babylonjs/Lights/light";
  35112. import { Node } from "babylonjs/node";
  35113. /**
  35114. * Defines how the parser contract is defined.
  35115. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35116. */
  35117. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35118. /**
  35119. * Defines how the individual parser contract is defined.
  35120. * These parser can parse an individual asset
  35121. */
  35122. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35123. /**
  35124. * Base class of the scene acting as a container for the different elements composing a scene.
  35125. * This class is dynamically extended by the different components of the scene increasing
  35126. * flexibility and reducing coupling
  35127. */
  35128. export abstract class AbstractScene {
  35129. /**
  35130. * Stores the list of available parsers in the application.
  35131. */
  35132. private static _BabylonFileParsers;
  35133. /**
  35134. * Stores the list of available individual parsers in the application.
  35135. */
  35136. private static _IndividualBabylonFileParsers;
  35137. /**
  35138. * Adds a parser in the list of available ones
  35139. * @param name Defines the name of the parser
  35140. * @param parser Defines the parser to add
  35141. */
  35142. static AddParser(name: string, parser: BabylonFileParser): void;
  35143. /**
  35144. * Gets a general parser from the list of avaialble ones
  35145. * @param name Defines the name of the parser
  35146. * @returns the requested parser or null
  35147. */
  35148. static GetParser(name: string): Nullable<BabylonFileParser>;
  35149. /**
  35150. * Adds n individual parser in the list of available ones
  35151. * @param name Defines the name of the parser
  35152. * @param parser Defines the parser to add
  35153. */
  35154. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35155. /**
  35156. * Gets an individual parser from the list of avaialble ones
  35157. * @param name Defines the name of the parser
  35158. * @returns the requested parser or null
  35159. */
  35160. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35161. /**
  35162. * Parser json data and populate both a scene and its associated container object
  35163. * @param jsonData Defines the data to parse
  35164. * @param scene Defines the scene to parse the data for
  35165. * @param container Defines the container attached to the parsing sequence
  35166. * @param rootUrl Defines the root url of the data
  35167. */
  35168. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35169. /**
  35170. * Gets the list of root nodes (ie. nodes with no parent)
  35171. */
  35172. rootNodes: Node[];
  35173. /** All of the cameras added to this scene
  35174. * @see http://doc.babylonjs.com/babylon101/cameras
  35175. */
  35176. cameras: Camera[];
  35177. /**
  35178. * All of the lights added to this scene
  35179. * @see http://doc.babylonjs.com/babylon101/lights
  35180. */
  35181. lights: Light[];
  35182. /**
  35183. * All of the (abstract) meshes added to this scene
  35184. */
  35185. meshes: AbstractMesh[];
  35186. /**
  35187. * The list of skeletons added to the scene
  35188. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35189. */
  35190. skeletons: Skeleton[];
  35191. /**
  35192. * All of the particle systems added to this scene
  35193. * @see http://doc.babylonjs.com/babylon101/particles
  35194. */
  35195. particleSystems: IParticleSystem[];
  35196. /**
  35197. * Gets a list of Animations associated with the scene
  35198. */
  35199. animations: Animation[];
  35200. /**
  35201. * All of the animation groups added to this scene
  35202. * @see http://doc.babylonjs.com/how_to/group
  35203. */
  35204. animationGroups: AnimationGroup[];
  35205. /**
  35206. * All of the multi-materials added to this scene
  35207. * @see http://doc.babylonjs.com/how_to/multi_materials
  35208. */
  35209. multiMaterials: MultiMaterial[];
  35210. /**
  35211. * All of the materials added to this scene
  35212. * In the context of a Scene, it is not supposed to be modified manually.
  35213. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35214. * Note also that the order of the Material wihin the array is not significant and might change.
  35215. * @see http://doc.babylonjs.com/babylon101/materials
  35216. */
  35217. materials: Material[];
  35218. /**
  35219. * The list of morph target managers added to the scene
  35220. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35221. */
  35222. morphTargetManagers: MorphTargetManager[];
  35223. /**
  35224. * The list of geometries used in the scene.
  35225. */
  35226. geometries: Geometry[];
  35227. /**
  35228. * All of the tranform nodes added to this scene
  35229. * In the context of a Scene, it is not supposed to be modified manually.
  35230. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35231. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35232. * @see http://doc.babylonjs.com/how_to/transformnode
  35233. */
  35234. transformNodes: TransformNode[];
  35235. /**
  35236. * ActionManagers available on the scene.
  35237. */
  35238. actionManagers: ActionManager[];
  35239. /**
  35240. * Textures to keep.
  35241. */
  35242. textures: BaseTexture[];
  35243. }
  35244. }
  35245. declare module "babylonjs/Audio/sound" {
  35246. import { Observable } from "babylonjs/Misc/observable";
  35247. import { Vector3 } from "babylonjs/Maths/math";
  35248. import { Nullable } from "babylonjs/types";
  35249. import { Scene } from "babylonjs/scene";
  35250. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35251. /**
  35252. * Defines a sound that can be played in the application.
  35253. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35255. */
  35256. export class Sound {
  35257. /**
  35258. * The name of the sound in the scene.
  35259. */
  35260. name: string;
  35261. /**
  35262. * Does the sound autoplay once loaded.
  35263. */
  35264. autoplay: boolean;
  35265. /**
  35266. * Does the sound loop after it finishes playing once.
  35267. */
  35268. loop: boolean;
  35269. /**
  35270. * Does the sound use a custom attenuation curve to simulate the falloff
  35271. * happening when the source gets further away from the camera.
  35272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35273. */
  35274. useCustomAttenuation: boolean;
  35275. /**
  35276. * The sound track id this sound belongs to.
  35277. */
  35278. soundTrackId: number;
  35279. /**
  35280. * Is this sound currently played.
  35281. */
  35282. isPlaying: boolean;
  35283. /**
  35284. * Is this sound currently paused.
  35285. */
  35286. isPaused: boolean;
  35287. /**
  35288. * Does this sound enables spatial sound.
  35289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35290. */
  35291. spatialSound: boolean;
  35292. /**
  35293. * Define the reference distance the sound should be heard perfectly.
  35294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35295. */
  35296. refDistance: number;
  35297. /**
  35298. * Define the roll off factor of spatial sounds.
  35299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35300. */
  35301. rolloffFactor: number;
  35302. /**
  35303. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35305. */
  35306. maxDistance: number;
  35307. /**
  35308. * Define the distance attenuation model the sound will follow.
  35309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35310. */
  35311. distanceModel: string;
  35312. /**
  35313. * @hidden
  35314. * Back Compat
  35315. **/
  35316. onended: () => any;
  35317. /**
  35318. * Observable event when the current playing sound finishes.
  35319. */
  35320. onEndedObservable: Observable<Sound>;
  35321. private _panningModel;
  35322. private _playbackRate;
  35323. private _streaming;
  35324. private _startTime;
  35325. private _startOffset;
  35326. private _position;
  35327. /** @hidden */
  35328. _positionInEmitterSpace: boolean;
  35329. private _localDirection;
  35330. private _volume;
  35331. private _isReadyToPlay;
  35332. private _isDirectional;
  35333. private _readyToPlayCallback;
  35334. private _audioBuffer;
  35335. private _soundSource;
  35336. private _streamingSource;
  35337. private _soundPanner;
  35338. private _soundGain;
  35339. private _inputAudioNode;
  35340. private _outputAudioNode;
  35341. private _coneInnerAngle;
  35342. private _coneOuterAngle;
  35343. private _coneOuterGain;
  35344. private _scene;
  35345. private _connectedTransformNode;
  35346. private _customAttenuationFunction;
  35347. private _registerFunc;
  35348. private _isOutputConnected;
  35349. private _htmlAudioElement;
  35350. private _urlType;
  35351. /** @hidden */
  35352. static _SceneComponentInitialization: (scene: Scene) => void;
  35353. /**
  35354. * Create a sound and attach it to a scene
  35355. * @param name Name of your sound
  35356. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35357. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35358. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35359. */
  35360. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  35361. /**
  35362. * Release the sound and its associated resources
  35363. */
  35364. dispose(): void;
  35365. /**
  35366. * Gets if the sounds is ready to be played or not.
  35367. * @returns true if ready, otherwise false
  35368. */
  35369. isReady(): boolean;
  35370. private _soundLoaded;
  35371. /**
  35372. * Sets the data of the sound from an audiobuffer
  35373. * @param audioBuffer The audioBuffer containing the data
  35374. */
  35375. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35376. /**
  35377. * Updates the current sounds options such as maxdistance, loop...
  35378. * @param options A JSON object containing values named as the object properties
  35379. */
  35380. updateOptions(options: any): void;
  35381. private _createSpatialParameters;
  35382. private _updateSpatialParameters;
  35383. /**
  35384. * Switch the panning model to HRTF:
  35385. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35387. */
  35388. switchPanningModelToHRTF(): void;
  35389. /**
  35390. * Switch the panning model to Equal Power:
  35391. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35392. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35393. */
  35394. switchPanningModelToEqualPower(): void;
  35395. private _switchPanningModel;
  35396. /**
  35397. * Connect this sound to a sound track audio node like gain...
  35398. * @param soundTrackAudioNode the sound track audio node to connect to
  35399. */
  35400. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35401. /**
  35402. * Transform this sound into a directional source
  35403. * @param coneInnerAngle Size of the inner cone in degree
  35404. * @param coneOuterAngle Size of the outer cone in degree
  35405. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35406. */
  35407. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35408. /**
  35409. * Gets or sets the inner angle for the directional cone.
  35410. */
  35411. /**
  35412. * Gets or sets the inner angle for the directional cone.
  35413. */
  35414. directionalConeInnerAngle: number;
  35415. /**
  35416. * Gets or sets the outer angle for the directional cone.
  35417. */
  35418. /**
  35419. * Gets or sets the outer angle for the directional cone.
  35420. */
  35421. directionalConeOuterAngle: number;
  35422. /**
  35423. * Sets the position of the emitter if spatial sound is enabled
  35424. * @param newPosition Defines the new posisiton
  35425. */
  35426. setPosition(newPosition: Vector3): void;
  35427. /**
  35428. * Sets the local direction of the emitter if spatial sound is enabled
  35429. * @param newLocalDirection Defines the new local direction
  35430. */
  35431. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35432. private _updateDirection;
  35433. /** @hidden */
  35434. updateDistanceFromListener(): void;
  35435. /**
  35436. * Sets a new custom attenuation function for the sound.
  35437. * @param callback Defines the function used for the attenuation
  35438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35439. */
  35440. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35441. /**
  35442. * Play the sound
  35443. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35444. * @param offset (optional) Start the sound setting it at a specific time
  35445. */
  35446. play(time?: number, offset?: number): void;
  35447. private _onended;
  35448. /**
  35449. * Stop the sound
  35450. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35451. */
  35452. stop(time?: number): void;
  35453. /**
  35454. * Put the sound in pause
  35455. */
  35456. pause(): void;
  35457. /**
  35458. * Sets a dedicated volume for this sounds
  35459. * @param newVolume Define the new volume of the sound
  35460. * @param time Define in how long the sound should be at this value
  35461. */
  35462. setVolume(newVolume: number, time?: number): void;
  35463. /**
  35464. * Set the sound play back rate
  35465. * @param newPlaybackRate Define the playback rate the sound should be played at
  35466. */
  35467. setPlaybackRate(newPlaybackRate: number): void;
  35468. /**
  35469. * Gets the volume of the sound.
  35470. * @returns the volume of the sound
  35471. */
  35472. getVolume(): number;
  35473. /**
  35474. * Attach the sound to a dedicated mesh
  35475. * @param transformNode The transform node to connect the sound with
  35476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35477. */
  35478. attachToMesh(transformNode: TransformNode): void;
  35479. /**
  35480. * Detach the sound from the previously attached mesh
  35481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35482. */
  35483. detachFromMesh(): void;
  35484. private _onRegisterAfterWorldMatrixUpdate;
  35485. /**
  35486. * Clone the current sound in the scene.
  35487. * @returns the new sound clone
  35488. */
  35489. clone(): Nullable<Sound>;
  35490. /**
  35491. * Gets the current underlying audio buffer containing the data
  35492. * @returns the audio buffer
  35493. */
  35494. getAudioBuffer(): Nullable<AudioBuffer>;
  35495. /**
  35496. * Serializes the Sound in a JSON representation
  35497. * @returns the JSON representation of the sound
  35498. */
  35499. serialize(): any;
  35500. /**
  35501. * Parse a JSON representation of a sound to innstantiate in a given scene
  35502. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35503. * @param scene Define the scene the new parsed sound should be created in
  35504. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35505. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35506. * @returns the newly parsed sound
  35507. */
  35508. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35509. }
  35510. }
  35511. declare module "babylonjs/Actions/directAudioActions" {
  35512. import { Action } from "babylonjs/Actions/action";
  35513. import { Condition } from "babylonjs/Actions/condition";
  35514. import { Sound } from "babylonjs/Audio/sound";
  35515. /**
  35516. * This defines an action helpful to play a defined sound on a triggered action.
  35517. */
  35518. export class PlaySoundAction extends Action {
  35519. private _sound;
  35520. /**
  35521. * Instantiate the action
  35522. * @param triggerOptions defines the trigger options
  35523. * @param sound defines the sound to play
  35524. * @param condition defines the trigger related conditions
  35525. */
  35526. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35527. /** @hidden */
  35528. _prepare(): void;
  35529. /**
  35530. * Execute the action and play the sound.
  35531. */
  35532. execute(): void;
  35533. /**
  35534. * Serializes the actions and its related information.
  35535. * @param parent defines the object to serialize in
  35536. * @returns the serialized object
  35537. */
  35538. serialize(parent: any): any;
  35539. }
  35540. /**
  35541. * This defines an action helpful to stop a defined sound on a triggered action.
  35542. */
  35543. export class StopSoundAction extends Action {
  35544. private _sound;
  35545. /**
  35546. * Instantiate the action
  35547. * @param triggerOptions defines the trigger options
  35548. * @param sound defines the sound to stop
  35549. * @param condition defines the trigger related conditions
  35550. */
  35551. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35552. /** @hidden */
  35553. _prepare(): void;
  35554. /**
  35555. * Execute the action and stop the sound.
  35556. */
  35557. execute(): void;
  35558. /**
  35559. * Serializes the actions and its related information.
  35560. * @param parent defines the object to serialize in
  35561. * @returns the serialized object
  35562. */
  35563. serialize(parent: any): any;
  35564. }
  35565. }
  35566. declare module "babylonjs/Actions/interpolateValueAction" {
  35567. import { Action } from "babylonjs/Actions/action";
  35568. import { Condition } from "babylonjs/Actions/condition";
  35569. import { Observable } from "babylonjs/Misc/observable";
  35570. /**
  35571. * This defines an action responsible to change the value of a property
  35572. * by interpolating between its current value and the newly set one once triggered.
  35573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35574. */
  35575. export class InterpolateValueAction extends Action {
  35576. /**
  35577. * Defines the path of the property where the value should be interpolated
  35578. */
  35579. propertyPath: string;
  35580. /**
  35581. * Defines the target value at the end of the interpolation.
  35582. */
  35583. value: any;
  35584. /**
  35585. * Defines the time it will take for the property to interpolate to the value.
  35586. */
  35587. duration: number;
  35588. /**
  35589. * Defines if the other scene animations should be stopped when the action has been triggered
  35590. */
  35591. stopOtherAnimations?: boolean;
  35592. /**
  35593. * Defines a callback raised once the interpolation animation has been done.
  35594. */
  35595. onInterpolationDone?: () => void;
  35596. /**
  35597. * Observable triggered once the interpolation animation has been done.
  35598. */
  35599. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35600. private _target;
  35601. private _effectiveTarget;
  35602. private _property;
  35603. /**
  35604. * Instantiate the action
  35605. * @param triggerOptions defines the trigger options
  35606. * @param target defines the object containing the value to interpolate
  35607. * @param propertyPath defines the path to the property in the target object
  35608. * @param value defines the target value at the end of the interpolation
  35609. * @param duration deines the time it will take for the property to interpolate to the value.
  35610. * @param condition defines the trigger related conditions
  35611. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35612. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35613. */
  35614. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35615. /** @hidden */
  35616. _prepare(): void;
  35617. /**
  35618. * Execute the action starts the value interpolation.
  35619. */
  35620. execute(): void;
  35621. /**
  35622. * Serializes the actions and its related information.
  35623. * @param parent defines the object to serialize in
  35624. * @returns the serialized object
  35625. */
  35626. serialize(parent: any): any;
  35627. }
  35628. }
  35629. declare module "babylonjs/Actions/index" {
  35630. export * from "babylonjs/Actions/action";
  35631. export * from "babylonjs/Actions/actionEvent";
  35632. export * from "babylonjs/Actions/actionManager";
  35633. export * from "babylonjs/Actions/condition";
  35634. export * from "babylonjs/Actions/directActions";
  35635. export * from "babylonjs/Actions/directAudioActions";
  35636. export * from "babylonjs/Actions/interpolateValueAction";
  35637. }
  35638. declare module "babylonjs/Animations/index" {
  35639. export * from "babylonjs/Animations/animatable";
  35640. export * from "babylonjs/Animations/animation";
  35641. export * from "babylonjs/Animations/animationGroup";
  35642. export * from "babylonjs/Animations/animationPropertiesOverride";
  35643. export * from "babylonjs/Animations/easing";
  35644. export * from "babylonjs/Animations/runtimeAnimation";
  35645. }
  35646. declare module "babylonjs/Audio/soundTrack" {
  35647. import { Sound } from "babylonjs/Audio/sound";
  35648. import { Analyser } from "babylonjs/Audio/analyser";
  35649. import { Scene } from "babylonjs/scene";
  35650. /**
  35651. * Options allowed during the creation of a sound track.
  35652. */
  35653. export interface ISoundTrackOptions {
  35654. /**
  35655. * The volume the sound track should take during creation
  35656. */
  35657. volume?: number;
  35658. /**
  35659. * Define if the sound track is the main sound track of the scene
  35660. */
  35661. mainTrack?: boolean;
  35662. }
  35663. /**
  35664. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35665. * It will be also used in a future release to apply effects on a specific track.
  35666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35667. */
  35668. export class SoundTrack {
  35669. /**
  35670. * The unique identifier of the sound track in the scene.
  35671. */
  35672. id: number;
  35673. /**
  35674. * The list of sounds included in the sound track.
  35675. */
  35676. soundCollection: Array<Sound>;
  35677. private _outputAudioNode;
  35678. private _scene;
  35679. private _isMainTrack;
  35680. private _connectedAnalyser;
  35681. private _options;
  35682. private _isInitialized;
  35683. /**
  35684. * Creates a new sound track.
  35685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35686. * @param scene Define the scene the sound track belongs to
  35687. * @param options
  35688. */
  35689. constructor(scene: Scene, options?: ISoundTrackOptions);
  35690. private _initializeSoundTrackAudioGraph;
  35691. /**
  35692. * Release the sound track and its associated resources
  35693. */
  35694. dispose(): void;
  35695. /**
  35696. * Adds a sound to this sound track
  35697. * @param sound define the cound to add
  35698. * @ignoreNaming
  35699. */
  35700. AddSound(sound: Sound): void;
  35701. /**
  35702. * Removes a sound to this sound track
  35703. * @param sound define the cound to remove
  35704. * @ignoreNaming
  35705. */
  35706. RemoveSound(sound: Sound): void;
  35707. /**
  35708. * Set a global volume for the full sound track.
  35709. * @param newVolume Define the new volume of the sound track
  35710. */
  35711. setVolume(newVolume: number): void;
  35712. /**
  35713. * Switch the panning model to HRTF:
  35714. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35716. */
  35717. switchPanningModelToHRTF(): void;
  35718. /**
  35719. * Switch the panning model to Equal Power:
  35720. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35722. */
  35723. switchPanningModelToEqualPower(): void;
  35724. /**
  35725. * Connect the sound track to an audio analyser allowing some amazing
  35726. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35728. * @param analyser The analyser to connect to the engine
  35729. */
  35730. connectToAnalyser(analyser: Analyser): void;
  35731. }
  35732. }
  35733. declare module "babylonjs/Audio/audioSceneComponent" {
  35734. import { Sound } from "babylonjs/Audio/sound";
  35735. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35736. import { Nullable } from "babylonjs/types";
  35737. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35738. import { Scene } from "babylonjs/scene";
  35739. import { AbstractScene } from "babylonjs/abstractScene";
  35740. module "babylonjs/abstractScene" {
  35741. interface AbstractScene {
  35742. /**
  35743. * The list of sounds used in the scene.
  35744. */
  35745. sounds: Nullable<Array<Sound>>;
  35746. }
  35747. }
  35748. module "babylonjs/scene" {
  35749. interface Scene {
  35750. /**
  35751. * @hidden
  35752. * Backing field
  35753. */
  35754. _mainSoundTrack: SoundTrack;
  35755. /**
  35756. * The main sound track played by the scene.
  35757. * It cotains your primary collection of sounds.
  35758. */
  35759. mainSoundTrack: SoundTrack;
  35760. /**
  35761. * The list of sound tracks added to the scene
  35762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35763. */
  35764. soundTracks: Nullable<Array<SoundTrack>>;
  35765. /**
  35766. * Gets a sound using a given name
  35767. * @param name defines the name to search for
  35768. * @return the found sound or null if not found at all.
  35769. */
  35770. getSoundByName(name: string): Nullable<Sound>;
  35771. /**
  35772. * Gets or sets if audio support is enabled
  35773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35774. */
  35775. audioEnabled: boolean;
  35776. /**
  35777. * Gets or sets if audio will be output to headphones
  35778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35779. */
  35780. headphone: boolean;
  35781. }
  35782. }
  35783. /**
  35784. * Defines the sound scene component responsible to manage any sounds
  35785. * in a given scene.
  35786. */
  35787. export class AudioSceneComponent implements ISceneSerializableComponent {
  35788. /**
  35789. * The component name helpfull to identify the component in the list of scene components.
  35790. */
  35791. readonly name: string;
  35792. /**
  35793. * The scene the component belongs to.
  35794. */
  35795. scene: Scene;
  35796. private _audioEnabled;
  35797. /**
  35798. * Gets whether audio is enabled or not.
  35799. * Please use related enable/disable method to switch state.
  35800. */
  35801. readonly audioEnabled: boolean;
  35802. private _headphone;
  35803. /**
  35804. * Gets whether audio is outputing to headphone or not.
  35805. * Please use the according Switch methods to change output.
  35806. */
  35807. readonly headphone: boolean;
  35808. /**
  35809. * Creates a new instance of the component for the given scene
  35810. * @param scene Defines the scene to register the component in
  35811. */
  35812. constructor(scene: Scene);
  35813. /**
  35814. * Registers the component in a given scene
  35815. */
  35816. register(): void;
  35817. /**
  35818. * Rebuilds the elements related to this component in case of
  35819. * context lost for instance.
  35820. */
  35821. rebuild(): void;
  35822. /**
  35823. * Serializes the component data to the specified json object
  35824. * @param serializationObject The object to serialize to
  35825. */
  35826. serialize(serializationObject: any): void;
  35827. /**
  35828. * Adds all the element from the container to the scene
  35829. * @param container the container holding the elements
  35830. */
  35831. addFromContainer(container: AbstractScene): void;
  35832. /**
  35833. * Removes all the elements in the container from the scene
  35834. * @param container contains the elements to remove
  35835. */
  35836. removeFromContainer(container: AbstractScene): void;
  35837. /**
  35838. * Disposes the component and the associated ressources.
  35839. */
  35840. dispose(): void;
  35841. /**
  35842. * Disables audio in the associated scene.
  35843. */
  35844. disableAudio(): void;
  35845. /**
  35846. * Enables audio in the associated scene.
  35847. */
  35848. enableAudio(): void;
  35849. /**
  35850. * Switch audio to headphone output.
  35851. */
  35852. switchAudioModeForHeadphones(): void;
  35853. /**
  35854. * Switch audio to normal speakers.
  35855. */
  35856. switchAudioModeForNormalSpeakers(): void;
  35857. private _afterRender;
  35858. }
  35859. }
  35860. declare module "babylonjs/Audio/weightedsound" {
  35861. import { Sound } from "babylonjs/Audio/sound";
  35862. /**
  35863. * Wraps one or more Sound objects and selects one with random weight for playback.
  35864. */
  35865. export class WeightedSound {
  35866. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35867. loop: boolean;
  35868. private _coneInnerAngle;
  35869. private _coneOuterAngle;
  35870. private _volume;
  35871. /** A Sound is currently playing. */
  35872. isPlaying: boolean;
  35873. /** A Sound is currently paused. */
  35874. isPaused: boolean;
  35875. private _sounds;
  35876. private _weights;
  35877. private _currentIndex?;
  35878. /**
  35879. * Creates a new WeightedSound from the list of sounds given.
  35880. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35881. * @param sounds Array of Sounds that will be selected from.
  35882. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35883. */
  35884. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35885. /**
  35886. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35887. */
  35888. /**
  35889. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35890. */
  35891. directionalConeInnerAngle: number;
  35892. /**
  35893. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35894. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35895. */
  35896. /**
  35897. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35898. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35899. */
  35900. directionalConeOuterAngle: number;
  35901. /**
  35902. * Playback volume.
  35903. */
  35904. /**
  35905. * Playback volume.
  35906. */
  35907. volume: number;
  35908. private _onended;
  35909. /**
  35910. * Suspend playback
  35911. */
  35912. pause(): void;
  35913. /**
  35914. * Stop playback
  35915. */
  35916. stop(): void;
  35917. /**
  35918. * Start playback.
  35919. * @param startOffset Position the clip head at a specific time in seconds.
  35920. */
  35921. play(startOffset?: number): void;
  35922. }
  35923. }
  35924. declare module "babylonjs/Audio/index" {
  35925. export * from "babylonjs/Audio/analyser";
  35926. export * from "babylonjs/Audio/audioEngine";
  35927. export * from "babylonjs/Audio/audioSceneComponent";
  35928. export * from "babylonjs/Audio/sound";
  35929. export * from "babylonjs/Audio/soundTrack";
  35930. export * from "babylonjs/Audio/weightedsound";
  35931. }
  35932. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35933. import { Behavior } from "babylonjs/Behaviors/behavior";
  35934. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35935. import { BackEase } from "babylonjs/Animations/easing";
  35936. /**
  35937. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35938. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35939. */
  35940. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35941. /**
  35942. * Gets the name of the behavior.
  35943. */
  35944. readonly name: string;
  35945. /**
  35946. * The easing function used by animations
  35947. */
  35948. static EasingFunction: BackEase;
  35949. /**
  35950. * The easing mode used by animations
  35951. */
  35952. static EasingMode: number;
  35953. /**
  35954. * The duration of the animation, in milliseconds
  35955. */
  35956. transitionDuration: number;
  35957. /**
  35958. * Length of the distance animated by the transition when lower radius is reached
  35959. */
  35960. lowerRadiusTransitionRange: number;
  35961. /**
  35962. * Length of the distance animated by the transition when upper radius is reached
  35963. */
  35964. upperRadiusTransitionRange: number;
  35965. private _autoTransitionRange;
  35966. /**
  35967. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35968. */
  35969. /**
  35970. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35971. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35972. */
  35973. autoTransitionRange: boolean;
  35974. private _attachedCamera;
  35975. private _onAfterCheckInputsObserver;
  35976. private _onMeshTargetChangedObserver;
  35977. /**
  35978. * Initializes the behavior.
  35979. */
  35980. init(): void;
  35981. /**
  35982. * Attaches the behavior to its arc rotate camera.
  35983. * @param camera Defines the camera to attach the behavior to
  35984. */
  35985. attach(camera: ArcRotateCamera): void;
  35986. /**
  35987. * Detaches the behavior from its current arc rotate camera.
  35988. */
  35989. detach(): void;
  35990. private _radiusIsAnimating;
  35991. private _radiusBounceTransition;
  35992. private _animatables;
  35993. private _cachedWheelPrecision;
  35994. /**
  35995. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35996. * @param radiusLimit The limit to check against.
  35997. * @return Bool to indicate if at limit.
  35998. */
  35999. private _isRadiusAtLimit;
  36000. /**
  36001. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36002. * @param radiusDelta The delta by which to animate to. Can be negative.
  36003. */
  36004. private _applyBoundRadiusAnimation;
  36005. /**
  36006. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36007. */
  36008. protected _clearAnimationLocks(): void;
  36009. /**
  36010. * Stops and removes all animations that have been applied to the camera
  36011. */
  36012. stopAllAnimations(): void;
  36013. }
  36014. }
  36015. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36016. import { Behavior } from "babylonjs/Behaviors/behavior";
  36017. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36018. import { ExponentialEase } from "babylonjs/Animations/easing";
  36019. import { Nullable } from "babylonjs/types";
  36020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36021. import { Vector3 } from "babylonjs/Maths/math";
  36022. /**
  36023. * 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.
  36024. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36025. */
  36026. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36027. /**
  36028. * Gets the name of the behavior.
  36029. */
  36030. readonly name: string;
  36031. private _mode;
  36032. private _radiusScale;
  36033. private _positionScale;
  36034. private _defaultElevation;
  36035. private _elevationReturnTime;
  36036. private _elevationReturnWaitTime;
  36037. private _zoomStopsAnimation;
  36038. private _framingTime;
  36039. /**
  36040. * The easing function used by animations
  36041. */
  36042. static EasingFunction: ExponentialEase;
  36043. /**
  36044. * The easing mode used by animations
  36045. */
  36046. static EasingMode: number;
  36047. /**
  36048. * Sets the current mode used by the behavior
  36049. */
  36050. /**
  36051. * Gets current mode used by the behavior.
  36052. */
  36053. mode: number;
  36054. /**
  36055. * Sets the scale applied to the radius (1 by default)
  36056. */
  36057. /**
  36058. * Gets the scale applied to the radius
  36059. */
  36060. radiusScale: number;
  36061. /**
  36062. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36063. */
  36064. /**
  36065. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36066. */
  36067. positionScale: number;
  36068. /**
  36069. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36070. * behaviour is triggered, in radians.
  36071. */
  36072. /**
  36073. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36074. * behaviour is triggered, in radians.
  36075. */
  36076. defaultElevation: number;
  36077. /**
  36078. * Sets the time (in milliseconds) taken to return to the default beta position.
  36079. * Negative value indicates camera should not return to default.
  36080. */
  36081. /**
  36082. * Gets the time (in milliseconds) taken to return to the default beta position.
  36083. * Negative value indicates camera should not return to default.
  36084. */
  36085. elevationReturnTime: number;
  36086. /**
  36087. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36088. */
  36089. /**
  36090. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36091. */
  36092. elevationReturnWaitTime: number;
  36093. /**
  36094. * Sets the flag that indicates if user zooming should stop animation.
  36095. */
  36096. /**
  36097. * Gets the flag that indicates if user zooming should stop animation.
  36098. */
  36099. zoomStopsAnimation: boolean;
  36100. /**
  36101. * Sets the transition time when framing the mesh, in milliseconds
  36102. */
  36103. /**
  36104. * Gets the transition time when framing the mesh, in milliseconds
  36105. */
  36106. framingTime: number;
  36107. /**
  36108. * Define if the behavior should automatically change the configured
  36109. * camera limits and sensibilities.
  36110. */
  36111. autoCorrectCameraLimitsAndSensibility: boolean;
  36112. private _onPrePointerObservableObserver;
  36113. private _onAfterCheckInputsObserver;
  36114. private _onMeshTargetChangedObserver;
  36115. private _attachedCamera;
  36116. private _isPointerDown;
  36117. private _lastInteractionTime;
  36118. /**
  36119. * Initializes the behavior.
  36120. */
  36121. init(): void;
  36122. /**
  36123. * Attaches the behavior to its arc rotate camera.
  36124. * @param camera Defines the camera to attach the behavior to
  36125. */
  36126. attach(camera: ArcRotateCamera): void;
  36127. /**
  36128. * Detaches the behavior from its current arc rotate camera.
  36129. */
  36130. detach(): void;
  36131. private _animatables;
  36132. private _betaIsAnimating;
  36133. private _betaTransition;
  36134. private _radiusTransition;
  36135. private _vectorTransition;
  36136. /**
  36137. * Targets the given mesh and updates zoom level accordingly.
  36138. * @param mesh The mesh to target.
  36139. * @param radius Optional. If a cached radius position already exists, overrides default.
  36140. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36141. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36142. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36143. */
  36144. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36145. /**
  36146. * Targets the given mesh with its children and updates zoom level accordingly.
  36147. * @param mesh The mesh to target.
  36148. * @param radius Optional. If a cached radius position already exists, overrides default.
  36149. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36150. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36151. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36152. */
  36153. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36154. /**
  36155. * Targets the given meshes with their children and updates zoom level accordingly.
  36156. * @param meshes The mesh to target.
  36157. * @param radius Optional. If a cached radius position already exists, overrides default.
  36158. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36159. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36160. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36161. */
  36162. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36163. /**
  36164. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36165. * @param minimumWorld Determines the smaller position of the bounding box extend
  36166. * @param maximumWorld Determines the bigger position of the bounding box extend
  36167. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36168. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36169. */
  36170. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36171. /**
  36172. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36173. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36174. * frustum width.
  36175. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36176. * to fully enclose the mesh in the viewing frustum.
  36177. */
  36178. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36179. /**
  36180. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36181. * is automatically returned to its default position (expected to be above ground plane).
  36182. */
  36183. private _maintainCameraAboveGround;
  36184. /**
  36185. * Returns the frustum slope based on the canvas ratio and camera FOV
  36186. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36187. */
  36188. private _getFrustumSlope;
  36189. /**
  36190. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36191. */
  36192. private _clearAnimationLocks;
  36193. /**
  36194. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36195. */
  36196. private _applyUserInteraction;
  36197. /**
  36198. * Stops and removes all animations that have been applied to the camera
  36199. */
  36200. stopAllAnimations(): void;
  36201. /**
  36202. * Gets a value indicating if the user is moving the camera
  36203. */
  36204. readonly isUserIsMoving: boolean;
  36205. /**
  36206. * The camera can move all the way towards the mesh.
  36207. */
  36208. static IgnoreBoundsSizeMode: number;
  36209. /**
  36210. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36211. */
  36212. static FitFrustumSidesMode: number;
  36213. }
  36214. }
  36215. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36216. import { Nullable } from "babylonjs/types";
  36217. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36218. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36219. /**
  36220. * Manage the pointers inputs to control an arc rotate camera.
  36221. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36222. */
  36223. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  36224. /**
  36225. * Defines the camera the input is attached to.
  36226. */
  36227. camera: ArcRotateCamera;
  36228. /**
  36229. * Defines the buttons associated with the input to handle camera move.
  36230. */
  36231. buttons: number[];
  36232. /**
  36233. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36234. */
  36235. angularSensibilityX: number;
  36236. /**
  36237. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36238. */
  36239. angularSensibilityY: number;
  36240. /**
  36241. * Defines the pointer pinch precision or how fast is the camera zooming.
  36242. */
  36243. pinchPrecision: number;
  36244. /**
  36245. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  36246. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36247. */
  36248. pinchDeltaPercentage: number;
  36249. /**
  36250. * Defines the pointer panning sensibility or how fast is the camera moving.
  36251. */
  36252. panningSensibility: number;
  36253. /**
  36254. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36255. */
  36256. multiTouchPanning: boolean;
  36257. /**
  36258. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  36259. */
  36260. multiTouchPanAndZoom: boolean;
  36261. /**
  36262. * Revers pinch action direction.
  36263. */
  36264. pinchInwards: boolean;
  36265. private _isPanClick;
  36266. private _pointerInput;
  36267. private _observer;
  36268. private _onMouseMove;
  36269. private _onGestureStart;
  36270. private _onGesture;
  36271. private _MSGestureHandler;
  36272. private _onLostFocus;
  36273. private _onContextMenu;
  36274. /**
  36275. * Attach the input controls to a specific dom element to get the input from.
  36276. * @param element Defines the element the controls should be listened from
  36277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36278. */
  36279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36280. /**
  36281. * Detach the current controls from the specified dom element.
  36282. * @param element Defines the element to stop listening the inputs from
  36283. */
  36284. detachControl(element: Nullable<HTMLElement>): void;
  36285. /**
  36286. * Gets the class name of the current intput.
  36287. * @returns the class name
  36288. */
  36289. getClassName(): string;
  36290. /**
  36291. * Get the friendly name associated with the input class.
  36292. * @returns the input friendly name
  36293. */
  36294. getSimpleName(): string;
  36295. }
  36296. }
  36297. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36298. import { Nullable } from "babylonjs/types";
  36299. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36300. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36301. /**
  36302. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36303. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36304. */
  36305. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36306. /**
  36307. * Defines the camera the input is attached to.
  36308. */
  36309. camera: ArcRotateCamera;
  36310. /**
  36311. * Defines the list of key codes associated with the up action (increase alpha)
  36312. */
  36313. keysUp: number[];
  36314. /**
  36315. * Defines the list of key codes associated with the down action (decrease alpha)
  36316. */
  36317. keysDown: number[];
  36318. /**
  36319. * Defines the list of key codes associated with the left action (increase beta)
  36320. */
  36321. keysLeft: number[];
  36322. /**
  36323. * Defines the list of key codes associated with the right action (decrease beta)
  36324. */
  36325. keysRight: number[];
  36326. /**
  36327. * Defines the list of key codes associated with the reset action.
  36328. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36329. */
  36330. keysReset: number[];
  36331. /**
  36332. * Defines the panning sensibility of the inputs.
  36333. * (How fast is the camera paning)
  36334. */
  36335. panningSensibility: number;
  36336. /**
  36337. * Defines the zooming sensibility of the inputs.
  36338. * (How fast is the camera zooming)
  36339. */
  36340. zoomingSensibility: number;
  36341. /**
  36342. * Defines wether maintaining the alt key down switch the movement mode from
  36343. * orientation to zoom.
  36344. */
  36345. useAltToZoom: boolean;
  36346. /**
  36347. * Rotation speed of the camera
  36348. */
  36349. angularSpeed: number;
  36350. private _keys;
  36351. private _ctrlPressed;
  36352. private _altPressed;
  36353. private _onCanvasBlurObserver;
  36354. private _onKeyboardObserver;
  36355. private _engine;
  36356. private _scene;
  36357. /**
  36358. * Attach the input controls to a specific dom element to get the input from.
  36359. * @param element Defines the element the controls should be listened from
  36360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36361. */
  36362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36363. /**
  36364. * Detach the current controls from the specified dom element.
  36365. * @param element Defines the element to stop listening the inputs from
  36366. */
  36367. detachControl(element: Nullable<HTMLElement>): void;
  36368. /**
  36369. * Update the current camera state depending on the inputs that have been used this frame.
  36370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36371. */
  36372. checkInputs(): void;
  36373. /**
  36374. * Gets the class name of the current intput.
  36375. * @returns the class name
  36376. */
  36377. getClassName(): string;
  36378. /**
  36379. * Get the friendly name associated with the input class.
  36380. * @returns the input friendly name
  36381. */
  36382. getSimpleName(): string;
  36383. }
  36384. }
  36385. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36386. import { Nullable } from "babylonjs/types";
  36387. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36388. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36389. /**
  36390. * Manage the mouse wheel inputs to control an arc rotate camera.
  36391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36392. */
  36393. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36394. /**
  36395. * Defines the camera the input is attached to.
  36396. */
  36397. camera: ArcRotateCamera;
  36398. /**
  36399. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36400. */
  36401. wheelPrecision: number;
  36402. /**
  36403. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36404. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36405. */
  36406. wheelDeltaPercentage: number;
  36407. private _wheel;
  36408. private _observer;
  36409. /**
  36410. * Attach the input controls to a specific dom element to get the input from.
  36411. * @param element Defines the element the controls should be listened from
  36412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36413. */
  36414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36415. /**
  36416. * Detach the current controls from the specified dom element.
  36417. * @param element Defines the element to stop listening the inputs from
  36418. */
  36419. detachControl(element: Nullable<HTMLElement>): void;
  36420. /**
  36421. * Gets the class name of the current intput.
  36422. * @returns the class name
  36423. */
  36424. getClassName(): string;
  36425. /**
  36426. * Get the friendly name associated with the input class.
  36427. * @returns the input friendly name
  36428. */
  36429. getSimpleName(): string;
  36430. }
  36431. }
  36432. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36433. import { Nullable } from "babylonjs/types";
  36434. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36435. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36436. /**
  36437. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36439. */
  36440. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36441. /**
  36442. * Defines the camera the input is attached to.
  36443. */
  36444. camera: ArcRotateCamera;
  36445. /**
  36446. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36447. */
  36448. alphaCorrection: number;
  36449. /**
  36450. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36451. */
  36452. gammaCorrection: number;
  36453. private _alpha;
  36454. private _gamma;
  36455. private _dirty;
  36456. private _deviceOrientationHandler;
  36457. /**
  36458. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36459. */
  36460. constructor();
  36461. /**
  36462. * Attach the input controls to a specific dom element to get the input from.
  36463. * @param element Defines the element the controls should be listened from
  36464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36465. */
  36466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36467. /** @hidden */
  36468. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36469. /**
  36470. * Update the current camera state depending on the inputs that have been used this frame.
  36471. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36472. */
  36473. checkInputs(): void;
  36474. /**
  36475. * Detach the current controls from the specified dom element.
  36476. * @param element Defines the element to stop listening the inputs from
  36477. */
  36478. detachControl(element: Nullable<HTMLElement>): void;
  36479. /**
  36480. * Gets the class name of the current intput.
  36481. * @returns the class name
  36482. */
  36483. getClassName(): string;
  36484. /**
  36485. * Get the friendly name associated with the input class.
  36486. * @returns the input friendly name
  36487. */
  36488. getSimpleName(): string;
  36489. }
  36490. }
  36491. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36492. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36493. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36494. /**
  36495. * Default Inputs manager for the ArcRotateCamera.
  36496. * It groups all the default supported inputs for ease of use.
  36497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36498. */
  36499. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36500. /**
  36501. * Instantiates a new ArcRotateCameraInputsManager.
  36502. * @param camera Defines the camera the inputs belong to
  36503. */
  36504. constructor(camera: ArcRotateCamera);
  36505. /**
  36506. * Add mouse wheel input support to the input manager.
  36507. * @returns the current input manager
  36508. */
  36509. addMouseWheel(): ArcRotateCameraInputsManager;
  36510. /**
  36511. * Add pointers input support to the input manager.
  36512. * @returns the current input manager
  36513. */
  36514. addPointers(): ArcRotateCameraInputsManager;
  36515. /**
  36516. * Add keyboard input support to the input manager.
  36517. * @returns the current input manager
  36518. */
  36519. addKeyboard(): ArcRotateCameraInputsManager;
  36520. /**
  36521. * Add orientation input support to the input manager.
  36522. * @returns the current input manager
  36523. */
  36524. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36525. }
  36526. }
  36527. declare module "babylonjs/Cameras/arcRotateCamera" {
  36528. import { Observable } from "babylonjs/Misc/observable";
  36529. import { Nullable } from "babylonjs/types";
  36530. import { Scene } from "babylonjs/scene";
  36531. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36533. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36534. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36535. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36536. import { Collider } from "babylonjs/Collisions/collider";
  36537. import { Camera } from "babylonjs/Cameras/camera";
  36538. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36539. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36540. /**
  36541. * This represents an orbital type of camera.
  36542. *
  36543. * 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.
  36544. * 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.
  36545. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36546. */
  36547. export class ArcRotateCamera extends TargetCamera {
  36548. /**
  36549. * Defines the rotation angle of the camera along the longitudinal axis.
  36550. */
  36551. alpha: number;
  36552. /**
  36553. * Defines the rotation angle of the camera along the latitudinal axis.
  36554. */
  36555. beta: number;
  36556. /**
  36557. * Defines the radius of the camera from it s target point.
  36558. */
  36559. radius: number;
  36560. protected _target: Vector3;
  36561. protected _targetHost: Nullable<AbstractMesh>;
  36562. /**
  36563. * Defines the target point of the camera.
  36564. * The camera looks towards it form the radius distance.
  36565. */
  36566. target: Vector3;
  36567. /**
  36568. * Current inertia value on the longitudinal axis.
  36569. * The bigger this number the longer it will take for the camera to stop.
  36570. */
  36571. inertialAlphaOffset: number;
  36572. /**
  36573. * Current inertia value on the latitudinal axis.
  36574. * The bigger this number the longer it will take for the camera to stop.
  36575. */
  36576. inertialBetaOffset: number;
  36577. /**
  36578. * Current inertia value on the radius axis.
  36579. * The bigger this number the longer it will take for the camera to stop.
  36580. */
  36581. inertialRadiusOffset: number;
  36582. /**
  36583. * Minimum allowed angle on the longitudinal axis.
  36584. * This can help limiting how the Camera is able to move in the scene.
  36585. */
  36586. lowerAlphaLimit: Nullable<number>;
  36587. /**
  36588. * Maximum allowed angle on the longitudinal axis.
  36589. * This can help limiting how the Camera is able to move in the scene.
  36590. */
  36591. upperAlphaLimit: Nullable<number>;
  36592. /**
  36593. * Minimum allowed angle on the latitudinal axis.
  36594. * This can help limiting how the Camera is able to move in the scene.
  36595. */
  36596. lowerBetaLimit: number;
  36597. /**
  36598. * Maximum allowed angle on the latitudinal axis.
  36599. * This can help limiting how the Camera is able to move in the scene.
  36600. */
  36601. upperBetaLimit: number;
  36602. /**
  36603. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36604. * This can help limiting how the Camera is able to move in the scene.
  36605. */
  36606. lowerRadiusLimit: Nullable<number>;
  36607. /**
  36608. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36609. * This can help limiting how the Camera is able to move in the scene.
  36610. */
  36611. upperRadiusLimit: Nullable<number>;
  36612. /**
  36613. * Defines the current inertia value used during panning of the camera along the X axis.
  36614. */
  36615. inertialPanningX: number;
  36616. /**
  36617. * Defines the current inertia value used during panning of the camera along the Y axis.
  36618. */
  36619. inertialPanningY: number;
  36620. /**
  36621. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36622. * Basically if your fingers moves away from more than this distance you will be considered
  36623. * in pinch mode.
  36624. */
  36625. pinchToPanMaxDistance: number;
  36626. /**
  36627. * Defines the maximum distance the camera can pan.
  36628. * This could help keeping the cammera always in your scene.
  36629. */
  36630. panningDistanceLimit: Nullable<number>;
  36631. /**
  36632. * Defines the target of the camera before paning.
  36633. */
  36634. panningOriginTarget: Vector3;
  36635. /**
  36636. * Defines the value of the inertia used during panning.
  36637. * 0 would mean stop inertia and one would mean no decelleration at all.
  36638. */
  36639. panningInertia: number;
  36640. /**
  36641. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36642. */
  36643. angularSensibilityX: number;
  36644. /**
  36645. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36646. */
  36647. angularSensibilityY: number;
  36648. /**
  36649. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36650. */
  36651. pinchPrecision: number;
  36652. /**
  36653. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36654. * It will be used instead of pinchDeltaPrecision if different from 0.
  36655. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36656. */
  36657. pinchDeltaPercentage: number;
  36658. /**
  36659. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36660. */
  36661. panningSensibility: number;
  36662. /**
  36663. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36664. */
  36665. keysUp: number[];
  36666. /**
  36667. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36668. */
  36669. keysDown: number[];
  36670. /**
  36671. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36672. */
  36673. keysLeft: number[];
  36674. /**
  36675. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36676. */
  36677. keysRight: number[];
  36678. /**
  36679. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36680. */
  36681. wheelPrecision: number;
  36682. /**
  36683. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36684. * It will be used instead of pinchDeltaPrecision if different from 0.
  36685. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36686. */
  36687. wheelDeltaPercentage: number;
  36688. /**
  36689. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36690. */
  36691. zoomOnFactor: number;
  36692. /**
  36693. * Defines a screen offset for the camera position.
  36694. */
  36695. targetScreenOffset: Vector2;
  36696. /**
  36697. * Allows the camera to be completely reversed.
  36698. * If false the camera can not arrive upside down.
  36699. */
  36700. allowUpsideDown: boolean;
  36701. /**
  36702. * Define if double tap/click is used to restore the previously saved state of the camera.
  36703. */
  36704. useInputToRestoreState: boolean;
  36705. /** @hidden */
  36706. _viewMatrix: Matrix;
  36707. /** @hidden */
  36708. _useCtrlForPanning: boolean;
  36709. /** @hidden */
  36710. _panningMouseButton: number;
  36711. /**
  36712. * Defines the input associated to the camera.
  36713. */
  36714. inputs: ArcRotateCameraInputsManager;
  36715. /** @hidden */
  36716. _reset: () => void;
  36717. /**
  36718. * Defines the allowed panning axis.
  36719. */
  36720. panningAxis: Vector3;
  36721. protected _localDirection: Vector3;
  36722. protected _transformedDirection: Vector3;
  36723. private _bouncingBehavior;
  36724. /**
  36725. * Gets the bouncing behavior of the camera if it has been enabled.
  36726. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36727. */
  36728. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36729. /**
  36730. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36731. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36732. */
  36733. useBouncingBehavior: boolean;
  36734. private _framingBehavior;
  36735. /**
  36736. * Gets the framing behavior of the camera if it has been enabled.
  36737. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36738. */
  36739. readonly framingBehavior: Nullable<FramingBehavior>;
  36740. /**
  36741. * Defines if the framing behavior of the camera is enabled on the camera.
  36742. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36743. */
  36744. useFramingBehavior: boolean;
  36745. private _autoRotationBehavior;
  36746. /**
  36747. * Gets the auto rotation behavior of the camera if it has been enabled.
  36748. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36749. */
  36750. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36751. /**
  36752. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36753. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36754. */
  36755. useAutoRotationBehavior: boolean;
  36756. /**
  36757. * Observable triggered when the mesh target has been changed on the camera.
  36758. */
  36759. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36760. /**
  36761. * Event raised when the camera is colliding with a mesh.
  36762. */
  36763. onCollide: (collidedMesh: AbstractMesh) => void;
  36764. /**
  36765. * Defines whether the camera should check collision with the objects oh the scene.
  36766. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36767. */
  36768. checkCollisions: boolean;
  36769. /**
  36770. * Defines the collision radius of the camera.
  36771. * This simulates a sphere around the camera.
  36772. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36773. */
  36774. collisionRadius: Vector3;
  36775. protected _collider: Collider;
  36776. protected _previousPosition: Vector3;
  36777. protected _collisionVelocity: Vector3;
  36778. protected _newPosition: Vector3;
  36779. protected _previousAlpha: number;
  36780. protected _previousBeta: number;
  36781. protected _previousRadius: number;
  36782. protected _collisionTriggered: boolean;
  36783. protected _targetBoundingCenter: Nullable<Vector3>;
  36784. private _computationVector;
  36785. private _tempAxisVector;
  36786. private _tempAxisRotationMatrix;
  36787. /**
  36788. * Instantiates a new ArcRotateCamera in a given scene
  36789. * @param name Defines the name of the camera
  36790. * @param alpha Defines the camera rotation along the logitudinal axis
  36791. * @param beta Defines the camera rotation along the latitudinal axis
  36792. * @param radius Defines the camera distance from its target
  36793. * @param target Defines the camera target
  36794. * @param scene Defines the scene the camera belongs to
  36795. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36796. */
  36797. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36798. /** @hidden */
  36799. _initCache(): void;
  36800. /** @hidden */
  36801. _updateCache(ignoreParentClass?: boolean): void;
  36802. protected _getTargetPosition(): Vector3;
  36803. private _storedAlpha;
  36804. private _storedBeta;
  36805. private _storedRadius;
  36806. private _storedTarget;
  36807. /**
  36808. * Stores the current state of the camera (alpha, beta, radius and target)
  36809. * @returns the camera itself
  36810. */
  36811. storeState(): Camera;
  36812. /**
  36813. * @hidden
  36814. * Restored camera state. You must call storeState() first
  36815. */
  36816. _restoreStateValues(): boolean;
  36817. /** @hidden */
  36818. _isSynchronizedViewMatrix(): boolean;
  36819. /**
  36820. * Attached controls to the current camera.
  36821. * @param element Defines the element the controls should be listened from
  36822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36823. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36824. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36825. */
  36826. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36827. /**
  36828. * Detach the current controls from the camera.
  36829. * The camera will stop reacting to inputs.
  36830. * @param element Defines the element to stop listening the inputs from
  36831. */
  36832. detachControl(element: HTMLElement): void;
  36833. /** @hidden */
  36834. _checkInputs(): void;
  36835. protected _checkLimits(): void;
  36836. /**
  36837. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  36838. */
  36839. rebuildAnglesAndRadius(): void;
  36840. /**
  36841. * Use a position to define the current camera related information like aplha, beta and radius
  36842. * @param position Defines the position to set the camera at
  36843. */
  36844. setPosition(position: Vector3): void;
  36845. /**
  36846. * Defines the target the camera should look at.
  36847. * This will automatically adapt alpha beta and radius to fit within the new target.
  36848. * @param target Defines the new target as a Vector or a mesh
  36849. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36850. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36851. */
  36852. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36853. /** @hidden */
  36854. _getViewMatrix(): Matrix;
  36855. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36856. /**
  36857. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36858. * @param meshes Defines the mesh to zoom on
  36859. * @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)
  36860. */
  36861. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36862. /**
  36863. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36864. * The target will be changed but the radius
  36865. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36866. * @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)
  36867. */
  36868. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36869. min: Vector3;
  36870. max: Vector3;
  36871. distance: number;
  36872. }, doNotUpdateMaxZ?: boolean): void;
  36873. /**
  36874. * @override
  36875. * Override Camera.createRigCamera
  36876. */
  36877. createRigCamera(name: string, cameraIndex: number): Camera;
  36878. /**
  36879. * @hidden
  36880. * @override
  36881. * Override Camera._updateRigCameras
  36882. */
  36883. _updateRigCameras(): void;
  36884. /**
  36885. * Destroy the camera and release the current resources hold by it.
  36886. */
  36887. dispose(): void;
  36888. /**
  36889. * Gets the current object class name.
  36890. * @return the class name
  36891. */
  36892. getClassName(): string;
  36893. }
  36894. }
  36895. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36896. import { Behavior } from "babylonjs/Behaviors/behavior";
  36897. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36898. /**
  36899. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36900. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36901. */
  36902. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36903. /**
  36904. * Gets the name of the behavior.
  36905. */
  36906. readonly name: string;
  36907. private _zoomStopsAnimation;
  36908. private _idleRotationSpeed;
  36909. private _idleRotationWaitTime;
  36910. private _idleRotationSpinupTime;
  36911. /**
  36912. * Sets the flag that indicates if user zooming should stop animation.
  36913. */
  36914. /**
  36915. * Gets the flag that indicates if user zooming should stop animation.
  36916. */
  36917. zoomStopsAnimation: boolean;
  36918. /**
  36919. * Sets the default speed at which the camera rotates around the model.
  36920. */
  36921. /**
  36922. * Gets the default speed at which the camera rotates around the model.
  36923. */
  36924. idleRotationSpeed: number;
  36925. /**
  36926. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36927. */
  36928. /**
  36929. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36930. */
  36931. idleRotationWaitTime: number;
  36932. /**
  36933. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36934. */
  36935. /**
  36936. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36937. */
  36938. idleRotationSpinupTime: number;
  36939. /**
  36940. * Gets a value indicating if the camera is currently rotating because of this behavior
  36941. */
  36942. readonly rotationInProgress: boolean;
  36943. private _onPrePointerObservableObserver;
  36944. private _onAfterCheckInputsObserver;
  36945. private _attachedCamera;
  36946. private _isPointerDown;
  36947. private _lastFrameTime;
  36948. private _lastInteractionTime;
  36949. private _cameraRotationSpeed;
  36950. /**
  36951. * Initializes the behavior.
  36952. */
  36953. init(): void;
  36954. /**
  36955. * Attaches the behavior to its arc rotate camera.
  36956. * @param camera Defines the camera to attach the behavior to
  36957. */
  36958. attach(camera: ArcRotateCamera): void;
  36959. /**
  36960. * Detaches the behavior from its current arc rotate camera.
  36961. */
  36962. detach(): void;
  36963. /**
  36964. * Returns true if user is scrolling.
  36965. * @return true if user is scrolling.
  36966. */
  36967. private _userIsZooming;
  36968. private _lastFrameRadius;
  36969. private _shouldAnimationStopForInteraction;
  36970. /**
  36971. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36972. */
  36973. private _applyUserInteraction;
  36974. private _userIsMoving;
  36975. }
  36976. }
  36977. declare module "babylonjs/Behaviors/Cameras/index" {
  36978. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36979. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36980. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36981. }
  36982. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36983. import { Mesh } from "babylonjs/Meshes/mesh";
  36984. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36985. import { Behavior } from "babylonjs/Behaviors/behavior";
  36986. /**
  36987. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36988. */
  36989. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36990. private ui;
  36991. /**
  36992. * The name of the behavior
  36993. */
  36994. name: string;
  36995. /**
  36996. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36997. */
  36998. distanceAwayFromFace: number;
  36999. /**
  37000. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37001. */
  37002. distanceAwayFromBottomOfFace: number;
  37003. private _faceVectors;
  37004. private _target;
  37005. private _scene;
  37006. private _onRenderObserver;
  37007. private _tmpMatrix;
  37008. private _tmpVector;
  37009. /**
  37010. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37011. * @param ui The transform node that should be attched to the mesh
  37012. */
  37013. constructor(ui: TransformNode);
  37014. /**
  37015. * Initializes the behavior
  37016. */
  37017. init(): void;
  37018. private _closestFace;
  37019. private _zeroVector;
  37020. private _lookAtTmpMatrix;
  37021. private _lookAtToRef;
  37022. /**
  37023. * Attaches the AttachToBoxBehavior to the passed in mesh
  37024. * @param target The mesh that the specified node will be attached to
  37025. */
  37026. attach(target: Mesh): void;
  37027. /**
  37028. * Detaches the behavior from the mesh
  37029. */
  37030. detach(): void;
  37031. }
  37032. }
  37033. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37034. import { Behavior } from "babylonjs/Behaviors/behavior";
  37035. import { Mesh } from "babylonjs/Meshes/mesh";
  37036. /**
  37037. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37038. */
  37039. export class FadeInOutBehavior implements Behavior<Mesh> {
  37040. /**
  37041. * Time in milliseconds to delay before fading in (Default: 0)
  37042. */
  37043. delay: number;
  37044. /**
  37045. * Time in milliseconds for the mesh to fade in (Default: 300)
  37046. */
  37047. fadeInTime: number;
  37048. private _millisecondsPerFrame;
  37049. private _hovered;
  37050. private _hoverValue;
  37051. private _ownerNode;
  37052. /**
  37053. * Instatiates the FadeInOutBehavior
  37054. */
  37055. constructor();
  37056. /**
  37057. * The name of the behavior
  37058. */
  37059. readonly name: string;
  37060. /**
  37061. * Initializes the behavior
  37062. */
  37063. init(): void;
  37064. /**
  37065. * Attaches the fade behavior on the passed in mesh
  37066. * @param ownerNode The mesh that will be faded in/out once attached
  37067. */
  37068. attach(ownerNode: Mesh): void;
  37069. /**
  37070. * Detaches the behavior from the mesh
  37071. */
  37072. detach(): void;
  37073. /**
  37074. * Triggers the mesh to begin fading in or out
  37075. * @param value if the object should fade in or out (true to fade in)
  37076. */
  37077. fadeIn(value: boolean): void;
  37078. private _update;
  37079. private _setAllVisibility;
  37080. }
  37081. }
  37082. declare module "babylonjs/Misc/pivotTools" {
  37083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37084. /**
  37085. * Class containing a set of static utilities functions for managing Pivots
  37086. * @hidden
  37087. */
  37088. export class PivotTools {
  37089. private static _PivotCached;
  37090. private static _OldPivotPoint;
  37091. private static _PivotTranslation;
  37092. private static _PivotTmpVector;
  37093. /** @hidden */
  37094. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37095. /** @hidden */
  37096. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37097. }
  37098. }
  37099. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37100. import { Behavior } from "babylonjs/Behaviors/behavior";
  37101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37102. import { Observable } from "babylonjs/Misc/observable";
  37103. import { Vector3 } from "babylonjs/Maths/math";
  37104. import { Ray } from "babylonjs/Culling/ray";
  37105. /**
  37106. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37107. */
  37108. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37109. private static _AnyMouseID;
  37110. private _attachedNode;
  37111. private _dragPlane;
  37112. private _scene;
  37113. private _pointerObserver;
  37114. private _beforeRenderObserver;
  37115. private static _planeScene;
  37116. /**
  37117. * 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)
  37118. */
  37119. maxDragAngle: number;
  37120. /**
  37121. * @hidden
  37122. */
  37123. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37124. /**
  37125. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37126. */
  37127. currentDraggingPointerID: number;
  37128. /**
  37129. * The last position where the pointer hit the drag plane in world space
  37130. */
  37131. lastDragPosition: Vector3;
  37132. /**
  37133. * If the behavior is currently in a dragging state
  37134. */
  37135. dragging: boolean;
  37136. /**
  37137. * 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)
  37138. */
  37139. dragDeltaRatio: number;
  37140. /**
  37141. * If the drag plane orientation should be updated during the dragging (Default: true)
  37142. */
  37143. updateDragPlane: boolean;
  37144. private _debugMode;
  37145. private _moving;
  37146. /**
  37147. * Fires each time the attached mesh is dragged with the pointer
  37148. * * delta between last drag position and current drag position in world space
  37149. * * dragDistance along the drag axis
  37150. * * dragPlaneNormal normal of the current drag plane used during the drag
  37151. * * dragPlanePoint in world space where the drag intersects the drag plane
  37152. */
  37153. onDragObservable: Observable<{
  37154. delta: Vector3;
  37155. dragPlanePoint: Vector3;
  37156. dragPlaneNormal: Vector3;
  37157. dragDistance: number;
  37158. pointerId: number;
  37159. }>;
  37160. /**
  37161. * Fires each time a drag begins (eg. mouse down on mesh)
  37162. */
  37163. onDragStartObservable: Observable<{
  37164. dragPlanePoint: Vector3;
  37165. pointerId: number;
  37166. }>;
  37167. /**
  37168. * Fires each time a drag ends (eg. mouse release after drag)
  37169. */
  37170. onDragEndObservable: Observable<{
  37171. dragPlanePoint: Vector3;
  37172. pointerId: number;
  37173. }>;
  37174. /**
  37175. * If the attached mesh should be moved when dragged
  37176. */
  37177. moveAttached: boolean;
  37178. /**
  37179. * If the drag behavior will react to drag events (Default: true)
  37180. */
  37181. enabled: boolean;
  37182. /**
  37183. * If camera controls should be detached during the drag
  37184. */
  37185. detachCameraControls: boolean;
  37186. /**
  37187. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37188. */
  37189. useObjectOrienationForDragging: boolean;
  37190. private _options;
  37191. /**
  37192. * Creates a pointer drag behavior that can be attached to a mesh
  37193. * @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)
  37194. */
  37195. constructor(options?: {
  37196. dragAxis?: Vector3;
  37197. dragPlaneNormal?: Vector3;
  37198. });
  37199. /**
  37200. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37201. */
  37202. validateDrag: (targetPosition: Vector3) => boolean;
  37203. /**
  37204. * The name of the behavior
  37205. */
  37206. readonly name: string;
  37207. /**
  37208. * Initializes the behavior
  37209. */
  37210. init(): void;
  37211. private _tmpVector;
  37212. private _alternatePickedPoint;
  37213. private _worldDragAxis;
  37214. private _targetPosition;
  37215. private _attachedElement;
  37216. /**
  37217. * Attaches the drag behavior the passed in mesh
  37218. * @param ownerNode The mesh that will be dragged around once attached
  37219. */
  37220. attach(ownerNode: AbstractMesh): void;
  37221. /**
  37222. * Force relase the drag action by code.
  37223. */
  37224. releaseDrag(): void;
  37225. private _startDragRay;
  37226. private _lastPointerRay;
  37227. /**
  37228. * Simulates the start of a pointer drag event on the behavior
  37229. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37230. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37231. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37232. */
  37233. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37234. private _startDrag;
  37235. private _dragDelta;
  37236. private _moveDrag;
  37237. private _pickWithRayOnDragPlane;
  37238. private _pointA;
  37239. private _pointB;
  37240. private _pointC;
  37241. private _lineA;
  37242. private _lineB;
  37243. private _localAxis;
  37244. private _lookAt;
  37245. private _updateDragPlanePosition;
  37246. /**
  37247. * Detaches the behavior from the mesh
  37248. */
  37249. detach(): void;
  37250. }
  37251. }
  37252. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37253. import { Mesh } from "babylonjs/Meshes/mesh";
  37254. import { Behavior } from "babylonjs/Behaviors/behavior";
  37255. /**
  37256. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37257. */
  37258. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37259. private _dragBehaviorA;
  37260. private _dragBehaviorB;
  37261. private _startDistance;
  37262. private _initialScale;
  37263. private _targetScale;
  37264. private _ownerNode;
  37265. private _sceneRenderObserver;
  37266. /**
  37267. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37268. */
  37269. constructor();
  37270. /**
  37271. * The name of the behavior
  37272. */
  37273. readonly name: string;
  37274. /**
  37275. * Initializes the behavior
  37276. */
  37277. init(): void;
  37278. private _getCurrentDistance;
  37279. /**
  37280. * Attaches the scale behavior the passed in mesh
  37281. * @param ownerNode The mesh that will be scaled around once attached
  37282. */
  37283. attach(ownerNode: Mesh): void;
  37284. /**
  37285. * Detaches the behavior from the mesh
  37286. */
  37287. detach(): void;
  37288. }
  37289. }
  37290. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37291. import { Behavior } from "babylonjs/Behaviors/behavior";
  37292. import { Mesh } from "babylonjs/Meshes/mesh";
  37293. import { Observable } from "babylonjs/Misc/observable";
  37294. /**
  37295. * 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
  37296. */
  37297. export class SixDofDragBehavior implements Behavior<Mesh> {
  37298. private static _virtualScene;
  37299. private _ownerNode;
  37300. private _sceneRenderObserver;
  37301. private _scene;
  37302. private _targetPosition;
  37303. private _virtualOriginMesh;
  37304. private _virtualDragMesh;
  37305. private _pointerObserver;
  37306. private _moving;
  37307. private _startingOrientation;
  37308. /**
  37309. * 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)
  37310. */
  37311. private zDragFactor;
  37312. /**
  37313. * If the object should rotate to face the drag origin
  37314. */
  37315. rotateDraggedObject: boolean;
  37316. /**
  37317. * If the behavior is currently in a dragging state
  37318. */
  37319. dragging: boolean;
  37320. /**
  37321. * 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)
  37322. */
  37323. dragDeltaRatio: number;
  37324. /**
  37325. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37326. */
  37327. currentDraggingPointerID: number;
  37328. /**
  37329. * If camera controls should be detached during the drag
  37330. */
  37331. detachCameraControls: boolean;
  37332. /**
  37333. * Fires each time a drag starts
  37334. */
  37335. onDragStartObservable: Observable<{}>;
  37336. /**
  37337. * Fires each time a drag ends (eg. mouse release after drag)
  37338. */
  37339. onDragEndObservable: Observable<{}>;
  37340. /**
  37341. * 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
  37342. */
  37343. constructor();
  37344. /**
  37345. * The name of the behavior
  37346. */
  37347. readonly name: string;
  37348. /**
  37349. * Initializes the behavior
  37350. */
  37351. init(): void;
  37352. /**
  37353. * Attaches the scale behavior the passed in mesh
  37354. * @param ownerNode The mesh that will be scaled around once attached
  37355. */
  37356. attach(ownerNode: Mesh): void;
  37357. /**
  37358. * Detaches the behavior from the mesh
  37359. */
  37360. detach(): void;
  37361. }
  37362. }
  37363. declare module "babylonjs/Behaviors/Meshes/index" {
  37364. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37365. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37366. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37367. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37368. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37369. }
  37370. declare module "babylonjs/Behaviors/index" {
  37371. export * from "babylonjs/Behaviors/behavior";
  37372. export * from "babylonjs/Behaviors/Cameras/index";
  37373. export * from "babylonjs/Behaviors/Meshes/index";
  37374. }
  37375. declare module "babylonjs/Bones/boneIKController" {
  37376. import { Bone } from "babylonjs/Bones/bone";
  37377. import { Vector3 } from "babylonjs/Maths/math";
  37378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37379. import { Nullable } from "babylonjs/types";
  37380. /**
  37381. * Class used to apply inverse kinematics to bones
  37382. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37383. */
  37384. export class BoneIKController {
  37385. private static _tmpVecs;
  37386. private static _tmpQuat;
  37387. private static _tmpMats;
  37388. /**
  37389. * Gets or sets the target mesh
  37390. */
  37391. targetMesh: AbstractMesh;
  37392. /** Gets or sets the mesh used as pole */
  37393. poleTargetMesh: AbstractMesh;
  37394. /**
  37395. * Gets or sets the bone used as pole
  37396. */
  37397. poleTargetBone: Nullable<Bone>;
  37398. /**
  37399. * Gets or sets the target position
  37400. */
  37401. targetPosition: Vector3;
  37402. /**
  37403. * Gets or sets the pole target position
  37404. */
  37405. poleTargetPosition: Vector3;
  37406. /**
  37407. * Gets or sets the pole target local offset
  37408. */
  37409. poleTargetLocalOffset: Vector3;
  37410. /**
  37411. * Gets or sets the pole angle
  37412. */
  37413. poleAngle: number;
  37414. /**
  37415. * Gets or sets the mesh associated with the controller
  37416. */
  37417. mesh: AbstractMesh;
  37418. /**
  37419. * 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)
  37420. */
  37421. slerpAmount: number;
  37422. private _bone1Quat;
  37423. private _bone1Mat;
  37424. private _bone2Ang;
  37425. private _bone1;
  37426. private _bone2;
  37427. private _bone1Length;
  37428. private _bone2Length;
  37429. private _maxAngle;
  37430. private _maxReach;
  37431. private _rightHandedSystem;
  37432. private _bendAxis;
  37433. private _slerping;
  37434. private _adjustRoll;
  37435. /**
  37436. * Gets or sets maximum allowed angle
  37437. */
  37438. maxAngle: number;
  37439. /**
  37440. * Creates a new BoneIKController
  37441. * @param mesh defines the mesh to control
  37442. * @param bone defines the bone to control
  37443. * @param options defines options to set up the controller
  37444. */
  37445. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37446. targetMesh?: AbstractMesh;
  37447. poleTargetMesh?: AbstractMesh;
  37448. poleTargetBone?: Bone;
  37449. poleTargetLocalOffset?: Vector3;
  37450. poleAngle?: number;
  37451. bendAxis?: Vector3;
  37452. maxAngle?: number;
  37453. slerpAmount?: number;
  37454. });
  37455. private _setMaxAngle;
  37456. /**
  37457. * Force the controller to update the bones
  37458. */
  37459. update(): void;
  37460. }
  37461. }
  37462. declare module "babylonjs/Bones/boneLookController" {
  37463. import { Vector3, Space } from "babylonjs/Maths/math";
  37464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37465. import { Bone } from "babylonjs/Bones/bone";
  37466. /**
  37467. * Class used to make a bone look toward a point in space
  37468. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37469. */
  37470. export class BoneLookController {
  37471. private static _tmpVecs;
  37472. private static _tmpQuat;
  37473. private static _tmpMats;
  37474. /**
  37475. * The target Vector3 that the bone will look at
  37476. */
  37477. target: Vector3;
  37478. /**
  37479. * The mesh that the bone is attached to
  37480. */
  37481. mesh: AbstractMesh;
  37482. /**
  37483. * The bone that will be looking to the target
  37484. */
  37485. bone: Bone;
  37486. /**
  37487. * The up axis of the coordinate system that is used when the bone is rotated
  37488. */
  37489. upAxis: Vector3;
  37490. /**
  37491. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37492. */
  37493. upAxisSpace: Space;
  37494. /**
  37495. * Used to make an adjustment to the yaw of the bone
  37496. */
  37497. adjustYaw: number;
  37498. /**
  37499. * Used to make an adjustment to the pitch of the bone
  37500. */
  37501. adjustPitch: number;
  37502. /**
  37503. * Used to make an adjustment to the roll of the bone
  37504. */
  37505. adjustRoll: number;
  37506. /**
  37507. * 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)
  37508. */
  37509. slerpAmount: number;
  37510. private _minYaw;
  37511. private _maxYaw;
  37512. private _minPitch;
  37513. private _maxPitch;
  37514. private _minYawSin;
  37515. private _minYawCos;
  37516. private _maxYawSin;
  37517. private _maxYawCos;
  37518. private _midYawConstraint;
  37519. private _minPitchTan;
  37520. private _maxPitchTan;
  37521. private _boneQuat;
  37522. private _slerping;
  37523. private _transformYawPitch;
  37524. private _transformYawPitchInv;
  37525. private _firstFrameSkipped;
  37526. private _yawRange;
  37527. private _fowardAxis;
  37528. /**
  37529. * Gets or sets the minimum yaw angle that the bone can look to
  37530. */
  37531. minYaw: number;
  37532. /**
  37533. * Gets or sets the maximum yaw angle that the bone can look to
  37534. */
  37535. maxYaw: number;
  37536. /**
  37537. * Gets or sets the minimum pitch angle that the bone can look to
  37538. */
  37539. minPitch: number;
  37540. /**
  37541. * Gets or sets the maximum pitch angle that the bone can look to
  37542. */
  37543. maxPitch: number;
  37544. /**
  37545. * Create a BoneLookController
  37546. * @param mesh the mesh that the bone belongs to
  37547. * @param bone the bone that will be looking to the target
  37548. * @param target the target Vector3 to look at
  37549. * @param settings optional settings:
  37550. * * maxYaw: the maximum angle the bone will yaw to
  37551. * * minYaw: the minimum angle the bone will yaw to
  37552. * * maxPitch: the maximum angle the bone will pitch to
  37553. * * minPitch: the minimum angle the bone will yaw to
  37554. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37555. * * upAxis: the up axis of the coordinate system
  37556. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37557. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37558. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37559. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37560. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37561. * * adjustRoll: used to make an adjustment to the roll of the bone
  37562. **/
  37563. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37564. maxYaw?: number;
  37565. minYaw?: number;
  37566. maxPitch?: number;
  37567. minPitch?: number;
  37568. slerpAmount?: number;
  37569. upAxis?: Vector3;
  37570. upAxisSpace?: Space;
  37571. yawAxis?: Vector3;
  37572. pitchAxis?: Vector3;
  37573. adjustYaw?: number;
  37574. adjustPitch?: number;
  37575. adjustRoll?: number;
  37576. });
  37577. /**
  37578. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37579. */
  37580. update(): void;
  37581. private _getAngleDiff;
  37582. private _getAngleBetween;
  37583. private _isAngleBetween;
  37584. }
  37585. }
  37586. declare module "babylonjs/Bones/index" {
  37587. export * from "babylonjs/Bones/bone";
  37588. export * from "babylonjs/Bones/boneIKController";
  37589. export * from "babylonjs/Bones/boneLookController";
  37590. export * from "babylonjs/Bones/skeleton";
  37591. }
  37592. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37593. import { Nullable } from "babylonjs/types";
  37594. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37595. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37596. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37597. /**
  37598. * Manage the gamepad inputs to control an arc rotate camera.
  37599. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37600. */
  37601. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37602. /**
  37603. * Defines the camera the input is attached to.
  37604. */
  37605. camera: ArcRotateCamera;
  37606. /**
  37607. * Defines the gamepad the input is gathering event from.
  37608. */
  37609. gamepad: Nullable<Gamepad>;
  37610. /**
  37611. * Defines the gamepad rotation sensiblity.
  37612. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37613. */
  37614. gamepadRotationSensibility: number;
  37615. /**
  37616. * Defines the gamepad move sensiblity.
  37617. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37618. */
  37619. gamepadMoveSensibility: number;
  37620. private _onGamepadConnectedObserver;
  37621. private _onGamepadDisconnectedObserver;
  37622. /**
  37623. * Attach the input controls to a specific dom element to get the input from.
  37624. * @param element Defines the element the controls should be listened from
  37625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37626. */
  37627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37628. /**
  37629. * Detach the current controls from the specified dom element.
  37630. * @param element Defines the element to stop listening the inputs from
  37631. */
  37632. detachControl(element: Nullable<HTMLElement>): void;
  37633. /**
  37634. * Update the current camera state depending on the inputs that have been used this frame.
  37635. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37636. */
  37637. checkInputs(): void;
  37638. /**
  37639. * Gets the class name of the current intput.
  37640. * @returns the class name
  37641. */
  37642. getClassName(): string;
  37643. /**
  37644. * Get the friendly name associated with the input class.
  37645. * @returns the input friendly name
  37646. */
  37647. getSimpleName(): string;
  37648. }
  37649. }
  37650. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37651. import { Nullable } from "babylonjs/types";
  37652. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37653. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37654. /**
  37655. * Listen to mouse events to control the camera.
  37656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37657. */
  37658. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37659. /**
  37660. * Defines the camera the input is attached to.
  37661. */
  37662. camera: FlyCamera;
  37663. /**
  37664. * Defines if touch is enabled. (Default is true.)
  37665. */
  37666. touchEnabled: boolean;
  37667. /**
  37668. * Defines the buttons associated with the input to handle camera rotation.
  37669. */
  37670. buttons: number[];
  37671. /**
  37672. * Assign buttons for Yaw control.
  37673. */
  37674. buttonsYaw: number[];
  37675. /**
  37676. * Assign buttons for Pitch control.
  37677. */
  37678. buttonsPitch: number[];
  37679. /**
  37680. * Assign buttons for Roll control.
  37681. */
  37682. buttonsRoll: number[];
  37683. /**
  37684. * Detect if any button is being pressed while mouse is moved.
  37685. * -1 = Mouse locked.
  37686. * 0 = Left button.
  37687. * 1 = Middle Button.
  37688. * 2 = Right Button.
  37689. */
  37690. activeButton: number;
  37691. /**
  37692. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37693. * Higher values reduce its sensitivity.
  37694. */
  37695. angularSensibility: number;
  37696. private _mousemoveCallback;
  37697. private _observer;
  37698. private _rollObserver;
  37699. private previousPosition;
  37700. private noPreventDefault;
  37701. private element;
  37702. /**
  37703. * Listen to mouse events to control the camera.
  37704. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37706. */
  37707. constructor(touchEnabled?: boolean);
  37708. /**
  37709. * Attach the mouse control to the HTML DOM element.
  37710. * @param element Defines the element that listens to the input events.
  37711. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37712. */
  37713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37714. /**
  37715. * Detach the current controls from the specified dom element.
  37716. * @param element Defines the element to stop listening the inputs from
  37717. */
  37718. detachControl(element: Nullable<HTMLElement>): void;
  37719. /**
  37720. * Gets the class name of the current input.
  37721. * @returns the class name.
  37722. */
  37723. getClassName(): string;
  37724. /**
  37725. * Get the friendly name associated with the input class.
  37726. * @returns the input's friendly name.
  37727. */
  37728. getSimpleName(): string;
  37729. private _pointerInput;
  37730. private _onMouseMove;
  37731. /**
  37732. * Rotate camera by mouse offset.
  37733. */
  37734. private rotateCamera;
  37735. }
  37736. }
  37737. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37738. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37739. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37740. /**
  37741. * Default Inputs manager for the FlyCamera.
  37742. * It groups all the default supported inputs for ease of use.
  37743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37744. */
  37745. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37746. /**
  37747. * Instantiates a new FlyCameraInputsManager.
  37748. * @param camera Defines the camera the inputs belong to.
  37749. */
  37750. constructor(camera: FlyCamera);
  37751. /**
  37752. * Add keyboard input support to the input manager.
  37753. * @returns the new FlyCameraKeyboardMoveInput().
  37754. */
  37755. addKeyboard(): FlyCameraInputsManager;
  37756. /**
  37757. * Add mouse input support to the input manager.
  37758. * @param touchEnabled Enable touch screen support.
  37759. * @returns the new FlyCameraMouseInput().
  37760. */
  37761. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37762. }
  37763. }
  37764. declare module "babylonjs/Cameras/flyCamera" {
  37765. import { Scene } from "babylonjs/scene";
  37766. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37768. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37769. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37770. /**
  37771. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37772. * such as in a 3D Space Shooter or a Flight Simulator.
  37773. */
  37774. export class FlyCamera extends TargetCamera {
  37775. /**
  37776. * Define the collision ellipsoid of the camera.
  37777. * This is helpful for simulating a camera body, like a player's body.
  37778. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37779. */
  37780. ellipsoid: Vector3;
  37781. /**
  37782. * Define an offset for the position of the ellipsoid around the camera.
  37783. * This can be helpful if the camera is attached away from the player's body center,
  37784. * such as at its head.
  37785. */
  37786. ellipsoidOffset: Vector3;
  37787. /**
  37788. * Enable or disable collisions of the camera with the rest of the scene objects.
  37789. */
  37790. checkCollisions: boolean;
  37791. /**
  37792. * Enable or disable gravity on the camera.
  37793. */
  37794. applyGravity: boolean;
  37795. /**
  37796. * Define the current direction the camera is moving to.
  37797. */
  37798. cameraDirection: Vector3;
  37799. /**
  37800. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37801. * This overrides and empties cameraRotation.
  37802. */
  37803. rotationQuaternion: Quaternion;
  37804. /**
  37805. * Track Roll to maintain the wanted Rolling when looking around.
  37806. */
  37807. _trackRoll: number;
  37808. /**
  37809. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37810. */
  37811. rollCorrect: number;
  37812. /**
  37813. * Mimic a banked turn, Rolling the camera when Yawing.
  37814. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37815. */
  37816. bankedTurn: boolean;
  37817. /**
  37818. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37819. */
  37820. bankedTurnLimit: number;
  37821. /**
  37822. * Value of 0 disables the banked Roll.
  37823. * Value of 1 is equal to the Yaw angle in radians.
  37824. */
  37825. bankedTurnMultiplier: number;
  37826. /**
  37827. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37828. */
  37829. inputs: FlyCameraInputsManager;
  37830. /**
  37831. * Gets the input sensibility for mouse input.
  37832. * Higher values reduce sensitivity.
  37833. */
  37834. /**
  37835. * Sets the input sensibility for a mouse input.
  37836. * Higher values reduce sensitivity.
  37837. */
  37838. angularSensibility: number;
  37839. /**
  37840. * Get the keys for camera movement forward.
  37841. */
  37842. /**
  37843. * Set the keys for camera movement forward.
  37844. */
  37845. keysForward: number[];
  37846. /**
  37847. * Get the keys for camera movement backward.
  37848. */
  37849. keysBackward: number[];
  37850. /**
  37851. * Get the keys for camera movement up.
  37852. */
  37853. /**
  37854. * Set the keys for camera movement up.
  37855. */
  37856. keysUp: number[];
  37857. /**
  37858. * Get the keys for camera movement down.
  37859. */
  37860. /**
  37861. * Set the keys for camera movement down.
  37862. */
  37863. keysDown: number[];
  37864. /**
  37865. * Get the keys for camera movement left.
  37866. */
  37867. /**
  37868. * Set the keys for camera movement left.
  37869. */
  37870. keysLeft: number[];
  37871. /**
  37872. * Set the keys for camera movement right.
  37873. */
  37874. /**
  37875. * Set the keys for camera movement right.
  37876. */
  37877. keysRight: number[];
  37878. /**
  37879. * Event raised when the camera collides with a mesh in the scene.
  37880. */
  37881. onCollide: (collidedMesh: AbstractMesh) => void;
  37882. private _collider;
  37883. private _needMoveForGravity;
  37884. private _oldPosition;
  37885. private _diffPosition;
  37886. private _newPosition;
  37887. /** @hidden */
  37888. _localDirection: Vector3;
  37889. /** @hidden */
  37890. _transformedDirection: Vector3;
  37891. /**
  37892. * Instantiates a FlyCamera.
  37893. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37894. * such as in a 3D Space Shooter or a Flight Simulator.
  37895. * @param name Define the name of the camera in the scene.
  37896. * @param position Define the starting position of the camera in the scene.
  37897. * @param scene Define the scene the camera belongs to.
  37898. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37899. */
  37900. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37901. /**
  37902. * Attach a control to the HTML DOM element.
  37903. * @param element Defines the element that listens to the input events.
  37904. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37905. */
  37906. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37907. /**
  37908. * Detach a control from the HTML DOM element.
  37909. * The camera will stop reacting to that input.
  37910. * @param element Defines the element that listens to the input events.
  37911. */
  37912. detachControl(element: HTMLElement): void;
  37913. private _collisionMask;
  37914. /**
  37915. * Get the mask that the camera ignores in collision events.
  37916. */
  37917. /**
  37918. * Set the mask that the camera ignores in collision events.
  37919. */
  37920. collisionMask: number;
  37921. /** @hidden */
  37922. _collideWithWorld(displacement: Vector3): void;
  37923. /** @hidden */
  37924. private _onCollisionPositionChange;
  37925. /** @hidden */
  37926. _checkInputs(): void;
  37927. /** @hidden */
  37928. _decideIfNeedsToMove(): boolean;
  37929. /** @hidden */
  37930. _updatePosition(): void;
  37931. /**
  37932. * Restore the Roll to its target value at the rate specified.
  37933. * @param rate - Higher means slower restoring.
  37934. * @hidden
  37935. */
  37936. restoreRoll(rate: number): void;
  37937. /**
  37938. * Destroy the camera and release the current resources held by it.
  37939. */
  37940. dispose(): void;
  37941. /**
  37942. * Get the current object class name.
  37943. * @returns the class name.
  37944. */
  37945. getClassName(): string;
  37946. }
  37947. }
  37948. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37949. import { Nullable } from "babylonjs/types";
  37950. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37951. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37952. /**
  37953. * Listen to keyboard events to control the camera.
  37954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37955. */
  37956. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37957. /**
  37958. * Defines the camera the input is attached to.
  37959. */
  37960. camera: FlyCamera;
  37961. /**
  37962. * The list of keyboard keys used to control the forward move of the camera.
  37963. */
  37964. keysForward: number[];
  37965. /**
  37966. * The list of keyboard keys used to control the backward move of the camera.
  37967. */
  37968. keysBackward: number[];
  37969. /**
  37970. * The list of keyboard keys used to control the forward move of the camera.
  37971. */
  37972. keysUp: number[];
  37973. /**
  37974. * The list of keyboard keys used to control the backward move of the camera.
  37975. */
  37976. keysDown: number[];
  37977. /**
  37978. * The list of keyboard keys used to control the right strafe move of the camera.
  37979. */
  37980. keysRight: number[];
  37981. /**
  37982. * The list of keyboard keys used to control the left strafe move of the camera.
  37983. */
  37984. keysLeft: number[];
  37985. private _keys;
  37986. private _onCanvasBlurObserver;
  37987. private _onKeyboardObserver;
  37988. private _engine;
  37989. private _scene;
  37990. /**
  37991. * Attach the input controls to a specific dom element to get the input from.
  37992. * @param element Defines the element the controls should be listened from
  37993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37994. */
  37995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37996. /**
  37997. * Detach the current controls from the specified dom element.
  37998. * @param element Defines the element to stop listening the inputs from
  37999. */
  38000. detachControl(element: Nullable<HTMLElement>): void;
  38001. /**
  38002. * Gets the class name of the current intput.
  38003. * @returns the class name
  38004. */
  38005. getClassName(): string;
  38006. /** @hidden */
  38007. _onLostFocus(e: FocusEvent): void;
  38008. /**
  38009. * Get the friendly name associated with the input class.
  38010. * @returns the input friendly name
  38011. */
  38012. getSimpleName(): string;
  38013. /**
  38014. * Update the current camera state depending on the inputs that have been used this frame.
  38015. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38016. */
  38017. checkInputs(): void;
  38018. }
  38019. }
  38020. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38021. import { Nullable } from "babylonjs/types";
  38022. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38023. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38024. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38025. /**
  38026. * Manage the gamepad inputs to control a free camera.
  38027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38028. */
  38029. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38030. /**
  38031. * Define the camera the input is attached to.
  38032. */
  38033. camera: FreeCamera;
  38034. /**
  38035. * Define the Gamepad controlling the input
  38036. */
  38037. gamepad: Nullable<Gamepad>;
  38038. /**
  38039. * Defines the gamepad rotation sensiblity.
  38040. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38041. */
  38042. gamepadAngularSensibility: number;
  38043. /**
  38044. * Defines the gamepad move sensiblity.
  38045. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38046. */
  38047. gamepadMoveSensibility: number;
  38048. private _onGamepadConnectedObserver;
  38049. private _onGamepadDisconnectedObserver;
  38050. private _cameraTransform;
  38051. private _deltaTransform;
  38052. private _vector3;
  38053. private _vector2;
  38054. /**
  38055. * Attach the input controls to a specific dom element to get the input from.
  38056. * @param element Defines the element the controls should be listened from
  38057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38058. */
  38059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38060. /**
  38061. * Detach the current controls from the specified dom element.
  38062. * @param element Defines the element to stop listening the inputs from
  38063. */
  38064. detachControl(element: Nullable<HTMLElement>): void;
  38065. /**
  38066. * Update the current camera state depending on the inputs that have been used this frame.
  38067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38068. */
  38069. checkInputs(): void;
  38070. /**
  38071. * Gets the class name of the current intput.
  38072. * @returns the class name
  38073. */
  38074. getClassName(): string;
  38075. /**
  38076. * Get the friendly name associated with the input class.
  38077. * @returns the input friendly name
  38078. */
  38079. getSimpleName(): string;
  38080. }
  38081. }
  38082. declare module "babylonjs/Cameras/Inputs/index" {
  38083. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38084. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38085. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38086. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38087. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38088. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38089. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38090. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38091. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38092. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38093. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38094. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38095. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38096. }
  38097. declare module "babylonjs/Cameras/touchCamera" {
  38098. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38099. import { Scene } from "babylonjs/scene";
  38100. import { Vector3 } from "babylonjs/Maths/math";
  38101. /**
  38102. * This represents a FPS type of camera controlled by touch.
  38103. * This is like a universal camera minus the Gamepad controls.
  38104. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38105. */
  38106. export class TouchCamera extends FreeCamera {
  38107. /**
  38108. * Defines the touch sensibility for rotation.
  38109. * The higher the faster.
  38110. */
  38111. touchAngularSensibility: number;
  38112. /**
  38113. * Defines the touch sensibility for move.
  38114. * The higher the faster.
  38115. */
  38116. touchMoveSensibility: number;
  38117. /**
  38118. * Instantiates a new touch camera.
  38119. * This represents a FPS type of camera controlled by touch.
  38120. * This is like a universal camera minus the Gamepad controls.
  38121. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38122. * @param name Define the name of the camera in the scene
  38123. * @param position Define the start position of the camera in the scene
  38124. * @param scene Define the scene the camera belongs to
  38125. */
  38126. constructor(name: string, position: Vector3, scene: Scene);
  38127. /**
  38128. * Gets the current object class name.
  38129. * @return the class name
  38130. */
  38131. getClassName(): string;
  38132. /** @hidden */
  38133. _setupInputs(): void;
  38134. }
  38135. }
  38136. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38137. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38138. import { Scene } from "babylonjs/scene";
  38139. import { Vector3, Axis } from "babylonjs/Maths/math";
  38140. /**
  38141. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38142. * being tilted forward or back and left or right.
  38143. */
  38144. export class DeviceOrientationCamera extends FreeCamera {
  38145. private _initialQuaternion;
  38146. private _quaternionCache;
  38147. /**
  38148. * Creates a new device orientation camera
  38149. * @param name The name of the camera
  38150. * @param position The start position camera
  38151. * @param scene The scene the camera belongs to
  38152. */
  38153. constructor(name: string, position: Vector3, scene: Scene);
  38154. /**
  38155. * Gets the current instance class name ("DeviceOrientationCamera").
  38156. * This helps avoiding instanceof at run time.
  38157. * @returns the class name
  38158. */
  38159. getClassName(): string;
  38160. /**
  38161. * @hidden
  38162. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38163. */
  38164. _checkInputs(): void;
  38165. /**
  38166. * Reset the camera to its default orientation on the specified axis only.
  38167. * @param axis The axis to reset
  38168. */
  38169. resetToCurrentRotation(axis?: Axis): void;
  38170. }
  38171. }
  38172. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38173. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38174. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38175. import { Nullable } from "babylonjs/types";
  38176. /**
  38177. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38179. */
  38180. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38181. /**
  38182. * Defines the camera the input is attached to.
  38183. */
  38184. camera: FollowCamera;
  38185. /**
  38186. * Defines the list of key codes associated with the up action (increase heightOffset)
  38187. */
  38188. keysUp: number[];
  38189. /**
  38190. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38191. */
  38192. keysDown: number[];
  38193. /**
  38194. * Defines the list of key codes associated with the left action (increase rotation)
  38195. */
  38196. keysLeft: number[];
  38197. /**
  38198. * Defines the list of key codes associated with the right action (decrease rotation)
  38199. */
  38200. keysRight: number[];
  38201. /**
  38202. * Defines the rate of change of heightOffset.
  38203. */
  38204. heightSensibility: number;
  38205. /**
  38206. * Defines the rate of change of rotationOffset.
  38207. */
  38208. rotationSensibility: number;
  38209. /**
  38210. * Defines the rate of change of radius.
  38211. */
  38212. radiusSensibility: number;
  38213. /**
  38214. * Defines the minimum heightOffset value.
  38215. */
  38216. minHeightOffset: number;
  38217. /**
  38218. * Defines the minimum radius value.
  38219. */
  38220. minRadius: number;
  38221. private _keys;
  38222. private _altPressed;
  38223. private _onCanvasBlurObserver;
  38224. private _onKeyboardObserver;
  38225. private _engine;
  38226. private _scene;
  38227. /**
  38228. * Attach the input controls to a specific dom element to get the input from.
  38229. * @param element Defines the element the controls should be listened from
  38230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38231. */
  38232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38233. /**
  38234. * Detach the current controls from the specified dom element.
  38235. * @param element Defines the element to stop listening the inputs from
  38236. */
  38237. detachControl(element: Nullable<HTMLElement>): void;
  38238. /**
  38239. * Update the current camera state depending on the inputs that have been used this frame.
  38240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38241. */
  38242. checkInputs(): void;
  38243. /**
  38244. * Gets the class name of the current intput.
  38245. * @returns the class name
  38246. */
  38247. getClassName(): string;
  38248. /**
  38249. * Get the friendly name associated with the input class.
  38250. * @returns the input friendly name
  38251. */
  38252. getSimpleName(): string;
  38253. }
  38254. }
  38255. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38256. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38257. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38258. /**
  38259. * Default Inputs manager for the FollowCamera.
  38260. * It groups all the default supported inputs for ease of use.
  38261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38262. */
  38263. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38264. /**
  38265. * Instantiates a new FollowCameraInputsManager.
  38266. * @param camera Defines the camera the inputs belong to
  38267. */
  38268. constructor(camera: FollowCamera);
  38269. /**
  38270. * Add keyboard input support to the input manager.
  38271. * @returns the current input manager
  38272. */
  38273. addKeyboard(): FollowCameraInputsManager;
  38274. /**
  38275. * Add mouse wheel input support to the input manager.
  38276. * @returns the current input manager
  38277. */
  38278. addMouseWheel(): FollowCameraInputsManager;
  38279. /**
  38280. * Add pointers input support to the input manager.
  38281. * @returns the current input manager
  38282. */
  38283. addPointers(): FollowCameraInputsManager;
  38284. /**
  38285. * Add orientation input support to the input manager.
  38286. * @returns the current input manager
  38287. */
  38288. addVRDeviceOrientation(): FollowCameraInputsManager;
  38289. }
  38290. }
  38291. declare module "babylonjs/Cameras/followCamera" {
  38292. import { Nullable } from "babylonjs/types";
  38293. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38294. import { Scene } from "babylonjs/scene";
  38295. import { Vector3 } from "babylonjs/Maths/math";
  38296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38297. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38298. /**
  38299. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38300. * an arc rotate version arcFollowCamera are available.
  38301. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38302. */
  38303. export class FollowCamera extends TargetCamera {
  38304. /**
  38305. * Distance the follow camera should follow an object at
  38306. */
  38307. radius: number;
  38308. /**
  38309. * Define a rotation offset between the camera and the object it follows
  38310. */
  38311. rotationOffset: number;
  38312. /**
  38313. * Define a height offset between the camera and the object it follows.
  38314. * It can help following an object from the top (like a car chaing a plane)
  38315. */
  38316. heightOffset: number;
  38317. /**
  38318. * Define how fast the camera can accelerate to follow it s target.
  38319. */
  38320. cameraAcceleration: number;
  38321. /**
  38322. * Define the speed limit of the camera following an object.
  38323. */
  38324. maxCameraSpeed: number;
  38325. /**
  38326. * Define the target of the camera.
  38327. */
  38328. lockedTarget: Nullable<AbstractMesh>;
  38329. /**
  38330. * Defines the input associated with the camera.
  38331. */
  38332. inputs: FollowCameraInputsManager;
  38333. /**
  38334. * Instantiates the follow camera.
  38335. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38336. * @param name Define the name of the camera in the scene
  38337. * @param position Define the position of the camera
  38338. * @param scene Define the scene the camera belong to
  38339. * @param lockedTarget Define the target of the camera
  38340. */
  38341. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38342. private _follow;
  38343. /**
  38344. * Attached controls to the current camera.
  38345. * @param element Defines the element the controls should be listened from
  38346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38347. */
  38348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38349. /**
  38350. * Detach the current controls from the camera.
  38351. * The camera will stop reacting to inputs.
  38352. * @param element Defines the element to stop listening the inputs from
  38353. */
  38354. detachControl(element: HTMLElement): void;
  38355. /** @hidden */
  38356. _checkInputs(): void;
  38357. /**
  38358. * Gets the camera class name.
  38359. * @returns the class name
  38360. */
  38361. getClassName(): string;
  38362. }
  38363. /**
  38364. * Arc Rotate version of the follow camera.
  38365. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38366. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38367. */
  38368. export class ArcFollowCamera extends TargetCamera {
  38369. /** The longitudinal angle of the camera */
  38370. alpha: number;
  38371. /** The latitudinal angle of the camera */
  38372. beta: number;
  38373. /** The radius of the camera from its target */
  38374. radius: number;
  38375. /** Define the camera target (the messh it should follow) */
  38376. target: Nullable<AbstractMesh>;
  38377. private _cartesianCoordinates;
  38378. /**
  38379. * Instantiates a new ArcFollowCamera
  38380. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38381. * @param name Define the name of the camera
  38382. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38383. * @param beta Define the rotation angle of the camera around the elevation axis
  38384. * @param radius Define the radius of the camera from its target point
  38385. * @param target Define the target of the camera
  38386. * @param scene Define the scene the camera belongs to
  38387. */
  38388. constructor(name: string,
  38389. /** The longitudinal angle of the camera */
  38390. alpha: number,
  38391. /** The latitudinal angle of the camera */
  38392. beta: number,
  38393. /** The radius of the camera from its target */
  38394. radius: number,
  38395. /** Define the camera target (the messh it should follow) */
  38396. target: Nullable<AbstractMesh>, scene: Scene);
  38397. private _follow;
  38398. /** @hidden */
  38399. _checkInputs(): void;
  38400. /**
  38401. * Returns the class name of the object.
  38402. * It is mostly used internally for serialization purposes.
  38403. */
  38404. getClassName(): string;
  38405. }
  38406. }
  38407. declare module "babylonjs/Cameras/universalCamera" {
  38408. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38409. import { Scene } from "babylonjs/scene";
  38410. import { Vector3 } from "babylonjs/Maths/math";
  38411. /**
  38412. * 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,
  38413. * which still works and will still be found in many Playgrounds.
  38414. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38415. */
  38416. export class UniversalCamera extends TouchCamera {
  38417. /**
  38418. * Defines the gamepad rotation sensiblity.
  38419. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38420. */
  38421. gamepadAngularSensibility: number;
  38422. /**
  38423. * Defines the gamepad move sensiblity.
  38424. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38425. */
  38426. gamepadMoveSensibility: number;
  38427. /**
  38428. * 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,
  38429. * which still works and will still be found in many Playgrounds.
  38430. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38431. * @param name Define the name of the camera in the scene
  38432. * @param position Define the start position of the camera in the scene
  38433. * @param scene Define the scene the camera belongs to
  38434. */
  38435. constructor(name: string, position: Vector3, scene: Scene);
  38436. /**
  38437. * Gets the current object class name.
  38438. * @return the class name
  38439. */
  38440. getClassName(): string;
  38441. }
  38442. }
  38443. declare module "babylonjs/Cameras/gamepadCamera" {
  38444. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38445. import { Scene } from "babylonjs/scene";
  38446. import { Vector3 } from "babylonjs/Maths/math";
  38447. /**
  38448. * This represents a FPS type of camera. This is only here for back compat purpose.
  38449. * Please use the UniversalCamera instead as both are identical.
  38450. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38451. */
  38452. export class GamepadCamera extends UniversalCamera {
  38453. /**
  38454. * Instantiates a new Gamepad Camera
  38455. * This represents a FPS type of camera. This is only here for back compat purpose.
  38456. * Please use the UniversalCamera instead as both are identical.
  38457. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38458. * @param name Define the name of the camera in the scene
  38459. * @param position Define the start position of the camera in the scene
  38460. * @param scene Define the scene the camera belongs to
  38461. */
  38462. constructor(name: string, position: Vector3, scene: Scene);
  38463. /**
  38464. * Gets the current object class name.
  38465. * @return the class name
  38466. */
  38467. getClassName(): string;
  38468. }
  38469. }
  38470. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38471. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38472. import { Scene } from "babylonjs/scene";
  38473. import { Vector3 } from "babylonjs/Maths/math";
  38474. /**
  38475. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38476. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38477. */
  38478. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38479. /**
  38480. * Creates a new AnaglyphArcRotateCamera
  38481. * @param name defines camera name
  38482. * @param alpha defines alpha angle (in radians)
  38483. * @param beta defines beta angle (in radians)
  38484. * @param radius defines radius
  38485. * @param target defines camera target
  38486. * @param interaxialDistance defines distance between each color axis
  38487. * @param scene defines the hosting scene
  38488. */
  38489. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38490. /**
  38491. * Gets camera class name
  38492. * @returns AnaglyphArcRotateCamera
  38493. */
  38494. getClassName(): string;
  38495. }
  38496. }
  38497. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38498. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38499. import { Scene } from "babylonjs/scene";
  38500. import { Vector3 } from "babylonjs/Maths/math";
  38501. /**
  38502. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38503. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38504. */
  38505. export class AnaglyphFreeCamera extends FreeCamera {
  38506. /**
  38507. * Creates a new AnaglyphFreeCamera
  38508. * @param name defines camera name
  38509. * @param position defines initial position
  38510. * @param interaxialDistance defines distance between each color axis
  38511. * @param scene defines the hosting scene
  38512. */
  38513. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38514. /**
  38515. * Gets camera class name
  38516. * @returns AnaglyphFreeCamera
  38517. */
  38518. getClassName(): string;
  38519. }
  38520. }
  38521. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38522. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38523. import { Scene } from "babylonjs/scene";
  38524. import { Vector3 } from "babylonjs/Maths/math";
  38525. /**
  38526. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38527. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38528. */
  38529. export class AnaglyphGamepadCamera extends GamepadCamera {
  38530. /**
  38531. * Creates a new AnaglyphGamepadCamera
  38532. * @param name defines camera name
  38533. * @param position defines initial position
  38534. * @param interaxialDistance defines distance between each color axis
  38535. * @param scene defines the hosting scene
  38536. */
  38537. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38538. /**
  38539. * Gets camera class name
  38540. * @returns AnaglyphGamepadCamera
  38541. */
  38542. getClassName(): string;
  38543. }
  38544. }
  38545. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38546. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38547. import { Scene } from "babylonjs/scene";
  38548. import { Vector3 } from "babylonjs/Maths/math";
  38549. /**
  38550. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38551. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38552. */
  38553. export class AnaglyphUniversalCamera extends UniversalCamera {
  38554. /**
  38555. * Creates a new AnaglyphUniversalCamera
  38556. * @param name defines camera name
  38557. * @param position defines initial position
  38558. * @param interaxialDistance defines distance between each color axis
  38559. * @param scene defines the hosting scene
  38560. */
  38561. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38562. /**
  38563. * Gets camera class name
  38564. * @returns AnaglyphUniversalCamera
  38565. */
  38566. getClassName(): string;
  38567. }
  38568. }
  38569. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38570. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38571. import { Scene } from "babylonjs/scene";
  38572. import { Vector3 } from "babylonjs/Maths/math";
  38573. /**
  38574. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38575. * @see http://doc.babylonjs.com/features/cameras
  38576. */
  38577. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38578. /**
  38579. * Creates a new StereoscopicArcRotateCamera
  38580. * @param name defines camera name
  38581. * @param alpha defines alpha angle (in radians)
  38582. * @param beta defines beta angle (in radians)
  38583. * @param radius defines radius
  38584. * @param target defines camera target
  38585. * @param interaxialDistance defines distance between each color axis
  38586. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38587. * @param scene defines the hosting scene
  38588. */
  38589. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38590. /**
  38591. * Gets camera class name
  38592. * @returns StereoscopicArcRotateCamera
  38593. */
  38594. getClassName(): string;
  38595. }
  38596. }
  38597. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38598. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38599. import { Scene } from "babylonjs/scene";
  38600. import { Vector3 } from "babylonjs/Maths/math";
  38601. /**
  38602. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38603. * @see http://doc.babylonjs.com/features/cameras
  38604. */
  38605. export class StereoscopicFreeCamera extends FreeCamera {
  38606. /**
  38607. * Creates a new StereoscopicFreeCamera
  38608. * @param name defines camera name
  38609. * @param position defines initial position
  38610. * @param interaxialDistance defines distance between each color axis
  38611. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38612. * @param scene defines the hosting scene
  38613. */
  38614. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38615. /**
  38616. * Gets camera class name
  38617. * @returns StereoscopicFreeCamera
  38618. */
  38619. getClassName(): string;
  38620. }
  38621. }
  38622. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38623. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38624. import { Scene } from "babylonjs/scene";
  38625. import { Vector3 } from "babylonjs/Maths/math";
  38626. /**
  38627. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38628. * @see http://doc.babylonjs.com/features/cameras
  38629. */
  38630. export class StereoscopicGamepadCamera extends GamepadCamera {
  38631. /**
  38632. * Creates a new StereoscopicGamepadCamera
  38633. * @param name defines camera name
  38634. * @param position defines initial position
  38635. * @param interaxialDistance defines distance between each color axis
  38636. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38637. * @param scene defines the hosting scene
  38638. */
  38639. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38640. /**
  38641. * Gets camera class name
  38642. * @returns StereoscopicGamepadCamera
  38643. */
  38644. getClassName(): string;
  38645. }
  38646. }
  38647. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38648. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38649. import { Scene } from "babylonjs/scene";
  38650. import { Vector3 } from "babylonjs/Maths/math";
  38651. /**
  38652. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38653. * @see http://doc.babylonjs.com/features/cameras
  38654. */
  38655. export class StereoscopicUniversalCamera extends UniversalCamera {
  38656. /**
  38657. * Creates a new StereoscopicUniversalCamera
  38658. * @param name defines camera name
  38659. * @param position defines initial position
  38660. * @param interaxialDistance defines distance between each color axis
  38661. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38662. * @param scene defines the hosting scene
  38663. */
  38664. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38665. /**
  38666. * Gets camera class name
  38667. * @returns StereoscopicUniversalCamera
  38668. */
  38669. getClassName(): string;
  38670. }
  38671. }
  38672. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38673. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38674. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38675. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38676. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38677. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38678. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38679. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38680. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38681. }
  38682. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38683. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38684. import { Scene } from "babylonjs/scene";
  38685. import { Vector3 } from "babylonjs/Maths/math";
  38686. /**
  38687. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38688. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38689. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38690. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38691. */
  38692. export class VirtualJoysticksCamera extends FreeCamera {
  38693. /**
  38694. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38695. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38696. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38697. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38698. * @param name Define the name of the camera in the scene
  38699. * @param position Define the start position of the camera in the scene
  38700. * @param scene Define the scene the camera belongs to
  38701. */
  38702. constructor(name: string, position: Vector3, scene: Scene);
  38703. /**
  38704. * Gets the current object class name.
  38705. * @return the class name
  38706. */
  38707. getClassName(): string;
  38708. }
  38709. }
  38710. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38711. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38712. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38713. import { Scene } from "babylonjs/scene";
  38714. import { Vector3 } from "babylonjs/Maths/math";
  38715. /**
  38716. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38717. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38718. */
  38719. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38720. /**
  38721. * Creates a new VRDeviceOrientationArcRotateCamera
  38722. * @param name defines camera name
  38723. * @param alpha defines the camera rotation along the logitudinal axis
  38724. * @param beta defines the camera rotation along the latitudinal axis
  38725. * @param radius defines the camera distance from its target
  38726. * @param target defines the camera target
  38727. * @param scene defines the scene the camera belongs to
  38728. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38729. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38730. */
  38731. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38732. /**
  38733. * Gets camera class name
  38734. * @returns VRDeviceOrientationArcRotateCamera
  38735. */
  38736. getClassName(): string;
  38737. }
  38738. }
  38739. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38740. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38741. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38742. import { Scene } from "babylonjs/scene";
  38743. import { Vector3 } from "babylonjs/Maths/math";
  38744. /**
  38745. * Camera used to simulate VR rendering (based on FreeCamera)
  38746. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38747. */
  38748. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38749. /**
  38750. * Creates a new VRDeviceOrientationFreeCamera
  38751. * @param name defines camera name
  38752. * @param position defines the start position of the camera
  38753. * @param scene defines the scene the camera belongs to
  38754. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38755. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38756. */
  38757. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38758. /**
  38759. * Gets camera class name
  38760. * @returns VRDeviceOrientationFreeCamera
  38761. */
  38762. getClassName(): string;
  38763. }
  38764. }
  38765. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38766. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38767. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38768. import { Scene } from "babylonjs/scene";
  38769. import { Vector3 } from "babylonjs/Maths/math";
  38770. /**
  38771. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38772. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38773. */
  38774. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38775. /**
  38776. * Creates a new VRDeviceOrientationGamepadCamera
  38777. * @param name defines camera name
  38778. * @param position defines the start position of the camera
  38779. * @param scene defines the scene the camera belongs to
  38780. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38781. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38782. */
  38783. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38784. /**
  38785. * Gets camera class name
  38786. * @returns VRDeviceOrientationGamepadCamera
  38787. */
  38788. getClassName(): string;
  38789. }
  38790. }
  38791. declare module "babylonjs/Gamepads/xboxGamepad" {
  38792. import { Observable } from "babylonjs/Misc/observable";
  38793. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38794. /**
  38795. * Defines supported buttons for XBox360 compatible gamepads
  38796. */
  38797. export enum Xbox360Button {
  38798. /** A */
  38799. A = 0,
  38800. /** B */
  38801. B = 1,
  38802. /** X */
  38803. X = 2,
  38804. /** Y */
  38805. Y = 3,
  38806. /** Start */
  38807. Start = 4,
  38808. /** Back */
  38809. Back = 5,
  38810. /** Left button */
  38811. LB = 6,
  38812. /** Right button */
  38813. RB = 7,
  38814. /** Left stick */
  38815. LeftStick = 8,
  38816. /** Right stick */
  38817. RightStick = 9
  38818. }
  38819. /** Defines values for XBox360 DPad */
  38820. export enum Xbox360Dpad {
  38821. /** Up */
  38822. Up = 0,
  38823. /** Down */
  38824. Down = 1,
  38825. /** Left */
  38826. Left = 2,
  38827. /** Right */
  38828. Right = 3
  38829. }
  38830. /**
  38831. * Defines a XBox360 gamepad
  38832. */
  38833. export class Xbox360Pad extends Gamepad {
  38834. private _leftTrigger;
  38835. private _rightTrigger;
  38836. private _onlefttriggerchanged;
  38837. private _onrighttriggerchanged;
  38838. private _onbuttondown;
  38839. private _onbuttonup;
  38840. private _ondpaddown;
  38841. private _ondpadup;
  38842. /** Observable raised when a button is pressed */
  38843. onButtonDownObservable: Observable<Xbox360Button>;
  38844. /** Observable raised when a button is released */
  38845. onButtonUpObservable: Observable<Xbox360Button>;
  38846. /** Observable raised when a pad is pressed */
  38847. onPadDownObservable: Observable<Xbox360Dpad>;
  38848. /** Observable raised when a pad is released */
  38849. onPadUpObservable: Observable<Xbox360Dpad>;
  38850. private _buttonA;
  38851. private _buttonB;
  38852. private _buttonX;
  38853. private _buttonY;
  38854. private _buttonBack;
  38855. private _buttonStart;
  38856. private _buttonLB;
  38857. private _buttonRB;
  38858. private _buttonLeftStick;
  38859. private _buttonRightStick;
  38860. private _dPadUp;
  38861. private _dPadDown;
  38862. private _dPadLeft;
  38863. private _dPadRight;
  38864. private _isXboxOnePad;
  38865. /**
  38866. * Creates a new XBox360 gamepad object
  38867. * @param id defines the id of this gamepad
  38868. * @param index defines its index
  38869. * @param gamepad defines the internal HTML gamepad object
  38870. * @param xboxOne defines if it is a XBox One gamepad
  38871. */
  38872. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38873. /**
  38874. * Defines the callback to call when left trigger is pressed
  38875. * @param callback defines the callback to use
  38876. */
  38877. onlefttriggerchanged(callback: (value: number) => void): void;
  38878. /**
  38879. * Defines the callback to call when right trigger is pressed
  38880. * @param callback defines the callback to use
  38881. */
  38882. onrighttriggerchanged(callback: (value: number) => void): void;
  38883. /**
  38884. * Gets the left trigger value
  38885. */
  38886. /**
  38887. * Sets the left trigger value
  38888. */
  38889. leftTrigger: number;
  38890. /**
  38891. * Gets the right trigger value
  38892. */
  38893. /**
  38894. * Sets the right trigger value
  38895. */
  38896. rightTrigger: number;
  38897. /**
  38898. * Defines the callback to call when a button is pressed
  38899. * @param callback defines the callback to use
  38900. */
  38901. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38902. /**
  38903. * Defines the callback to call when a button is released
  38904. * @param callback defines the callback to use
  38905. */
  38906. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38907. /**
  38908. * Defines the callback to call when a pad is pressed
  38909. * @param callback defines the callback to use
  38910. */
  38911. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38912. /**
  38913. * Defines the callback to call when a pad is released
  38914. * @param callback defines the callback to use
  38915. */
  38916. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38917. private _setButtonValue;
  38918. private _setDPadValue;
  38919. /**
  38920. * Gets the value of the `A` button
  38921. */
  38922. /**
  38923. * Sets the value of the `A` button
  38924. */
  38925. buttonA: number;
  38926. /**
  38927. * Gets the value of the `B` button
  38928. */
  38929. /**
  38930. * Sets the value of the `B` button
  38931. */
  38932. buttonB: number;
  38933. /**
  38934. * Gets the value of the `X` button
  38935. */
  38936. /**
  38937. * Sets the value of the `X` button
  38938. */
  38939. buttonX: number;
  38940. /**
  38941. * Gets the value of the `Y` button
  38942. */
  38943. /**
  38944. * Sets the value of the `Y` button
  38945. */
  38946. buttonY: number;
  38947. /**
  38948. * Gets the value of the `Start` button
  38949. */
  38950. /**
  38951. * Sets the value of the `Start` button
  38952. */
  38953. buttonStart: number;
  38954. /**
  38955. * Gets the value of the `Back` button
  38956. */
  38957. /**
  38958. * Sets the value of the `Back` button
  38959. */
  38960. buttonBack: number;
  38961. /**
  38962. * Gets the value of the `Left` button
  38963. */
  38964. /**
  38965. * Sets the value of the `Left` button
  38966. */
  38967. buttonLB: number;
  38968. /**
  38969. * Gets the value of the `Right` button
  38970. */
  38971. /**
  38972. * Sets the value of the `Right` button
  38973. */
  38974. buttonRB: number;
  38975. /**
  38976. * Gets the value of the Left joystick
  38977. */
  38978. /**
  38979. * Sets the value of the Left joystick
  38980. */
  38981. buttonLeftStick: number;
  38982. /**
  38983. * Gets the value of the Right joystick
  38984. */
  38985. /**
  38986. * Sets the value of the Right joystick
  38987. */
  38988. buttonRightStick: number;
  38989. /**
  38990. * Gets the value of D-pad up
  38991. */
  38992. /**
  38993. * Sets the value of D-pad up
  38994. */
  38995. dPadUp: number;
  38996. /**
  38997. * Gets the value of D-pad down
  38998. */
  38999. /**
  39000. * Sets the value of D-pad down
  39001. */
  39002. dPadDown: number;
  39003. /**
  39004. * Gets the value of D-pad left
  39005. */
  39006. /**
  39007. * Sets the value of D-pad left
  39008. */
  39009. dPadLeft: number;
  39010. /**
  39011. * Gets the value of D-pad right
  39012. */
  39013. /**
  39014. * Sets the value of D-pad right
  39015. */
  39016. dPadRight: number;
  39017. /**
  39018. * Force the gamepad to synchronize with device values
  39019. */
  39020. update(): void;
  39021. /**
  39022. * Disposes the gamepad
  39023. */
  39024. dispose(): void;
  39025. }
  39026. }
  39027. declare module "babylonjs/Materials/pushMaterial" {
  39028. import { Nullable } from "babylonjs/types";
  39029. import { Scene } from "babylonjs/scene";
  39030. import { Matrix } from "babylonjs/Maths/math";
  39031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39032. import { Mesh } from "babylonjs/Meshes/mesh";
  39033. import { Material } from "babylonjs/Materials/material";
  39034. import { Effect } from "babylonjs/Materials/effect";
  39035. /**
  39036. * Base class of materials working in push mode in babylon JS
  39037. * @hidden
  39038. */
  39039. export class PushMaterial extends Material {
  39040. protected _activeEffect: Effect;
  39041. protected _normalMatrix: Matrix;
  39042. /**
  39043. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39044. * This means that the material can keep using a previous shader while a new one is being compiled.
  39045. * This is mostly used when shader parallel compilation is supported (true by default)
  39046. */
  39047. allowShaderHotSwapping: boolean;
  39048. constructor(name: string, scene: Scene);
  39049. getEffect(): Effect;
  39050. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39051. /**
  39052. * Binds the given world matrix to the active effect
  39053. *
  39054. * @param world the matrix to bind
  39055. */
  39056. bindOnlyWorldMatrix(world: Matrix): void;
  39057. /**
  39058. * Binds the given normal matrix to the active effect
  39059. *
  39060. * @param normalMatrix the matrix to bind
  39061. */
  39062. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39063. bind(world: Matrix, mesh?: Mesh): void;
  39064. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39065. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39066. }
  39067. }
  39068. declare module "babylonjs/Materials/materialFlags" {
  39069. /**
  39070. * This groups all the flags used to control the materials channel.
  39071. */
  39072. export class MaterialFlags {
  39073. private static _DiffuseTextureEnabled;
  39074. /**
  39075. * Are diffuse textures enabled in the application.
  39076. */
  39077. static DiffuseTextureEnabled: boolean;
  39078. private static _AmbientTextureEnabled;
  39079. /**
  39080. * Are ambient textures enabled in the application.
  39081. */
  39082. static AmbientTextureEnabled: boolean;
  39083. private static _OpacityTextureEnabled;
  39084. /**
  39085. * Are opacity textures enabled in the application.
  39086. */
  39087. static OpacityTextureEnabled: boolean;
  39088. private static _ReflectionTextureEnabled;
  39089. /**
  39090. * Are reflection textures enabled in the application.
  39091. */
  39092. static ReflectionTextureEnabled: boolean;
  39093. private static _EmissiveTextureEnabled;
  39094. /**
  39095. * Are emissive textures enabled in the application.
  39096. */
  39097. static EmissiveTextureEnabled: boolean;
  39098. private static _SpecularTextureEnabled;
  39099. /**
  39100. * Are specular textures enabled in the application.
  39101. */
  39102. static SpecularTextureEnabled: boolean;
  39103. private static _BumpTextureEnabled;
  39104. /**
  39105. * Are bump textures enabled in the application.
  39106. */
  39107. static BumpTextureEnabled: boolean;
  39108. private static _LightmapTextureEnabled;
  39109. /**
  39110. * Are lightmap textures enabled in the application.
  39111. */
  39112. static LightmapTextureEnabled: boolean;
  39113. private static _RefractionTextureEnabled;
  39114. /**
  39115. * Are refraction textures enabled in the application.
  39116. */
  39117. static RefractionTextureEnabled: boolean;
  39118. private static _ColorGradingTextureEnabled;
  39119. /**
  39120. * Are color grading textures enabled in the application.
  39121. */
  39122. static ColorGradingTextureEnabled: boolean;
  39123. private static _FresnelEnabled;
  39124. /**
  39125. * Are fresnels enabled in the application.
  39126. */
  39127. static FresnelEnabled: boolean;
  39128. }
  39129. }
  39130. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39131. /** @hidden */
  39132. export var defaultFragmentDeclaration: {
  39133. name: string;
  39134. shader: string;
  39135. };
  39136. }
  39137. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39138. /** @hidden */
  39139. export var defaultUboDeclaration: {
  39140. name: string;
  39141. shader: string;
  39142. };
  39143. }
  39144. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39145. /** @hidden */
  39146. export var lightFragmentDeclaration: {
  39147. name: string;
  39148. shader: string;
  39149. };
  39150. }
  39151. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39152. /** @hidden */
  39153. export var lightUboDeclaration: {
  39154. name: string;
  39155. shader: string;
  39156. };
  39157. }
  39158. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39159. /** @hidden */
  39160. export var lightsFragmentFunctions: {
  39161. name: string;
  39162. shader: string;
  39163. };
  39164. }
  39165. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39166. /** @hidden */
  39167. export var shadowsFragmentFunctions: {
  39168. name: string;
  39169. shader: string;
  39170. };
  39171. }
  39172. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39173. /** @hidden */
  39174. export var fresnelFunction: {
  39175. name: string;
  39176. shader: string;
  39177. };
  39178. }
  39179. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39180. /** @hidden */
  39181. export var reflectionFunction: {
  39182. name: string;
  39183. shader: string;
  39184. };
  39185. }
  39186. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39187. /** @hidden */
  39188. export var bumpFragmentFunctions: {
  39189. name: string;
  39190. shader: string;
  39191. };
  39192. }
  39193. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39194. /** @hidden */
  39195. export var logDepthDeclaration: {
  39196. name: string;
  39197. shader: string;
  39198. };
  39199. }
  39200. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39201. /** @hidden */
  39202. export var bumpFragment: {
  39203. name: string;
  39204. shader: string;
  39205. };
  39206. }
  39207. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39208. /** @hidden */
  39209. export var depthPrePass: {
  39210. name: string;
  39211. shader: string;
  39212. };
  39213. }
  39214. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39215. /** @hidden */
  39216. export var lightFragment: {
  39217. name: string;
  39218. shader: string;
  39219. };
  39220. }
  39221. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39222. /** @hidden */
  39223. export var logDepthFragment: {
  39224. name: string;
  39225. shader: string;
  39226. };
  39227. }
  39228. declare module "babylonjs/Shaders/default.fragment" {
  39229. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39230. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39231. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39232. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39233. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39234. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39235. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39236. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39237. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39238. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39239. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39240. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39241. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39242. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39243. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39244. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39245. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39246. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39247. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39248. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39249. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39250. /** @hidden */
  39251. export var defaultPixelShader: {
  39252. name: string;
  39253. shader: string;
  39254. };
  39255. }
  39256. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39257. /** @hidden */
  39258. export var defaultVertexDeclaration: {
  39259. name: string;
  39260. shader: string;
  39261. };
  39262. }
  39263. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39264. /** @hidden */
  39265. export var bumpVertexDeclaration: {
  39266. name: string;
  39267. shader: string;
  39268. };
  39269. }
  39270. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39271. /** @hidden */
  39272. export var bumpVertex: {
  39273. name: string;
  39274. shader: string;
  39275. };
  39276. }
  39277. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39278. /** @hidden */
  39279. export var fogVertex: {
  39280. name: string;
  39281. shader: string;
  39282. };
  39283. }
  39284. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39285. /** @hidden */
  39286. export var shadowsVertex: {
  39287. name: string;
  39288. shader: string;
  39289. };
  39290. }
  39291. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39292. /** @hidden */
  39293. export var pointCloudVertex: {
  39294. name: string;
  39295. shader: string;
  39296. };
  39297. }
  39298. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39299. /** @hidden */
  39300. export var logDepthVertex: {
  39301. name: string;
  39302. shader: string;
  39303. };
  39304. }
  39305. declare module "babylonjs/Shaders/default.vertex" {
  39306. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39307. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39308. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39309. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39310. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39311. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39312. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39313. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39314. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39315. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39316. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39317. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39318. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39319. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39320. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39321. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39322. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39323. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39324. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39325. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39326. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39327. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39328. /** @hidden */
  39329. export var defaultVertexShader: {
  39330. name: string;
  39331. shader: string;
  39332. };
  39333. }
  39334. declare module "babylonjs/Materials/standardMaterial" {
  39335. import { SmartArray } from "babylonjs/Misc/smartArray";
  39336. import { IAnimatable } from "babylonjs/Misc/tools";
  39337. import { Nullable } from "babylonjs/types";
  39338. import { Scene } from "babylonjs/scene";
  39339. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39340. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39342. import { Mesh } from "babylonjs/Meshes/mesh";
  39343. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39344. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39345. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39346. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39347. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39348. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39350. import "babylonjs/Shaders/default.fragment";
  39351. import "babylonjs/Shaders/default.vertex";
  39352. /** @hidden */
  39353. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39354. MAINUV1: boolean;
  39355. MAINUV2: boolean;
  39356. DIFFUSE: boolean;
  39357. DIFFUSEDIRECTUV: number;
  39358. AMBIENT: boolean;
  39359. AMBIENTDIRECTUV: number;
  39360. OPACITY: boolean;
  39361. OPACITYDIRECTUV: number;
  39362. OPACITYRGB: boolean;
  39363. REFLECTION: boolean;
  39364. EMISSIVE: boolean;
  39365. EMISSIVEDIRECTUV: number;
  39366. SPECULAR: boolean;
  39367. SPECULARDIRECTUV: number;
  39368. BUMP: boolean;
  39369. BUMPDIRECTUV: number;
  39370. PARALLAX: boolean;
  39371. PARALLAXOCCLUSION: boolean;
  39372. SPECULAROVERALPHA: boolean;
  39373. CLIPPLANE: boolean;
  39374. CLIPPLANE2: boolean;
  39375. CLIPPLANE3: boolean;
  39376. CLIPPLANE4: boolean;
  39377. ALPHATEST: boolean;
  39378. DEPTHPREPASS: boolean;
  39379. ALPHAFROMDIFFUSE: boolean;
  39380. POINTSIZE: boolean;
  39381. FOG: boolean;
  39382. SPECULARTERM: boolean;
  39383. DIFFUSEFRESNEL: boolean;
  39384. OPACITYFRESNEL: boolean;
  39385. REFLECTIONFRESNEL: boolean;
  39386. REFRACTIONFRESNEL: boolean;
  39387. EMISSIVEFRESNEL: boolean;
  39388. FRESNEL: boolean;
  39389. NORMAL: boolean;
  39390. UV1: boolean;
  39391. UV2: boolean;
  39392. VERTEXCOLOR: boolean;
  39393. VERTEXALPHA: boolean;
  39394. NUM_BONE_INFLUENCERS: number;
  39395. BonesPerMesh: number;
  39396. BONETEXTURE: boolean;
  39397. INSTANCES: boolean;
  39398. GLOSSINESS: boolean;
  39399. ROUGHNESS: boolean;
  39400. EMISSIVEASILLUMINATION: boolean;
  39401. LINKEMISSIVEWITHDIFFUSE: boolean;
  39402. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39403. LIGHTMAP: boolean;
  39404. LIGHTMAPDIRECTUV: number;
  39405. OBJECTSPACE_NORMALMAP: boolean;
  39406. USELIGHTMAPASSHADOWMAP: boolean;
  39407. REFLECTIONMAP_3D: boolean;
  39408. REFLECTIONMAP_SPHERICAL: boolean;
  39409. REFLECTIONMAP_PLANAR: boolean;
  39410. REFLECTIONMAP_CUBIC: boolean;
  39411. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39412. REFLECTIONMAP_PROJECTION: boolean;
  39413. REFLECTIONMAP_SKYBOX: boolean;
  39414. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39415. REFLECTIONMAP_EXPLICIT: boolean;
  39416. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39417. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39418. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39419. INVERTCUBICMAP: boolean;
  39420. LOGARITHMICDEPTH: boolean;
  39421. REFRACTION: boolean;
  39422. REFRACTIONMAP_3D: boolean;
  39423. REFLECTIONOVERALPHA: boolean;
  39424. TWOSIDEDLIGHTING: boolean;
  39425. SHADOWFLOAT: boolean;
  39426. MORPHTARGETS: boolean;
  39427. MORPHTARGETS_NORMAL: boolean;
  39428. MORPHTARGETS_TANGENT: boolean;
  39429. NUM_MORPH_INFLUENCERS: number;
  39430. NONUNIFORMSCALING: boolean;
  39431. PREMULTIPLYALPHA: boolean;
  39432. IMAGEPROCESSING: boolean;
  39433. VIGNETTE: boolean;
  39434. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39435. VIGNETTEBLENDMODEOPAQUE: boolean;
  39436. TONEMAPPING: boolean;
  39437. TONEMAPPING_ACES: boolean;
  39438. CONTRAST: boolean;
  39439. COLORCURVES: boolean;
  39440. COLORGRADING: boolean;
  39441. COLORGRADING3D: boolean;
  39442. SAMPLER3DGREENDEPTH: boolean;
  39443. SAMPLER3DBGRMAP: boolean;
  39444. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39445. /**
  39446. * If the reflection texture on this material is in linear color space
  39447. * @hidden
  39448. */
  39449. IS_REFLECTION_LINEAR: boolean;
  39450. /**
  39451. * If the refraction texture on this material is in linear color space
  39452. * @hidden
  39453. */
  39454. IS_REFRACTION_LINEAR: boolean;
  39455. EXPOSURE: boolean;
  39456. constructor();
  39457. setReflectionMode(modeToEnable: string): void;
  39458. }
  39459. /**
  39460. * This is the default material used in Babylon. It is the best trade off between quality
  39461. * and performances.
  39462. * @see http://doc.babylonjs.com/babylon101/materials
  39463. */
  39464. export class StandardMaterial extends PushMaterial {
  39465. private _diffuseTexture;
  39466. /**
  39467. * The basic texture of the material as viewed under a light.
  39468. */
  39469. diffuseTexture: Nullable<BaseTexture>;
  39470. private _ambientTexture;
  39471. /**
  39472. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39473. */
  39474. ambientTexture: Nullable<BaseTexture>;
  39475. private _opacityTexture;
  39476. /**
  39477. * Define the transparency of the material from a texture.
  39478. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39479. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39480. */
  39481. opacityTexture: Nullable<BaseTexture>;
  39482. private _reflectionTexture;
  39483. /**
  39484. * Define the texture used to display the reflection.
  39485. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39486. */
  39487. reflectionTexture: Nullable<BaseTexture>;
  39488. private _emissiveTexture;
  39489. /**
  39490. * Define texture of the material as if self lit.
  39491. * This will be mixed in the final result even in the absence of light.
  39492. */
  39493. emissiveTexture: Nullable<BaseTexture>;
  39494. private _specularTexture;
  39495. /**
  39496. * Define how the color and intensity of the highlight given by the light in the material.
  39497. */
  39498. specularTexture: Nullable<BaseTexture>;
  39499. private _bumpTexture;
  39500. /**
  39501. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39502. * 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.
  39503. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39504. */
  39505. bumpTexture: Nullable<BaseTexture>;
  39506. private _lightmapTexture;
  39507. /**
  39508. * Complex lighting can be computationally expensive to compute at runtime.
  39509. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39510. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39511. */
  39512. lightmapTexture: Nullable<BaseTexture>;
  39513. private _refractionTexture;
  39514. /**
  39515. * Define the texture used to display the refraction.
  39516. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39517. */
  39518. refractionTexture: Nullable<BaseTexture>;
  39519. /**
  39520. * The color of the material lit by the environmental background lighting.
  39521. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39522. */
  39523. ambientColor: Color3;
  39524. /**
  39525. * The basic color of the material as viewed under a light.
  39526. */
  39527. diffuseColor: Color3;
  39528. /**
  39529. * Define how the color and intensity of the highlight given by the light in the material.
  39530. */
  39531. specularColor: Color3;
  39532. /**
  39533. * Define the color of the material as if self lit.
  39534. * This will be mixed in the final result even in the absence of light.
  39535. */
  39536. emissiveColor: Color3;
  39537. /**
  39538. * Defines how sharp are the highlights in the material.
  39539. * The bigger the value the sharper giving a more glossy feeling to the result.
  39540. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39541. */
  39542. specularPower: number;
  39543. private _useAlphaFromDiffuseTexture;
  39544. /**
  39545. * Does the transparency come from the diffuse texture alpha channel.
  39546. */
  39547. useAlphaFromDiffuseTexture: boolean;
  39548. private _useEmissiveAsIllumination;
  39549. /**
  39550. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39551. */
  39552. useEmissiveAsIllumination: boolean;
  39553. private _linkEmissiveWithDiffuse;
  39554. /**
  39555. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39556. * the emissive level when the final color is close to one.
  39557. */
  39558. linkEmissiveWithDiffuse: boolean;
  39559. private _useSpecularOverAlpha;
  39560. /**
  39561. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39562. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39563. */
  39564. useSpecularOverAlpha: boolean;
  39565. private _useReflectionOverAlpha;
  39566. /**
  39567. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39568. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39569. */
  39570. useReflectionOverAlpha: boolean;
  39571. private _disableLighting;
  39572. /**
  39573. * Does lights from the scene impacts this material.
  39574. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39575. */
  39576. disableLighting: boolean;
  39577. private _useObjectSpaceNormalMap;
  39578. /**
  39579. * Allows using an object space normal map (instead of tangent space).
  39580. */
  39581. useObjectSpaceNormalMap: boolean;
  39582. private _useParallax;
  39583. /**
  39584. * Is parallax enabled or not.
  39585. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39586. */
  39587. useParallax: boolean;
  39588. private _useParallaxOcclusion;
  39589. /**
  39590. * Is parallax occlusion enabled or not.
  39591. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39592. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39593. */
  39594. useParallaxOcclusion: boolean;
  39595. /**
  39596. * 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.
  39597. */
  39598. parallaxScaleBias: number;
  39599. private _roughness;
  39600. /**
  39601. * Helps to define how blurry the reflections should appears in the material.
  39602. */
  39603. roughness: number;
  39604. /**
  39605. * In case of refraction, define the value of the indice of refraction.
  39606. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39607. */
  39608. indexOfRefraction: number;
  39609. /**
  39610. * Invert the refraction texture alongside the y axis.
  39611. * It can be useful with procedural textures or probe for instance.
  39612. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39613. */
  39614. invertRefractionY: boolean;
  39615. /**
  39616. * Defines the alpha limits in alpha test mode.
  39617. */
  39618. alphaCutOff: number;
  39619. private _useLightmapAsShadowmap;
  39620. /**
  39621. * In case of light mapping, define whether the map contains light or shadow informations.
  39622. */
  39623. useLightmapAsShadowmap: boolean;
  39624. private _diffuseFresnelParameters;
  39625. /**
  39626. * Define the diffuse fresnel parameters of the material.
  39627. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39628. */
  39629. diffuseFresnelParameters: FresnelParameters;
  39630. private _opacityFresnelParameters;
  39631. /**
  39632. * Define the opacity fresnel parameters of the material.
  39633. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39634. */
  39635. opacityFresnelParameters: FresnelParameters;
  39636. private _reflectionFresnelParameters;
  39637. /**
  39638. * Define the reflection fresnel parameters of the material.
  39639. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39640. */
  39641. reflectionFresnelParameters: FresnelParameters;
  39642. private _refractionFresnelParameters;
  39643. /**
  39644. * Define the refraction fresnel parameters of the material.
  39645. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39646. */
  39647. refractionFresnelParameters: FresnelParameters;
  39648. private _emissiveFresnelParameters;
  39649. /**
  39650. * Define the emissive fresnel parameters of the material.
  39651. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39652. */
  39653. emissiveFresnelParameters: FresnelParameters;
  39654. private _useReflectionFresnelFromSpecular;
  39655. /**
  39656. * If true automatically deducts the fresnels values from the material specularity.
  39657. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39658. */
  39659. useReflectionFresnelFromSpecular: boolean;
  39660. private _useGlossinessFromSpecularMapAlpha;
  39661. /**
  39662. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39663. */
  39664. useGlossinessFromSpecularMapAlpha: boolean;
  39665. private _maxSimultaneousLights;
  39666. /**
  39667. * Defines the maximum number of lights that can be used in the material
  39668. */
  39669. maxSimultaneousLights: number;
  39670. private _invertNormalMapX;
  39671. /**
  39672. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39673. */
  39674. invertNormalMapX: boolean;
  39675. private _invertNormalMapY;
  39676. /**
  39677. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39678. */
  39679. invertNormalMapY: boolean;
  39680. private _twoSidedLighting;
  39681. /**
  39682. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39683. */
  39684. twoSidedLighting: boolean;
  39685. /**
  39686. * Default configuration related to image processing available in the standard Material.
  39687. */
  39688. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39689. /**
  39690. * Gets the image processing configuration used either in this material.
  39691. */
  39692. /**
  39693. * Sets the Default image processing configuration used either in the this material.
  39694. *
  39695. * If sets to null, the scene one is in use.
  39696. */
  39697. imageProcessingConfiguration: ImageProcessingConfiguration;
  39698. /**
  39699. * Keep track of the image processing observer to allow dispose and replace.
  39700. */
  39701. private _imageProcessingObserver;
  39702. /**
  39703. * Attaches a new image processing configuration to the Standard Material.
  39704. * @param configuration
  39705. */
  39706. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39707. /**
  39708. * Gets wether the color curves effect is enabled.
  39709. */
  39710. /**
  39711. * Sets wether the color curves effect is enabled.
  39712. */
  39713. cameraColorCurvesEnabled: boolean;
  39714. /**
  39715. * Gets wether the color grading effect is enabled.
  39716. */
  39717. /**
  39718. * Gets wether the color grading effect is enabled.
  39719. */
  39720. cameraColorGradingEnabled: boolean;
  39721. /**
  39722. * Gets wether tonemapping is enabled or not.
  39723. */
  39724. /**
  39725. * Sets wether tonemapping is enabled or not
  39726. */
  39727. cameraToneMappingEnabled: boolean;
  39728. /**
  39729. * The camera exposure used on this material.
  39730. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39731. * This corresponds to a photographic exposure.
  39732. */
  39733. /**
  39734. * The camera exposure used on this material.
  39735. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39736. * This corresponds to a photographic exposure.
  39737. */
  39738. cameraExposure: number;
  39739. /**
  39740. * Gets The camera contrast used on this material.
  39741. */
  39742. /**
  39743. * Sets The camera contrast used on this material.
  39744. */
  39745. cameraContrast: number;
  39746. /**
  39747. * Gets the Color Grading 2D Lookup Texture.
  39748. */
  39749. /**
  39750. * Sets the Color Grading 2D Lookup Texture.
  39751. */
  39752. cameraColorGradingTexture: Nullable<BaseTexture>;
  39753. /**
  39754. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39755. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39756. * 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;
  39757. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39758. */
  39759. /**
  39760. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39761. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39762. * 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;
  39763. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39764. */
  39765. cameraColorCurves: Nullable<ColorCurves>;
  39766. /**
  39767. * Custom callback helping to override the default shader used in the material.
  39768. */
  39769. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39770. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39771. protected _worldViewProjectionMatrix: Matrix;
  39772. protected _globalAmbientColor: Color3;
  39773. protected _useLogarithmicDepth: boolean;
  39774. /**
  39775. * Instantiates a new standard material.
  39776. * This is the default material used in Babylon. It is the best trade off between quality
  39777. * and performances.
  39778. * @see http://doc.babylonjs.com/babylon101/materials
  39779. * @param name Define the name of the material in the scene
  39780. * @param scene Define the scene the material belong to
  39781. */
  39782. constructor(name: string, scene: Scene);
  39783. /**
  39784. * Gets a boolean indicating that current material needs to register RTT
  39785. */
  39786. readonly hasRenderTargetTextures: boolean;
  39787. /**
  39788. * Gets the current class name of the material e.g. "StandardMaterial"
  39789. * Mainly use in serialization.
  39790. * @returns the class name
  39791. */
  39792. getClassName(): string;
  39793. /**
  39794. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39795. * You can try switching to logarithmic depth.
  39796. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39797. */
  39798. useLogarithmicDepth: boolean;
  39799. /**
  39800. * Specifies if the material will require alpha blending
  39801. * @returns a boolean specifying if alpha blending is needed
  39802. */
  39803. needAlphaBlending(): boolean;
  39804. /**
  39805. * Specifies if this material should be rendered in alpha test mode
  39806. * @returns a boolean specifying if an alpha test is needed.
  39807. */
  39808. needAlphaTesting(): boolean;
  39809. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39810. /**
  39811. * Get the texture used for alpha test purpose.
  39812. * @returns the diffuse texture in case of the standard material.
  39813. */
  39814. getAlphaTestTexture(): Nullable<BaseTexture>;
  39815. /**
  39816. * Get if the submesh is ready to be used and all its information available.
  39817. * Child classes can use it to update shaders
  39818. * @param mesh defines the mesh to check
  39819. * @param subMesh defines which submesh to check
  39820. * @param useInstances specifies that instances should be used
  39821. * @returns a boolean indicating that the submesh is ready or not
  39822. */
  39823. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39824. /**
  39825. * Builds the material UBO layouts.
  39826. * Used internally during the effect preparation.
  39827. */
  39828. buildUniformLayout(): void;
  39829. /**
  39830. * Unbinds the material from the mesh
  39831. */
  39832. unbind(): void;
  39833. /**
  39834. * Binds the submesh to this material by preparing the effect and shader to draw
  39835. * @param world defines the world transformation matrix
  39836. * @param mesh defines the mesh containing the submesh
  39837. * @param subMesh defines the submesh to bind the material to
  39838. */
  39839. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39840. /**
  39841. * Get the list of animatables in the material.
  39842. * @returns the list of animatables object used in the material
  39843. */
  39844. getAnimatables(): IAnimatable[];
  39845. /**
  39846. * Gets the active textures from the material
  39847. * @returns an array of textures
  39848. */
  39849. getActiveTextures(): BaseTexture[];
  39850. /**
  39851. * Specifies if the material uses a texture
  39852. * @param texture defines the texture to check against the material
  39853. * @returns a boolean specifying if the material uses the texture
  39854. */
  39855. hasTexture(texture: BaseTexture): boolean;
  39856. /**
  39857. * Disposes the material
  39858. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39859. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39860. */
  39861. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39862. /**
  39863. * Makes a duplicate of the material, and gives it a new name
  39864. * @param name defines the new name for the duplicated material
  39865. * @returns the cloned material
  39866. */
  39867. clone(name: string): StandardMaterial;
  39868. /**
  39869. * Serializes this material in a JSON representation
  39870. * @returns the serialized material object
  39871. */
  39872. serialize(): any;
  39873. /**
  39874. * Creates a standard material from parsed material data
  39875. * @param source defines the JSON representation of the material
  39876. * @param scene defines the hosting scene
  39877. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39878. * @returns a new standard material
  39879. */
  39880. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39881. /**
  39882. * Are diffuse textures enabled in the application.
  39883. */
  39884. static DiffuseTextureEnabled: boolean;
  39885. /**
  39886. * Are ambient textures enabled in the application.
  39887. */
  39888. static AmbientTextureEnabled: boolean;
  39889. /**
  39890. * Are opacity textures enabled in the application.
  39891. */
  39892. static OpacityTextureEnabled: boolean;
  39893. /**
  39894. * Are reflection textures enabled in the application.
  39895. */
  39896. static ReflectionTextureEnabled: boolean;
  39897. /**
  39898. * Are emissive textures enabled in the application.
  39899. */
  39900. static EmissiveTextureEnabled: boolean;
  39901. /**
  39902. * Are specular textures enabled in the application.
  39903. */
  39904. static SpecularTextureEnabled: boolean;
  39905. /**
  39906. * Are bump textures enabled in the application.
  39907. */
  39908. static BumpTextureEnabled: boolean;
  39909. /**
  39910. * Are lightmap textures enabled in the application.
  39911. */
  39912. static LightmapTextureEnabled: boolean;
  39913. /**
  39914. * Are refraction textures enabled in the application.
  39915. */
  39916. static RefractionTextureEnabled: boolean;
  39917. /**
  39918. * Are color grading textures enabled in the application.
  39919. */
  39920. static ColorGradingTextureEnabled: boolean;
  39921. /**
  39922. * Are fresnels enabled in the application.
  39923. */
  39924. static FresnelEnabled: boolean;
  39925. }
  39926. }
  39927. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39928. import { Scene } from "babylonjs/scene";
  39929. import { Texture } from "babylonjs/Materials/Textures/texture";
  39930. /**
  39931. * A class extending Texture allowing drawing on a texture
  39932. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39933. */
  39934. export class DynamicTexture extends Texture {
  39935. private _generateMipMaps;
  39936. private _canvas;
  39937. private _context;
  39938. private _engine;
  39939. /**
  39940. * Creates a DynamicTexture
  39941. * @param name defines the name of the texture
  39942. * @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
  39943. * @param scene defines the scene where you want the texture
  39944. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39945. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39946. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39947. */
  39948. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39949. /**
  39950. * Get the current class name of the texture useful for serialization or dynamic coding.
  39951. * @returns "DynamicTexture"
  39952. */
  39953. getClassName(): string;
  39954. /**
  39955. * Gets the current state of canRescale
  39956. */
  39957. readonly canRescale: boolean;
  39958. private _recreate;
  39959. /**
  39960. * Scales the texture
  39961. * @param ratio the scale factor to apply to both width and height
  39962. */
  39963. scale(ratio: number): void;
  39964. /**
  39965. * Resizes the texture
  39966. * @param width the new width
  39967. * @param height the new height
  39968. */
  39969. scaleTo(width: number, height: number): void;
  39970. /**
  39971. * Gets the context of the canvas used by the texture
  39972. * @returns the canvas context of the dynamic texture
  39973. */
  39974. getContext(): CanvasRenderingContext2D;
  39975. /**
  39976. * Clears the texture
  39977. */
  39978. clear(): void;
  39979. /**
  39980. * Updates the texture
  39981. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39982. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39983. */
  39984. update(invertY?: boolean, premulAlpha?: boolean): void;
  39985. /**
  39986. * Draws text onto the texture
  39987. * @param text defines the text to be drawn
  39988. * @param x defines the placement of the text from the left
  39989. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39990. * @param font defines the font to be used with font-style, font-size, font-name
  39991. * @param color defines the color used for the text
  39992. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39993. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39994. * @param update defines whether texture is immediately update (default is true)
  39995. */
  39996. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39997. /**
  39998. * Clones the texture
  39999. * @returns the clone of the texture.
  40000. */
  40001. clone(): DynamicTexture;
  40002. /**
  40003. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40004. * @returns a serialized dynamic texture object
  40005. */
  40006. serialize(): any;
  40007. /** @hidden */
  40008. _rebuild(): void;
  40009. }
  40010. }
  40011. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40012. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40013. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40014. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40015. /** @hidden */
  40016. export var imageProcessingPixelShader: {
  40017. name: string;
  40018. shader: string;
  40019. };
  40020. }
  40021. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40022. import { Nullable } from "babylonjs/types";
  40023. import { Color4 } from "babylonjs/Maths/math";
  40024. import { Camera } from "babylonjs/Cameras/camera";
  40025. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40026. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40027. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40028. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40029. import { Engine } from "babylonjs/Engines/engine";
  40030. import "babylonjs/Shaders/imageProcessing.fragment";
  40031. import "babylonjs/Shaders/postprocess.vertex";
  40032. /**
  40033. * ImageProcessingPostProcess
  40034. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40035. */
  40036. export class ImageProcessingPostProcess extends PostProcess {
  40037. /**
  40038. * Default configuration related to image processing available in the PBR Material.
  40039. */
  40040. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40041. /**
  40042. * Gets the image processing configuration used either in this material.
  40043. */
  40044. /**
  40045. * Sets the Default image processing configuration used either in the this material.
  40046. *
  40047. * If sets to null, the scene one is in use.
  40048. */
  40049. imageProcessingConfiguration: ImageProcessingConfiguration;
  40050. /**
  40051. * Keep track of the image processing observer to allow dispose and replace.
  40052. */
  40053. private _imageProcessingObserver;
  40054. /**
  40055. * Attaches a new image processing configuration to the PBR Material.
  40056. * @param configuration
  40057. */
  40058. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40059. /**
  40060. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40061. */
  40062. /**
  40063. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40064. */
  40065. colorCurves: Nullable<ColorCurves>;
  40066. /**
  40067. * Gets wether the color curves effect is enabled.
  40068. */
  40069. /**
  40070. * Sets wether the color curves effect is enabled.
  40071. */
  40072. colorCurvesEnabled: boolean;
  40073. /**
  40074. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40075. */
  40076. /**
  40077. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40078. */
  40079. colorGradingTexture: Nullable<BaseTexture>;
  40080. /**
  40081. * Gets wether the color grading effect is enabled.
  40082. */
  40083. /**
  40084. * Gets wether the color grading effect is enabled.
  40085. */
  40086. colorGradingEnabled: boolean;
  40087. /**
  40088. * Gets exposure used in the effect.
  40089. */
  40090. /**
  40091. * Sets exposure used in the effect.
  40092. */
  40093. exposure: number;
  40094. /**
  40095. * Gets wether tonemapping is enabled or not.
  40096. */
  40097. /**
  40098. * Sets wether tonemapping is enabled or not
  40099. */
  40100. toneMappingEnabled: boolean;
  40101. /**
  40102. * Gets contrast used in the effect.
  40103. */
  40104. /**
  40105. * Sets contrast used in the effect.
  40106. */
  40107. contrast: number;
  40108. /**
  40109. * Gets Vignette stretch size.
  40110. */
  40111. /**
  40112. * Sets Vignette stretch size.
  40113. */
  40114. vignetteStretch: number;
  40115. /**
  40116. * Gets Vignette centre X Offset.
  40117. */
  40118. /**
  40119. * Sets Vignette centre X Offset.
  40120. */
  40121. vignetteCentreX: number;
  40122. /**
  40123. * Gets Vignette centre Y Offset.
  40124. */
  40125. /**
  40126. * Sets Vignette centre Y Offset.
  40127. */
  40128. vignetteCentreY: number;
  40129. /**
  40130. * Gets Vignette weight or intensity of the vignette effect.
  40131. */
  40132. /**
  40133. * Sets Vignette weight or intensity of the vignette effect.
  40134. */
  40135. vignetteWeight: number;
  40136. /**
  40137. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40138. * if vignetteEnabled is set to true.
  40139. */
  40140. /**
  40141. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40142. * if vignetteEnabled is set to true.
  40143. */
  40144. vignetteColor: Color4;
  40145. /**
  40146. * Gets Camera field of view used by the Vignette effect.
  40147. */
  40148. /**
  40149. * Sets Camera field of view used by the Vignette effect.
  40150. */
  40151. vignetteCameraFov: number;
  40152. /**
  40153. * Gets the vignette blend mode allowing different kind of effect.
  40154. */
  40155. /**
  40156. * Sets the vignette blend mode allowing different kind of effect.
  40157. */
  40158. vignetteBlendMode: number;
  40159. /**
  40160. * Gets wether the vignette effect is enabled.
  40161. */
  40162. /**
  40163. * Sets wether the vignette effect is enabled.
  40164. */
  40165. vignetteEnabled: boolean;
  40166. private _fromLinearSpace;
  40167. /**
  40168. * Gets wether the input of the processing is in Gamma or Linear Space.
  40169. */
  40170. /**
  40171. * Sets wether the input of the processing is in Gamma or Linear Space.
  40172. */
  40173. fromLinearSpace: boolean;
  40174. /**
  40175. * Defines cache preventing GC.
  40176. */
  40177. private _defines;
  40178. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40179. /**
  40180. * "ImageProcessingPostProcess"
  40181. * @returns "ImageProcessingPostProcess"
  40182. */
  40183. getClassName(): string;
  40184. protected _updateParameters(): void;
  40185. dispose(camera?: Camera): void;
  40186. }
  40187. }
  40188. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40189. import { Observable } from "babylonjs/Misc/observable";
  40190. import { Nullable } from "babylonjs/types";
  40191. import { Camera } from "babylonjs/Cameras/camera";
  40192. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40193. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40194. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40195. import { Scene } from "babylonjs/scene";
  40196. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40197. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40199. import { Mesh } from "babylonjs/Meshes/mesh";
  40200. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40201. /**
  40202. * Options to modify the vr teleportation behavior.
  40203. */
  40204. export interface VRTeleportationOptions {
  40205. /**
  40206. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40207. */
  40208. floorMeshName?: string;
  40209. /**
  40210. * A list of meshes to be used as the teleportation floor. (default: empty)
  40211. */
  40212. floorMeshes?: Mesh[];
  40213. }
  40214. /**
  40215. * Options to modify the vr experience helper's behavior.
  40216. */
  40217. export interface VRExperienceHelperOptions extends WebVROptions {
  40218. /**
  40219. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40220. */
  40221. createDeviceOrientationCamera?: boolean;
  40222. /**
  40223. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40224. */
  40225. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40226. /**
  40227. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40228. */
  40229. laserToggle?: boolean;
  40230. /**
  40231. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40232. */
  40233. floorMeshes?: Mesh[];
  40234. }
  40235. /**
  40236. * Helps to quickly add VR support to an existing scene.
  40237. * See http://doc.babylonjs.com/how_to/webvr_helper
  40238. */
  40239. export class VRExperienceHelper {
  40240. /** Options to modify the vr experience helper's behavior. */
  40241. webVROptions: VRExperienceHelperOptions;
  40242. private _scene;
  40243. private _position;
  40244. private _btnVR;
  40245. private _btnVRDisplayed;
  40246. private _webVRsupported;
  40247. private _webVRready;
  40248. private _webVRrequesting;
  40249. private _webVRpresenting;
  40250. private _hasEnteredVR;
  40251. private _fullscreenVRpresenting;
  40252. private _canvas;
  40253. private _webVRCamera;
  40254. private _vrDeviceOrientationCamera;
  40255. private _deviceOrientationCamera;
  40256. private _existingCamera;
  40257. private _onKeyDown;
  40258. private _onVrDisplayPresentChange;
  40259. private _onVRDisplayChanged;
  40260. private _onVRRequestPresentStart;
  40261. private _onVRRequestPresentComplete;
  40262. /**
  40263. * Observable raised when entering VR.
  40264. */
  40265. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40266. /**
  40267. * Observable raised when exiting VR.
  40268. */
  40269. onExitingVRObservable: Observable<VRExperienceHelper>;
  40270. /**
  40271. * Observable raised when controller mesh is loaded.
  40272. */
  40273. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40274. /** Return this.onEnteringVRObservable
  40275. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40276. */
  40277. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40278. /** Return this.onExitingVRObservable
  40279. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40280. */
  40281. readonly onExitingVR: Observable<VRExperienceHelper>;
  40282. /** Return this.onControllerMeshLoadedObservable
  40283. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40284. */
  40285. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40286. private _rayLength;
  40287. private _useCustomVRButton;
  40288. private _teleportationRequested;
  40289. private _teleportActive;
  40290. private _floorMeshName;
  40291. private _floorMeshesCollection;
  40292. private _rotationAllowed;
  40293. private _teleportBackwardsVector;
  40294. private _teleportationTarget;
  40295. private _isDefaultTeleportationTarget;
  40296. private _postProcessMove;
  40297. private _teleportationFillColor;
  40298. private _teleportationBorderColor;
  40299. private _rotationAngle;
  40300. private _haloCenter;
  40301. private _cameraGazer;
  40302. private _padSensibilityUp;
  40303. private _padSensibilityDown;
  40304. private _leftController;
  40305. private _rightController;
  40306. /**
  40307. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40308. */
  40309. onNewMeshSelected: Observable<AbstractMesh>;
  40310. /**
  40311. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40312. */
  40313. onNewMeshPicked: Observable<PickingInfo>;
  40314. private _circleEase;
  40315. /**
  40316. * Observable raised before camera teleportation
  40317. */
  40318. onBeforeCameraTeleport: Observable<Vector3>;
  40319. /**
  40320. * Observable raised after camera teleportation
  40321. */
  40322. onAfterCameraTeleport: Observable<Vector3>;
  40323. /**
  40324. * Observable raised when current selected mesh gets unselected
  40325. */
  40326. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40327. private _raySelectionPredicate;
  40328. /**
  40329. * To be optionaly changed by user to define custom ray selection
  40330. */
  40331. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40332. /**
  40333. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40334. */
  40335. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40336. /**
  40337. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40338. */
  40339. teleportationEnabled: boolean;
  40340. private _defaultHeight;
  40341. private _teleportationInitialized;
  40342. private _interactionsEnabled;
  40343. private _interactionsRequested;
  40344. private _displayGaze;
  40345. private _displayLaserPointer;
  40346. /**
  40347. * The mesh used to display where the user is going to teleport.
  40348. */
  40349. /**
  40350. * Sets the mesh to be used to display where the user is going to teleport.
  40351. */
  40352. teleportationTarget: Mesh;
  40353. /**
  40354. * 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
  40355. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40356. * See http://doc.babylonjs.com/resources/baking_transformations
  40357. */
  40358. gazeTrackerMesh: Mesh;
  40359. /**
  40360. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40361. */
  40362. updateGazeTrackerScale: boolean;
  40363. /**
  40364. * If the gaze trackers color should be updated when selecting meshes
  40365. */
  40366. updateGazeTrackerColor: boolean;
  40367. /**
  40368. * The gaze tracking mesh corresponding to the left controller
  40369. */
  40370. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40371. /**
  40372. * The gaze tracking mesh corresponding to the right controller
  40373. */
  40374. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40375. /**
  40376. * If the ray of the gaze should be displayed.
  40377. */
  40378. /**
  40379. * Sets if the ray of the gaze should be displayed.
  40380. */
  40381. displayGaze: boolean;
  40382. /**
  40383. * If the ray of the LaserPointer should be displayed.
  40384. */
  40385. /**
  40386. * Sets if the ray of the LaserPointer should be displayed.
  40387. */
  40388. displayLaserPointer: boolean;
  40389. /**
  40390. * The deviceOrientationCamera used as the camera when not in VR.
  40391. */
  40392. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40393. /**
  40394. * Based on the current WebVR support, returns the current VR camera used.
  40395. */
  40396. readonly currentVRCamera: Nullable<Camera>;
  40397. /**
  40398. * The webVRCamera which is used when in VR.
  40399. */
  40400. readonly webVRCamera: WebVRFreeCamera;
  40401. /**
  40402. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40403. */
  40404. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40405. private readonly _teleportationRequestInitiated;
  40406. /**
  40407. * Instantiates a VRExperienceHelper.
  40408. * Helps to quickly add VR support to an existing scene.
  40409. * @param scene The scene the VRExperienceHelper belongs to.
  40410. * @param webVROptions Options to modify the vr experience helper's behavior.
  40411. */
  40412. constructor(scene: Scene,
  40413. /** Options to modify the vr experience helper's behavior. */
  40414. webVROptions?: VRExperienceHelperOptions);
  40415. private _onDefaultMeshLoaded;
  40416. private _onResize;
  40417. private _onFullscreenChange;
  40418. /**
  40419. * Gets a value indicating if we are currently in VR mode.
  40420. */
  40421. readonly isInVRMode: boolean;
  40422. private onVrDisplayPresentChange;
  40423. private onVRDisplayChanged;
  40424. private moveButtonToBottomRight;
  40425. private displayVRButton;
  40426. private updateButtonVisibility;
  40427. private _cachedAngularSensibility;
  40428. /**
  40429. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40430. * Otherwise, will use the fullscreen API.
  40431. */
  40432. enterVR(): void;
  40433. /**
  40434. * Attempt to exit VR, or fullscreen.
  40435. */
  40436. exitVR(): void;
  40437. /**
  40438. * The position of the vr experience helper.
  40439. */
  40440. /**
  40441. * Sets the position of the vr experience helper.
  40442. */
  40443. position: Vector3;
  40444. /**
  40445. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40446. */
  40447. enableInteractions(): void;
  40448. private readonly _noControllerIsActive;
  40449. private beforeRender;
  40450. private _isTeleportationFloor;
  40451. /**
  40452. * Adds a floor mesh to be used for teleportation.
  40453. * @param floorMesh the mesh to be used for teleportation.
  40454. */
  40455. addFloorMesh(floorMesh: Mesh): void;
  40456. /**
  40457. * Removes a floor mesh from being used for teleportation.
  40458. * @param floorMesh the mesh to be removed.
  40459. */
  40460. removeFloorMesh(floorMesh: Mesh): void;
  40461. /**
  40462. * Enables interactions and teleportation using the VR controllers and gaze.
  40463. * @param vrTeleportationOptions options to modify teleportation behavior.
  40464. */
  40465. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40466. private _onNewGamepadConnected;
  40467. private _tryEnableInteractionOnController;
  40468. private _onNewGamepadDisconnected;
  40469. private _enableInteractionOnController;
  40470. private _checkTeleportWithRay;
  40471. private _checkRotate;
  40472. private _checkTeleportBackwards;
  40473. private _enableTeleportationOnController;
  40474. private _createTeleportationCircles;
  40475. private _displayTeleportationTarget;
  40476. private _hideTeleportationTarget;
  40477. private _rotateCamera;
  40478. private _moveTeleportationSelectorTo;
  40479. private _workingVector;
  40480. private _workingQuaternion;
  40481. private _workingMatrix;
  40482. /**
  40483. * Teleports the users feet to the desired location
  40484. * @param location The location where the user's feet should be placed
  40485. */
  40486. teleportCamera(location: Vector3): void;
  40487. private _convertNormalToDirectionOfRay;
  40488. private _castRayAndSelectObject;
  40489. private _notifySelectedMeshUnselected;
  40490. /**
  40491. * Sets the color of the laser ray from the vr controllers.
  40492. * @param color new color for the ray.
  40493. */
  40494. changeLaserColor(color: Color3): void;
  40495. /**
  40496. * Sets the color of the ray from the vr headsets gaze.
  40497. * @param color new color for the ray.
  40498. */
  40499. changeGazeColor(color: Color3): void;
  40500. /**
  40501. * Exits VR and disposes of the vr experience helper
  40502. */
  40503. dispose(): void;
  40504. /**
  40505. * Gets the name of the VRExperienceHelper class
  40506. * @returns "VRExperienceHelper"
  40507. */
  40508. getClassName(): string;
  40509. }
  40510. }
  40511. declare module "babylonjs/Cameras/VR/index" {
  40512. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40513. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40514. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40515. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40516. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40517. export * from "babylonjs/Cameras/VR/webVRCamera";
  40518. }
  40519. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40520. import { Observable } from "babylonjs/Misc/observable";
  40521. import { Nullable } from "babylonjs/types";
  40522. import { IDisposable, Scene } from "babylonjs/scene";
  40523. import { Vector3 } from "babylonjs/Maths/math";
  40524. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40525. import { Ray } from "babylonjs/Culling/ray";
  40526. /**
  40527. * Manages an XRSession
  40528. * @see https://doc.babylonjs.com/how_to/webxr
  40529. */
  40530. export class WebXRSessionManager implements IDisposable {
  40531. private scene;
  40532. /**
  40533. * Fires every time a new xrFrame arrives which can be used to update the camera
  40534. */
  40535. onXRFrameObservable: Observable<any>;
  40536. /**
  40537. * Fires when the xr session is ended either by the device or manually done
  40538. */
  40539. onXRSessionEnded: Observable<any>;
  40540. /** @hidden */
  40541. _xrSession: XRSession;
  40542. /** @hidden */
  40543. _frameOfReference: XRFrameOfReference;
  40544. /** @hidden */
  40545. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40546. /** @hidden */
  40547. _currentXRFrame: Nullable<XRFrame>;
  40548. private _xrNavigator;
  40549. private _xrDevice;
  40550. private _tmpMatrix;
  40551. /**
  40552. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40553. * @param scene The scene which the session should be created for
  40554. */
  40555. constructor(scene: Scene);
  40556. /**
  40557. * Initializes the manager
  40558. * After initialization enterXR can be called to start an XR session
  40559. * @returns Promise which resolves after it is initialized
  40560. */
  40561. initializeAsync(): Promise<void>;
  40562. /**
  40563. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40564. * @param sessionCreationOptions xr options to create the session with
  40565. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40566. * @returns Promise which resolves after it enters XR
  40567. */
  40568. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40569. /**
  40570. * Stops the xrSession and restores the renderloop
  40571. * @returns Promise which resolves after it exits XR
  40572. */
  40573. exitXRAsync(): Promise<void>;
  40574. /**
  40575. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40576. * @param ray ray to cast into the environment
  40577. * @returns Promise which resolves with a collision point in the environment if it exists
  40578. */
  40579. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40580. /**
  40581. * Checks if a session would be supported for the creation options specified
  40582. * @param options creation options to check if they are supported
  40583. * @returns true if supported
  40584. */
  40585. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40586. /**
  40587. * @hidden
  40588. * Converts the render layer of xrSession to a render target
  40589. * @param session session to create render target for
  40590. * @param scene scene the new render target should be created for
  40591. */
  40592. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40593. /**
  40594. * Disposes of the session manager
  40595. */
  40596. dispose(): void;
  40597. }
  40598. }
  40599. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40600. import { Scene } from "babylonjs/scene";
  40601. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40602. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40603. /**
  40604. * WebXR Camera which holds the views for the xrSession
  40605. * @see https://doc.babylonjs.com/how_to/webxr
  40606. */
  40607. export class WebXRCamera extends FreeCamera {
  40608. private static _TmpMatrix;
  40609. /**
  40610. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40611. * @param name the name of the camera
  40612. * @param scene the scene to add the camera to
  40613. */
  40614. constructor(name: string, scene: Scene);
  40615. private _updateNumberOfRigCameras;
  40616. /** @hidden */
  40617. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40618. /**
  40619. * Updates the cameras position from the current pose information of the XR session
  40620. * @param xrSessionManager the session containing pose information
  40621. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40622. */
  40623. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40624. }
  40625. }
  40626. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40627. import { Nullable } from "babylonjs/types";
  40628. import { Observable } from "babylonjs/Misc/observable";
  40629. import { IDisposable, Scene } from "babylonjs/scene";
  40630. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40632. import { Ray } from "babylonjs/Culling/ray";
  40633. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40634. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40635. /**
  40636. * States of the webXR experience
  40637. */
  40638. export enum WebXRState {
  40639. /**
  40640. * Transitioning to being in XR mode
  40641. */
  40642. ENTERING_XR = 0,
  40643. /**
  40644. * Transitioning to non XR mode
  40645. */
  40646. EXITING_XR = 1,
  40647. /**
  40648. * In XR mode and presenting
  40649. */
  40650. IN_XR = 2,
  40651. /**
  40652. * Not entered XR mode
  40653. */
  40654. NOT_IN_XR = 3
  40655. }
  40656. /**
  40657. * Helper class used to enable XR
  40658. * @see https://doc.babylonjs.com/how_to/webxr
  40659. */
  40660. export class WebXRExperienceHelper implements IDisposable {
  40661. private scene;
  40662. /**
  40663. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  40664. */
  40665. container: AbstractMesh;
  40666. /**
  40667. * Camera used to render xr content
  40668. */
  40669. camera: WebXRCamera;
  40670. /**
  40671. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40672. */
  40673. state: WebXRState;
  40674. private _setState;
  40675. private static _TmpVector;
  40676. /**
  40677. * Fires when the state of the experience helper has changed
  40678. */
  40679. onStateChangedObservable: Observable<WebXRState>;
  40680. /** @hidden */
  40681. _sessionManager: WebXRSessionManager;
  40682. private _nonVRCamera;
  40683. private _originalSceneAutoClear;
  40684. private _supported;
  40685. /**
  40686. * Creates the experience helper
  40687. * @param scene the scene to attach the experience helper to
  40688. * @returns a promise for the experience helper
  40689. */
  40690. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40691. /**
  40692. * Creates a WebXRExperienceHelper
  40693. * @param scene The scene the helper should be created in
  40694. */
  40695. private constructor();
  40696. /**
  40697. * Exits XR mode and returns the scene to its original state
  40698. * @returns promise that resolves after xr mode has exited
  40699. */
  40700. exitXRAsync(): Promise<void>;
  40701. /**
  40702. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40703. * @param sessionCreationOptions options for the XR session
  40704. * @param frameOfReference frame of reference of the XR session
  40705. * @returns promise that resolves after xr mode has entered
  40706. */
  40707. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40708. /**
  40709. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40710. * @param ray ray to cast into the environment
  40711. * @returns Promise which resolves with a collision point in the environment if it exists
  40712. */
  40713. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40714. /**
  40715. * Updates the global position of the camera by moving the camera's container
  40716. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40717. * @param position The desired global position of the camera
  40718. */
  40719. setPositionOfCameraUsingContainer(position: Vector3): void;
  40720. /**
  40721. * Rotates the xr camera by rotating the camera's container around the camera's position
  40722. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40723. * @param rotation the desired quaternion rotation to apply to the camera
  40724. */
  40725. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40726. /**
  40727. * Checks if the creation options are supported by the xr session
  40728. * @param options creation options
  40729. * @returns true if supported
  40730. */
  40731. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40732. /**
  40733. * Disposes of the experience helper
  40734. */
  40735. dispose(): void;
  40736. }
  40737. }
  40738. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40739. import { Nullable } from "babylonjs/types";
  40740. import { Observable } from "babylonjs/Misc/observable";
  40741. import { IDisposable, Scene } from "babylonjs/scene";
  40742. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40743. /**
  40744. * Button which can be used to enter a different mode of XR
  40745. */
  40746. export class WebXREnterExitUIButton {
  40747. /** button element */
  40748. element: HTMLElement;
  40749. /** XR initialization options for the button */
  40750. initializationOptions: XRSessionCreationOptions;
  40751. /**
  40752. * Creates a WebXREnterExitUIButton
  40753. * @param element button element
  40754. * @param initializationOptions XR initialization options for the button
  40755. */
  40756. constructor(
  40757. /** button element */
  40758. element: HTMLElement,
  40759. /** XR initialization options for the button */
  40760. initializationOptions: XRSessionCreationOptions);
  40761. /**
  40762. * Overwritable function which can be used to update the button's visuals when the state changes
  40763. * @param activeButton the current active button in the UI
  40764. */
  40765. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40766. }
  40767. /**
  40768. * Options to create the webXR UI
  40769. */
  40770. export class WebXREnterExitUIOptions {
  40771. /**
  40772. * Context to enter xr with
  40773. */
  40774. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40775. /**
  40776. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40777. */
  40778. customButtons?: Array<WebXREnterExitUIButton>;
  40779. }
  40780. /**
  40781. * UI to allow the user to enter/exit XR mode
  40782. */
  40783. export class WebXREnterExitUI implements IDisposable {
  40784. private scene;
  40785. private _overlay;
  40786. private _buttons;
  40787. private _activeButton;
  40788. /**
  40789. * Fired every time the active button is changed.
  40790. *
  40791. * When xr is entered via a button that launches xr that button will be the callback parameter
  40792. *
  40793. * When exiting xr the callback parameter will be null)
  40794. */
  40795. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40796. /**
  40797. * Creates UI to allow the user to enter/exit XR mode
  40798. * @param scene the scene to add the ui to
  40799. * @param helper the xr experience helper to enter/exit xr with
  40800. * @param options options to configure the UI
  40801. * @returns the created ui
  40802. */
  40803. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40804. private constructor();
  40805. private _updateButtons;
  40806. /**
  40807. * Disposes of the object
  40808. */
  40809. dispose(): void;
  40810. }
  40811. }
  40812. declare module "babylonjs/Cameras/XR/webXRInput" {
  40813. import { IDisposable, Scene } from "babylonjs/scene";
  40814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40815. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40816. /**
  40817. * Represents an XR input
  40818. */
  40819. export class WebXRController {
  40820. /**
  40821. * 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
  40822. */
  40823. grip?: AbstractMesh;
  40824. /**
  40825. * Pointer which can be used to select objects or attach a visible laser to
  40826. */
  40827. pointer: AbstractMesh;
  40828. /**
  40829. * Creates the controller
  40830. * @see https://doc.babylonjs.com/how_to/webxr
  40831. * @param scene the scene which the controller should be associated to
  40832. */
  40833. constructor(scene: Scene);
  40834. /**
  40835. * Disposes of the object
  40836. */
  40837. dispose(): void;
  40838. }
  40839. /**
  40840. * XR input used to track XR inputs such as controllers/rays
  40841. */
  40842. export class WebXRInput implements IDisposable {
  40843. private helper;
  40844. /**
  40845. * XR controllers being tracked
  40846. */
  40847. controllers: Array<WebXRController>;
  40848. private _tmpMatrix;
  40849. private _frameObserver;
  40850. /**
  40851. * Initializes the WebXRInput
  40852. * @param helper experience helper which the input should be created for
  40853. */
  40854. constructor(helper: WebXRExperienceHelper);
  40855. /**
  40856. * Disposes of the object
  40857. */
  40858. dispose(): void;
  40859. }
  40860. }
  40861. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40862. import { Nullable } from "babylonjs/types";
  40863. import { IDisposable } from "babylonjs/scene";
  40864. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40865. /**
  40866. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40867. */
  40868. export class WebXRManagedOutputCanvas implements IDisposable {
  40869. private _canvas;
  40870. /**
  40871. * xrpresent context of the canvas which can be used to display/mirror xr content
  40872. */
  40873. canvasContext: Nullable<WebGLRenderingContext>;
  40874. /**
  40875. * Initializes the canvas to be added/removed upon entering/exiting xr
  40876. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40877. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40878. */
  40879. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40880. /**
  40881. * Disposes of the object
  40882. */
  40883. dispose(): void;
  40884. private _setManagedOutputCanvas;
  40885. private _addCanvas;
  40886. private _removeCanvas;
  40887. }
  40888. }
  40889. declare module "babylonjs/Cameras/XR/index" {
  40890. export * from "babylonjs/Cameras/XR/webXRCamera";
  40891. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40892. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40893. export * from "babylonjs/Cameras/XR/webXRInput";
  40894. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40895. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40896. }
  40897. declare module "babylonjs/Cameras/index" {
  40898. export * from "babylonjs/Cameras/Inputs/index";
  40899. export * from "babylonjs/Cameras/cameraInputsManager";
  40900. export * from "babylonjs/Cameras/camera";
  40901. export * from "babylonjs/Cameras/targetCamera";
  40902. export * from "babylonjs/Cameras/freeCamera";
  40903. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40904. export * from "babylonjs/Cameras/touchCamera";
  40905. export * from "babylonjs/Cameras/arcRotateCamera";
  40906. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40907. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40908. export * from "babylonjs/Cameras/flyCamera";
  40909. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40910. export * from "babylonjs/Cameras/followCamera";
  40911. export * from "babylonjs/Cameras/gamepadCamera";
  40912. export * from "babylonjs/Cameras/Stereoscopic/index";
  40913. export * from "babylonjs/Cameras/universalCamera";
  40914. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40915. export * from "babylonjs/Cameras/VR/index";
  40916. export * from "babylonjs/Cameras/XR/index";
  40917. }
  40918. declare module "babylonjs/Collisions/index" {
  40919. export * from "babylonjs/Collisions/collider";
  40920. export * from "babylonjs/Collisions/collisionCoordinator";
  40921. export * from "babylonjs/Collisions/pickingInfo";
  40922. export * from "babylonjs/Collisions/intersectionInfo";
  40923. }
  40924. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40925. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40926. import { Vector3, Plane } from "babylonjs/Maths/math";
  40927. import { Ray } from "babylonjs/Culling/ray";
  40928. /**
  40929. * Contains an array of blocks representing the octree
  40930. */
  40931. export interface IOctreeContainer<T> {
  40932. /**
  40933. * Blocks within the octree
  40934. */
  40935. blocks: Array<OctreeBlock<T>>;
  40936. }
  40937. /**
  40938. * Class used to store a cell in an octree
  40939. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40940. */
  40941. export class OctreeBlock<T> {
  40942. /**
  40943. * Gets the content of the current block
  40944. */
  40945. entries: T[];
  40946. /**
  40947. * Gets the list of block children
  40948. */
  40949. blocks: Array<OctreeBlock<T>>;
  40950. private _depth;
  40951. private _maxDepth;
  40952. private _capacity;
  40953. private _minPoint;
  40954. private _maxPoint;
  40955. private _boundingVectors;
  40956. private _creationFunc;
  40957. /**
  40958. * Creates a new block
  40959. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40960. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40961. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40962. * @param depth defines the current depth of this block in the octree
  40963. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40964. * @param creationFunc defines a callback to call when an element is added to the block
  40965. */
  40966. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40967. /**
  40968. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40969. */
  40970. readonly capacity: number;
  40971. /**
  40972. * Gets the minimum vector (in world space) of the block's bounding box
  40973. */
  40974. readonly minPoint: Vector3;
  40975. /**
  40976. * Gets the maximum vector (in world space) of the block's bounding box
  40977. */
  40978. readonly maxPoint: Vector3;
  40979. /**
  40980. * Add a new element to this block
  40981. * @param entry defines the element to add
  40982. */
  40983. addEntry(entry: T): void;
  40984. /**
  40985. * Remove an element from this block
  40986. * @param entry defines the element to remove
  40987. */
  40988. removeEntry(entry: T): void;
  40989. /**
  40990. * Add an array of elements to this block
  40991. * @param entries defines the array of elements to add
  40992. */
  40993. addEntries(entries: T[]): void;
  40994. /**
  40995. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40996. * @param frustumPlanes defines the frustum planes to test
  40997. * @param selection defines the array to store current content if selection is positive
  40998. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40999. */
  41000. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41001. /**
  41002. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41003. * @param sphereCenter defines the bounding sphere center
  41004. * @param sphereRadius defines the bounding sphere radius
  41005. * @param selection defines the array to store current content if selection is positive
  41006. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41007. */
  41008. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41009. /**
  41010. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41011. * @param ray defines the ray to test with
  41012. * @param selection defines the array to store current content if selection is positive
  41013. */
  41014. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41015. /**
  41016. * Subdivide the content into child blocks (this block will then be empty)
  41017. */
  41018. createInnerBlocks(): void;
  41019. /**
  41020. * @hidden
  41021. */
  41022. 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;
  41023. }
  41024. }
  41025. declare module "babylonjs/Culling/Octrees/octree" {
  41026. import { SmartArray } from "babylonjs/Misc/smartArray";
  41027. import { Vector3, Plane } from "babylonjs/Maths/math";
  41028. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41030. import { Ray } from "babylonjs/Culling/ray";
  41031. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41032. /**
  41033. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41034. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41035. */
  41036. export class Octree<T> {
  41037. /** 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.) */
  41038. maxDepth: number;
  41039. /**
  41040. * Blocks within the octree containing objects
  41041. */
  41042. blocks: Array<OctreeBlock<T>>;
  41043. /**
  41044. * Content stored in the octree
  41045. */
  41046. dynamicContent: T[];
  41047. private _maxBlockCapacity;
  41048. private _selectionContent;
  41049. private _creationFunc;
  41050. /**
  41051. * Creates a octree
  41052. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41053. * @param creationFunc function to be used to instatiate the octree
  41054. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41055. * @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.)
  41056. */
  41057. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41058. /** 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.) */
  41059. maxDepth?: number);
  41060. /**
  41061. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41062. * @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);
  41063. * @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);
  41064. * @param entries meshes to be added to the octree blocks
  41065. */
  41066. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41067. /**
  41068. * Adds a mesh to the octree
  41069. * @param entry Mesh to add to the octree
  41070. */
  41071. addMesh(entry: T): void;
  41072. /**
  41073. * Remove an element from the octree
  41074. * @param entry defines the element to remove
  41075. */
  41076. removeMesh(entry: T): void;
  41077. /**
  41078. * Selects an array of meshes within the frustum
  41079. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41080. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41081. * @returns array of meshes within the frustum
  41082. */
  41083. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41084. /**
  41085. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41086. * @param sphereCenter defines the bounding sphere center
  41087. * @param sphereRadius defines the bounding sphere radius
  41088. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41089. * @returns an array of objects that intersect the sphere
  41090. */
  41091. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41092. /**
  41093. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41094. * @param ray defines the ray to test with
  41095. * @returns array of intersected objects
  41096. */
  41097. intersectsRay(ray: Ray): SmartArray<T>;
  41098. /**
  41099. * Adds a mesh into the octree block if it intersects the block
  41100. */
  41101. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41102. /**
  41103. * Adds a submesh into the octree block if it intersects the block
  41104. */
  41105. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41106. }
  41107. }
  41108. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41109. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41110. import { Scene } from "babylonjs/scene";
  41111. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41113. import { Collider } from "babylonjs/Collisions/collider";
  41114. import { Ray } from "babylonjs/Culling/ray";
  41115. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41116. module "babylonjs/scene" {
  41117. interface Scene {
  41118. /**
  41119. * @hidden
  41120. * Backing Filed
  41121. */
  41122. _selectionOctree: Octree<AbstractMesh>;
  41123. /**
  41124. * Gets the octree used to boost mesh selection (picking)
  41125. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41126. */
  41127. selectionOctree: Octree<AbstractMesh>;
  41128. /**
  41129. * Creates or updates the octree used to boost selection (picking)
  41130. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41131. * @param maxCapacity defines the maximum capacity per leaf
  41132. * @param maxDepth defines the maximum depth of the octree
  41133. * @returns an octree of AbstractMesh
  41134. */
  41135. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41136. }
  41137. }
  41138. module "babylonjs/Meshes/abstractMesh" {
  41139. interface AbstractMesh {
  41140. /**
  41141. * @hidden
  41142. * Backing Field
  41143. */
  41144. _submeshesOctree: Octree<SubMesh>;
  41145. /**
  41146. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41147. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41148. * @param maxCapacity defines the maximum size of each block (64 by default)
  41149. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41150. * @returns the new octree
  41151. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41153. */
  41154. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41155. }
  41156. }
  41157. /**
  41158. * Defines the octree scene component responsible to manage any octrees
  41159. * in a given scene.
  41160. */
  41161. export class OctreeSceneComponent {
  41162. /**
  41163. * The component name helpfull to identify the component in the list of scene components.
  41164. */
  41165. readonly name: string;
  41166. /**
  41167. * The scene the component belongs to.
  41168. */
  41169. scene: Scene;
  41170. /**
  41171. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41172. */
  41173. readonly checksIsEnabled: boolean;
  41174. /**
  41175. * Creates a new instance of the component for the given scene
  41176. * @param scene Defines the scene to register the component in
  41177. */
  41178. constructor(scene: Scene);
  41179. /**
  41180. * Registers the component in a given scene
  41181. */
  41182. register(): void;
  41183. /**
  41184. * Return the list of active meshes
  41185. * @returns the list of active meshes
  41186. */
  41187. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41188. /**
  41189. * Return the list of active sub meshes
  41190. * @param mesh The mesh to get the candidates sub meshes from
  41191. * @returns the list of active sub meshes
  41192. */
  41193. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41194. private _tempRay;
  41195. /**
  41196. * Return the list of sub meshes intersecting with a given local ray
  41197. * @param mesh defines the mesh to find the submesh for
  41198. * @param localRay defines the ray in local space
  41199. * @returns the list of intersecting sub meshes
  41200. */
  41201. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41202. /**
  41203. * Return the list of sub meshes colliding with a collider
  41204. * @param mesh defines the mesh to find the submesh for
  41205. * @param collider defines the collider to evaluate the collision against
  41206. * @returns the list of colliding sub meshes
  41207. */
  41208. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41209. /**
  41210. * Rebuilds the elements related to this component in case of
  41211. * context lost for instance.
  41212. */
  41213. rebuild(): void;
  41214. /**
  41215. * Disposes the component and the associated ressources.
  41216. */
  41217. dispose(): void;
  41218. }
  41219. }
  41220. declare module "babylonjs/Culling/Octrees/index" {
  41221. export * from "babylonjs/Culling/Octrees/octree";
  41222. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41223. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41224. }
  41225. declare module "babylonjs/Culling/index" {
  41226. export * from "babylonjs/Culling/boundingBox";
  41227. export * from "babylonjs/Culling/boundingInfo";
  41228. export * from "babylonjs/Culling/boundingSphere";
  41229. export * from "babylonjs/Culling/Octrees/index";
  41230. export * from "babylonjs/Culling/ray";
  41231. }
  41232. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41233. import { IDisposable, Scene } from "babylonjs/scene";
  41234. import { Nullable } from "babylonjs/types";
  41235. import { Observable } from "babylonjs/Misc/observable";
  41236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41237. /**
  41238. * Renders a layer on top of an existing scene
  41239. */
  41240. export class UtilityLayerRenderer implements IDisposable {
  41241. /** the original scene that will be rendered on top of */
  41242. originalScene: Scene;
  41243. private _pointerCaptures;
  41244. private _lastPointerEvents;
  41245. private static _DefaultUtilityLayer;
  41246. private static _DefaultKeepDepthUtilityLayer;
  41247. /**
  41248. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41249. */
  41250. pickUtilitySceneFirst: boolean;
  41251. /**
  41252. * 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)
  41253. */
  41254. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41255. /**
  41256. * 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)
  41257. */
  41258. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41259. /**
  41260. * The scene that is rendered on top of the original scene
  41261. */
  41262. utilityLayerScene: Scene;
  41263. /**
  41264. * If the utility layer should automatically be rendered on top of existing scene
  41265. */
  41266. shouldRender: boolean;
  41267. /**
  41268. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41269. */
  41270. onlyCheckPointerDownEvents: boolean;
  41271. /**
  41272. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41273. */
  41274. processAllEvents: boolean;
  41275. /**
  41276. * Observable raised when the pointer move from the utility layer scene to the main scene
  41277. */
  41278. onPointerOutObservable: Observable<number>;
  41279. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41280. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41281. private _afterRenderObserver;
  41282. private _sceneDisposeObserver;
  41283. private _originalPointerObserver;
  41284. /**
  41285. * Instantiates a UtilityLayerRenderer
  41286. * @param originalScene the original scene that will be rendered on top of
  41287. * @param handleEvents boolean indicating if the utility layer should handle events
  41288. */
  41289. constructor(
  41290. /** the original scene that will be rendered on top of */
  41291. originalScene: Scene, handleEvents?: boolean);
  41292. private _notifyObservers;
  41293. /**
  41294. * Renders the utility layers scene on top of the original scene
  41295. */
  41296. render(): void;
  41297. /**
  41298. * Disposes of the renderer
  41299. */
  41300. dispose(): void;
  41301. private _updateCamera;
  41302. }
  41303. }
  41304. declare module "babylonjs/Gizmos/gizmo" {
  41305. import { Nullable } from "babylonjs/types";
  41306. import { IDisposable } from "babylonjs/scene";
  41307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41308. import { Mesh } from "babylonjs/Meshes/mesh";
  41309. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41310. /**
  41311. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41312. */
  41313. export class Gizmo implements IDisposable {
  41314. /** The utility layer the gizmo will be added to */
  41315. gizmoLayer: UtilityLayerRenderer;
  41316. /**
  41317. * The root mesh of the gizmo
  41318. */
  41319. protected _rootMesh: Mesh;
  41320. private _attachedMesh;
  41321. /**
  41322. * Ratio for the scale of the gizmo (Default: 1)
  41323. */
  41324. scaleRatio: number;
  41325. private _tmpMatrix;
  41326. /**
  41327. * If a custom mesh has been set (Default: false)
  41328. */
  41329. protected _customMeshSet: boolean;
  41330. /**
  41331. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41332. * * When set, interactions will be enabled
  41333. */
  41334. attachedMesh: Nullable<AbstractMesh>;
  41335. /**
  41336. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41337. * @param mesh The mesh to replace the default mesh of the gizmo
  41338. */
  41339. setCustomMesh(mesh: Mesh): void;
  41340. /**
  41341. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41342. */
  41343. updateGizmoRotationToMatchAttachedMesh: boolean;
  41344. /**
  41345. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41346. */
  41347. updateGizmoPositionToMatchAttachedMesh: boolean;
  41348. /**
  41349. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41350. */
  41351. protected _updateScale: boolean;
  41352. protected _interactionsEnabled: boolean;
  41353. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41354. private _beforeRenderObserver;
  41355. /**
  41356. * Creates a gizmo
  41357. * @param gizmoLayer The utility layer the gizmo will be added to
  41358. */
  41359. constructor(
  41360. /** The utility layer the gizmo will be added to */
  41361. gizmoLayer?: UtilityLayerRenderer);
  41362. private _tempVector;
  41363. /**
  41364. * @hidden
  41365. * Updates the gizmo to match the attached mesh's position/rotation
  41366. */
  41367. protected _update(): void;
  41368. /**
  41369. * Disposes of the gizmo
  41370. */
  41371. dispose(): void;
  41372. }
  41373. }
  41374. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41375. import { Observable } from "babylonjs/Misc/observable";
  41376. import { Nullable } from "babylonjs/types";
  41377. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41378. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41380. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41381. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41382. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41383. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41384. import { Scene } from "babylonjs/scene";
  41385. /**
  41386. * Single axis drag gizmo
  41387. */
  41388. export class AxisDragGizmo extends Gizmo {
  41389. /**
  41390. * Drag behavior responsible for the gizmos dragging interactions
  41391. */
  41392. dragBehavior: PointerDragBehavior;
  41393. private _pointerObserver;
  41394. /**
  41395. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41396. */
  41397. snapDistance: number;
  41398. /**
  41399. * Event that fires each time the gizmo snaps to a new location.
  41400. * * snapDistance is the the change in distance
  41401. */
  41402. onSnapObservable: Observable<{
  41403. snapDistance: number;
  41404. }>;
  41405. /** @hidden */
  41406. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41407. /** @hidden */
  41408. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41409. /**
  41410. * Creates an AxisDragGizmo
  41411. * @param gizmoLayer The utility layer the gizmo will be added to
  41412. * @param dragAxis The axis which the gizmo will be able to drag on
  41413. * @param color The color of the gizmo
  41414. */
  41415. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41416. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41417. /**
  41418. * Disposes of the gizmo
  41419. */
  41420. dispose(): void;
  41421. }
  41422. }
  41423. declare module "babylonjs/Debug/axesViewer" {
  41424. import { Vector3 } from "babylonjs/Maths/math";
  41425. import { Nullable } from "babylonjs/types";
  41426. import { Scene } from "babylonjs/scene";
  41427. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41428. /**
  41429. * The Axes viewer will show 3 axes in a specific point in space
  41430. */
  41431. export class AxesViewer {
  41432. private _xAxis;
  41433. private _yAxis;
  41434. private _zAxis;
  41435. private _scaleLinesFactor;
  41436. private _instanced;
  41437. /**
  41438. * Gets the hosting scene
  41439. */
  41440. scene: Scene;
  41441. /**
  41442. * Gets or sets a number used to scale line length
  41443. */
  41444. scaleLines: number;
  41445. /** Gets the node hierarchy used to render x-axis */
  41446. readonly xAxis: TransformNode;
  41447. /** Gets the node hierarchy used to render y-axis */
  41448. readonly yAxis: TransformNode;
  41449. /** Gets the node hierarchy used to render z-axis */
  41450. readonly zAxis: TransformNode;
  41451. /**
  41452. * Creates a new AxesViewer
  41453. * @param scene defines the hosting scene
  41454. * @param scaleLines defines a number used to scale line length (1 by default)
  41455. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41456. * @param xAxis defines the node hierarchy used to render the x-axis
  41457. * @param yAxis defines the node hierarchy used to render the y-axis
  41458. * @param zAxis defines the node hierarchy used to render the z-axis
  41459. */
  41460. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41461. /**
  41462. * Force the viewer to update
  41463. * @param position defines the position of the viewer
  41464. * @param xaxis defines the x axis of the viewer
  41465. * @param yaxis defines the y axis of the viewer
  41466. * @param zaxis defines the z axis of the viewer
  41467. */
  41468. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41469. /**
  41470. * Creates an instance of this axes viewer.
  41471. * @returns a new axes viewer with instanced meshes
  41472. */
  41473. createInstance(): AxesViewer;
  41474. /** Releases resources */
  41475. dispose(): void;
  41476. private static _SetRenderingGroupId;
  41477. }
  41478. }
  41479. declare module "babylonjs/Debug/boneAxesViewer" {
  41480. import { Nullable } from "babylonjs/types";
  41481. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41482. import { Vector3 } from "babylonjs/Maths/math";
  41483. import { Mesh } from "babylonjs/Meshes/mesh";
  41484. import { Bone } from "babylonjs/Bones/bone";
  41485. import { Scene } from "babylonjs/scene";
  41486. /**
  41487. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41488. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41489. */
  41490. export class BoneAxesViewer extends AxesViewer {
  41491. /**
  41492. * Gets or sets the target mesh where to display the axes viewer
  41493. */
  41494. mesh: Nullable<Mesh>;
  41495. /**
  41496. * Gets or sets the target bone where to display the axes viewer
  41497. */
  41498. bone: Nullable<Bone>;
  41499. /** Gets current position */
  41500. pos: Vector3;
  41501. /** Gets direction of X axis */
  41502. xaxis: Vector3;
  41503. /** Gets direction of Y axis */
  41504. yaxis: Vector3;
  41505. /** Gets direction of Z axis */
  41506. zaxis: Vector3;
  41507. /**
  41508. * Creates a new BoneAxesViewer
  41509. * @param scene defines the hosting scene
  41510. * @param bone defines the target bone
  41511. * @param mesh defines the target mesh
  41512. * @param scaleLines defines a scaling factor for line length (1 by default)
  41513. */
  41514. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41515. /**
  41516. * Force the viewer to update
  41517. */
  41518. update(): void;
  41519. /** Releases resources */
  41520. dispose(): void;
  41521. }
  41522. }
  41523. declare module "babylonjs/Debug/debugLayer" {
  41524. import { Observable } from "babylonjs/Misc/observable";
  41525. import { Scene } from "babylonjs/scene";
  41526. /**
  41527. * Interface used to define scene explorer extensibility option
  41528. */
  41529. export interface IExplorerExtensibilityOption {
  41530. /**
  41531. * Define the option label
  41532. */
  41533. label: string;
  41534. /**
  41535. * Defines the action to execute on click
  41536. */
  41537. action: (entity: any) => void;
  41538. }
  41539. /**
  41540. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41541. */
  41542. export interface IExplorerExtensibilityGroup {
  41543. /**
  41544. * Defines a predicate to test if a given type mut be extended
  41545. */
  41546. predicate: (entity: any) => boolean;
  41547. /**
  41548. * Gets the list of options added to a type
  41549. */
  41550. entries: IExplorerExtensibilityOption[];
  41551. }
  41552. /**
  41553. * Interface used to define the options to use to create the Inspector
  41554. */
  41555. export interface IInspectorOptions {
  41556. /**
  41557. * Display in overlay mode (default: false)
  41558. */
  41559. overlay?: boolean;
  41560. /**
  41561. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41562. */
  41563. globalRoot?: HTMLElement;
  41564. /**
  41565. * Display the Scene explorer
  41566. */
  41567. showExplorer?: boolean;
  41568. /**
  41569. * Display the property inspector
  41570. */
  41571. showInspector?: boolean;
  41572. /**
  41573. * Display in embed mode (both panes on the right)
  41574. */
  41575. embedMode?: boolean;
  41576. /**
  41577. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41578. */
  41579. handleResize?: boolean;
  41580. /**
  41581. * Allow the panes to popup (default: true)
  41582. */
  41583. enablePopup?: boolean;
  41584. /**
  41585. * Allow the panes to be closed by users (default: true)
  41586. */
  41587. enableClose?: boolean;
  41588. /**
  41589. * Optional list of extensibility entries
  41590. */
  41591. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41592. }
  41593. module "babylonjs/scene" {
  41594. interface Scene {
  41595. /**
  41596. * @hidden
  41597. * Backing field
  41598. */
  41599. _debugLayer: DebugLayer;
  41600. /**
  41601. * Gets the debug layer (aka Inspector) associated with the scene
  41602. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41603. */
  41604. debugLayer: DebugLayer;
  41605. }
  41606. }
  41607. /**
  41608. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41609. * what is happening in your scene
  41610. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41611. */
  41612. export class DebugLayer {
  41613. /**
  41614. * Define the url to get the inspector script from.
  41615. * By default it uses the babylonjs CDN.
  41616. * @ignoreNaming
  41617. */
  41618. static InspectorURL: string;
  41619. private _scene;
  41620. private BJSINSPECTOR;
  41621. /**
  41622. * Observable triggered when a property is changed through the inspector.
  41623. */
  41624. onPropertyChangedObservable: Observable<{
  41625. object: any;
  41626. property: string;
  41627. value: any;
  41628. initialValue: any;
  41629. }>;
  41630. /**
  41631. * Instantiates a new debug layer.
  41632. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41633. * what is happening in your scene
  41634. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41635. * @param scene Defines the scene to inspect
  41636. */
  41637. constructor(scene: Scene);
  41638. /** Creates the inspector window. */
  41639. private _createInspector;
  41640. /** Get the inspector from bundle or global */
  41641. private _getGlobalInspector;
  41642. /**
  41643. * Get if the inspector is visible or not.
  41644. * @returns true if visible otherwise, false
  41645. */
  41646. isVisible(): boolean;
  41647. /**
  41648. * Hide the inspector and close its window.
  41649. */
  41650. hide(): void;
  41651. /**
  41652. * Launch the debugLayer.
  41653. * @param config Define the configuration of the inspector
  41654. */
  41655. show(config?: IInspectorOptions): void;
  41656. }
  41657. }
  41658. declare module "babylonjs/Debug/physicsViewer" {
  41659. import { Nullable } from "babylonjs/types";
  41660. import { Scene } from "babylonjs/scene";
  41661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41662. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41663. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41664. /**
  41665. * Used to show the physics impostor around the specific mesh
  41666. */
  41667. export class PhysicsViewer {
  41668. /** @hidden */
  41669. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41670. /** @hidden */
  41671. protected _meshes: Array<Nullable<AbstractMesh>>;
  41672. /** @hidden */
  41673. protected _scene: Nullable<Scene>;
  41674. /** @hidden */
  41675. protected _numMeshes: number;
  41676. /** @hidden */
  41677. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41678. private _renderFunction;
  41679. private _utilityLayer;
  41680. private _debugBoxMesh;
  41681. private _debugSphereMesh;
  41682. private _debugMaterial;
  41683. /**
  41684. * Creates a new PhysicsViewer
  41685. * @param scene defines the hosting scene
  41686. */
  41687. constructor(scene: Scene);
  41688. /** @hidden */
  41689. protected _updateDebugMeshes(): void;
  41690. /**
  41691. * Renders a specified physic impostor
  41692. * @param impostor defines the impostor to render
  41693. * @returns the new debug mesh used to render the impostor
  41694. */
  41695. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41696. /**
  41697. * Hides a specified physic impostor
  41698. * @param impostor defines the impostor to hide
  41699. */
  41700. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41701. private _getDebugMaterial;
  41702. private _getDebugBoxMesh;
  41703. private _getDebugSphereMesh;
  41704. private _getDebugMesh;
  41705. /** Releases all resources */
  41706. dispose(): void;
  41707. }
  41708. }
  41709. declare module "babylonjs/Debug/rayHelper" {
  41710. import { Nullable } from "babylonjs/types";
  41711. import { Ray } from "babylonjs/Culling/ray";
  41712. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41713. import { Scene } from "babylonjs/scene";
  41714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41715. /**
  41716. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41717. * in order to better appreciate the issue one might have.
  41718. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41719. */
  41720. export class RayHelper {
  41721. /**
  41722. * Defines the ray we are currently tryin to visualize.
  41723. */
  41724. ray: Nullable<Ray>;
  41725. private _renderPoints;
  41726. private _renderLine;
  41727. private _renderFunction;
  41728. private _scene;
  41729. private _updateToMeshFunction;
  41730. private _attachedToMesh;
  41731. private _meshSpaceDirection;
  41732. private _meshSpaceOrigin;
  41733. /**
  41734. * Helper function to create a colored helper in a scene in one line.
  41735. * @param ray Defines the ray we are currently tryin to visualize
  41736. * @param scene Defines the scene the ray is used in
  41737. * @param color Defines the color we want to see the ray in
  41738. * @returns The newly created ray helper.
  41739. */
  41740. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41741. /**
  41742. * Instantiate a new ray helper.
  41743. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41744. * in order to better appreciate the issue one might have.
  41745. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41746. * @param ray Defines the ray we are currently tryin to visualize
  41747. */
  41748. constructor(ray: Ray);
  41749. /**
  41750. * Shows the ray we are willing to debug.
  41751. * @param scene Defines the scene the ray needs to be rendered in
  41752. * @param color Defines the color the ray needs to be rendered in
  41753. */
  41754. show(scene: Scene, color?: Color3): void;
  41755. /**
  41756. * Hides the ray we are debugging.
  41757. */
  41758. hide(): void;
  41759. private _render;
  41760. /**
  41761. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41762. * @param mesh Defines the mesh we want the helper attached to
  41763. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41764. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41765. * @param length Defines the length of the ray
  41766. */
  41767. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41768. /**
  41769. * Detach the ray helper from the mesh it has previously been attached to.
  41770. */
  41771. detachFromMesh(): void;
  41772. private _updateToMesh;
  41773. /**
  41774. * Dispose the helper and release its associated resources.
  41775. */
  41776. dispose(): void;
  41777. }
  41778. }
  41779. declare module "babylonjs/Debug/skeletonViewer" {
  41780. import { Color3 } from "babylonjs/Maths/math";
  41781. import { Scene } from "babylonjs/scene";
  41782. import { Nullable } from "babylonjs/types";
  41783. import { Skeleton } from "babylonjs/Bones/skeleton";
  41784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41785. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41786. /**
  41787. * Class used to render a debug view of a given skeleton
  41788. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41789. */
  41790. export class SkeletonViewer {
  41791. /** defines the skeleton to render */
  41792. skeleton: Skeleton;
  41793. /** defines the mesh attached to the skeleton */
  41794. mesh: AbstractMesh;
  41795. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41796. autoUpdateBonesMatrices: boolean;
  41797. /** defines the rendering group id to use with the viewer */
  41798. renderingGroupId: number;
  41799. /** Gets or sets the color used to render the skeleton */
  41800. color: Color3;
  41801. private _scene;
  41802. private _debugLines;
  41803. private _debugMesh;
  41804. private _isEnabled;
  41805. private _renderFunction;
  41806. private _utilityLayer;
  41807. /**
  41808. * Returns the mesh used to render the bones
  41809. */
  41810. readonly debugMesh: Nullable<LinesMesh>;
  41811. /**
  41812. * Creates a new SkeletonViewer
  41813. * @param skeleton defines the skeleton to render
  41814. * @param mesh defines the mesh attached to the skeleton
  41815. * @param scene defines the hosting scene
  41816. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41817. * @param renderingGroupId defines the rendering group id to use with the viewer
  41818. */
  41819. constructor(
  41820. /** defines the skeleton to render */
  41821. skeleton: Skeleton,
  41822. /** defines the mesh attached to the skeleton */
  41823. mesh: AbstractMesh, scene: Scene,
  41824. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41825. autoUpdateBonesMatrices?: boolean,
  41826. /** defines the rendering group id to use with the viewer */
  41827. renderingGroupId?: number);
  41828. /** Gets or sets a boolean indicating if the viewer is enabled */
  41829. isEnabled: boolean;
  41830. private _getBonePosition;
  41831. private _getLinesForBonesWithLength;
  41832. private _getLinesForBonesNoLength;
  41833. /** Update the viewer to sync with current skeleton state */
  41834. update(): void;
  41835. /** Release associated resources */
  41836. dispose(): void;
  41837. }
  41838. }
  41839. declare module "babylonjs/Debug/index" {
  41840. export * from "babylonjs/Debug/axesViewer";
  41841. export * from "babylonjs/Debug/boneAxesViewer";
  41842. export * from "babylonjs/Debug/debugLayer";
  41843. export * from "babylonjs/Debug/physicsViewer";
  41844. export * from "babylonjs/Debug/rayHelper";
  41845. export * from "babylonjs/Debug/skeletonViewer";
  41846. }
  41847. declare module "babylonjs/Engines/nullEngine" {
  41848. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41849. import { Scene } from "babylonjs/scene";
  41850. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41851. import { Engine } from "babylonjs/Engines/engine";
  41852. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41853. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41854. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41855. import { Effect } from "babylonjs/Materials/effect";
  41856. /**
  41857. * Options to create the null engine
  41858. */
  41859. export class NullEngineOptions {
  41860. /**
  41861. * Render width (Default: 512)
  41862. */
  41863. renderWidth: number;
  41864. /**
  41865. * Render height (Default: 256)
  41866. */
  41867. renderHeight: number;
  41868. /**
  41869. * Texture size (Default: 512)
  41870. */
  41871. textureSize: number;
  41872. /**
  41873. * If delta time between frames should be constant
  41874. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41875. */
  41876. deterministicLockstep: boolean;
  41877. /**
  41878. * Maximum about of steps between frames (Default: 4)
  41879. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41880. */
  41881. lockstepMaxSteps: number;
  41882. }
  41883. /**
  41884. * The null engine class provides support for headless version of babylon.js.
  41885. * This can be used in server side scenario or for testing purposes
  41886. */
  41887. export class NullEngine extends Engine {
  41888. private _options;
  41889. /**
  41890. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41891. */
  41892. isDeterministicLockStep(): boolean;
  41893. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41894. getLockstepMaxSteps(): number;
  41895. /**
  41896. * Sets hardware scaling, used to save performance if needed
  41897. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41898. */
  41899. getHardwareScalingLevel(): number;
  41900. constructor(options?: NullEngineOptions);
  41901. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41902. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41903. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41904. getRenderWidth(useScreen?: boolean): number;
  41905. getRenderHeight(useScreen?: boolean): number;
  41906. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41907. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41908. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41909. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41910. bindSamplers(effect: Effect): void;
  41911. enableEffect(effect: Effect): void;
  41912. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41913. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41914. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41915. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41916. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41917. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41918. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41919. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41920. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41921. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41922. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41923. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41924. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41925. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41926. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41927. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41928. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41929. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41930. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41931. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41932. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41933. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41934. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41935. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41936. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41937. bindBuffers(vertexBuffers: {
  41938. [key: string]: VertexBuffer;
  41939. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41940. wipeCaches(bruteForce?: boolean): void;
  41941. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41942. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41943. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41944. /** @hidden */
  41945. _createTexture(): WebGLTexture;
  41946. /** @hidden */
  41947. _releaseTexture(texture: InternalTexture): void;
  41948. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  41949. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41950. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41951. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41952. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41953. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41954. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41955. areAllEffectsReady(): boolean;
  41956. /**
  41957. * @hidden
  41958. * Get the current error code of the webGL context
  41959. * @returns the error code
  41960. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41961. */
  41962. getError(): number;
  41963. /** @hidden */
  41964. _getUnpackAlignement(): number;
  41965. /** @hidden */
  41966. _unpackFlipY(value: boolean): void;
  41967. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41968. /**
  41969. * Updates a dynamic vertex buffer.
  41970. * @param vertexBuffer the vertex buffer to update
  41971. * @param data the data used to update the vertex buffer
  41972. * @param byteOffset the byte offset of the data (optional)
  41973. * @param byteLength the byte length of the data (optional)
  41974. */
  41975. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41976. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41977. /** @hidden */
  41978. _bindTexture(channel: number, texture: InternalTexture): void;
  41979. /** @hidden */
  41980. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41981. releaseEffects(): void;
  41982. displayLoadingUI(): void;
  41983. hideLoadingUI(): void;
  41984. /** @hidden */
  41985. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41986. /** @hidden */
  41987. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41988. /** @hidden */
  41989. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41990. /** @hidden */
  41991. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41992. }
  41993. }
  41994. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41995. import { Nullable, int } from "babylonjs/types";
  41996. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41997. /** @hidden */
  41998. export class _OcclusionDataStorage {
  41999. /** @hidden */
  42000. occlusionInternalRetryCounter: number;
  42001. /** @hidden */
  42002. isOcclusionQueryInProgress: boolean;
  42003. /** @hidden */
  42004. isOccluded: boolean;
  42005. /** @hidden */
  42006. occlusionRetryCount: number;
  42007. /** @hidden */
  42008. occlusionType: number;
  42009. /** @hidden */
  42010. occlusionQueryAlgorithmType: number;
  42011. }
  42012. module "babylonjs/Engines/engine" {
  42013. interface Engine {
  42014. /**
  42015. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42016. * @return the new query
  42017. */
  42018. createQuery(): WebGLQuery;
  42019. /**
  42020. * Delete and release a webGL query
  42021. * @param query defines the query to delete
  42022. * @return the current engine
  42023. */
  42024. deleteQuery(query: WebGLQuery): Engine;
  42025. /**
  42026. * Check if a given query has resolved and got its value
  42027. * @param query defines the query to check
  42028. * @returns true if the query got its value
  42029. */
  42030. isQueryResultAvailable(query: WebGLQuery): boolean;
  42031. /**
  42032. * Gets the value of a given query
  42033. * @param query defines the query to check
  42034. * @returns the value of the query
  42035. */
  42036. getQueryResult(query: WebGLQuery): number;
  42037. /**
  42038. * Initiates an occlusion query
  42039. * @param algorithmType defines the algorithm to use
  42040. * @param query defines the query to use
  42041. * @returns the current engine
  42042. * @see http://doc.babylonjs.com/features/occlusionquery
  42043. */
  42044. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42045. /**
  42046. * Ends an occlusion query
  42047. * @see http://doc.babylonjs.com/features/occlusionquery
  42048. * @param algorithmType defines the algorithm to use
  42049. * @returns the current engine
  42050. */
  42051. endOcclusionQuery(algorithmType: number): Engine;
  42052. /**
  42053. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42054. * Please note that only one query can be issued at a time
  42055. * @returns a time token used to track the time span
  42056. */
  42057. startTimeQuery(): Nullable<_TimeToken>;
  42058. /**
  42059. * Ends a time query
  42060. * @param token defines the token used to measure the time span
  42061. * @returns the time spent (in ns)
  42062. */
  42063. endTimeQuery(token: _TimeToken): int;
  42064. /** @hidden */
  42065. _currentNonTimestampToken: Nullable<_TimeToken>;
  42066. /** @hidden */
  42067. _createTimeQuery(): WebGLQuery;
  42068. /** @hidden */
  42069. _deleteTimeQuery(query: WebGLQuery): void;
  42070. /** @hidden */
  42071. _getGlAlgorithmType(algorithmType: number): number;
  42072. /** @hidden */
  42073. _getTimeQueryResult(query: WebGLQuery): any;
  42074. /** @hidden */
  42075. _getTimeQueryAvailability(query: WebGLQuery): any;
  42076. }
  42077. }
  42078. module "babylonjs/Meshes/abstractMesh" {
  42079. interface AbstractMesh {
  42080. /**
  42081. * Backing filed
  42082. * @hidden
  42083. */
  42084. __occlusionDataStorage: _OcclusionDataStorage;
  42085. /**
  42086. * Access property
  42087. * @hidden
  42088. */
  42089. _occlusionDataStorage: _OcclusionDataStorage;
  42090. /**
  42091. * 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.
  42092. * The default value is -1 which means don't break the query and wait till the result
  42093. * @see http://doc.babylonjs.com/features/occlusionquery
  42094. */
  42095. occlusionRetryCount: number;
  42096. /**
  42097. * 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:
  42098. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42099. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42100. * * 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.
  42101. * @see http://doc.babylonjs.com/features/occlusionquery
  42102. */
  42103. occlusionType: number;
  42104. /**
  42105. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42106. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42107. * * 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.
  42108. * @see http://doc.babylonjs.com/features/occlusionquery
  42109. */
  42110. occlusionQueryAlgorithmType: number;
  42111. /**
  42112. * 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
  42113. * @see http://doc.babylonjs.com/features/occlusionquery
  42114. */
  42115. isOccluded: boolean;
  42116. /**
  42117. * Flag to check the progress status of the query
  42118. * @see http://doc.babylonjs.com/features/occlusionquery
  42119. */
  42120. isOcclusionQueryInProgress: boolean;
  42121. }
  42122. }
  42123. }
  42124. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42125. import { Nullable } from "babylonjs/types";
  42126. /** @hidden */
  42127. export var _forceTransformFeedbackToBundle: boolean;
  42128. module "babylonjs/Engines/engine" {
  42129. interface Engine {
  42130. /**
  42131. * Creates a webGL transform feedback object
  42132. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42133. * @returns the webGL transform feedback object
  42134. */
  42135. createTransformFeedback(): WebGLTransformFeedback;
  42136. /**
  42137. * Delete a webGL transform feedback object
  42138. * @param value defines the webGL transform feedback object to delete
  42139. */
  42140. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42141. /**
  42142. * Bind a webGL transform feedback object to the webgl context
  42143. * @param value defines the webGL transform feedback object to bind
  42144. */
  42145. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42146. /**
  42147. * Begins a transform feedback operation
  42148. * @param usePoints defines if points or triangles must be used
  42149. */
  42150. beginTransformFeedback(usePoints: boolean): void;
  42151. /**
  42152. * Ends a transform feedback operation
  42153. */
  42154. endTransformFeedback(): void;
  42155. /**
  42156. * Specify the varyings to use with transform feedback
  42157. * @param program defines the associated webGL program
  42158. * @param value defines the list of strings representing the varying names
  42159. */
  42160. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42161. /**
  42162. * Bind a webGL buffer for a transform feedback operation
  42163. * @param value defines the webGL buffer to bind
  42164. */
  42165. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42166. }
  42167. }
  42168. }
  42169. declare module "babylonjs/Engines/Extensions/index" {
  42170. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42171. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42172. }
  42173. declare module "babylonjs/Engines/index" {
  42174. export * from "babylonjs/Engines/constants";
  42175. export * from "babylonjs/Engines/engine";
  42176. export * from "babylonjs/Engines/engineStore";
  42177. export * from "babylonjs/Engines/nullEngine";
  42178. export * from "babylonjs/Engines/Extensions/index";
  42179. }
  42180. declare module "babylonjs/Events/clipboardEvents" {
  42181. /**
  42182. * Gather the list of clipboard event types as constants.
  42183. */
  42184. export class ClipboardEventTypes {
  42185. /**
  42186. * The clipboard event is fired when a copy command is active (pressed).
  42187. */
  42188. static readonly COPY: number;
  42189. /**
  42190. * The clipboard event is fired when a cut command is active (pressed).
  42191. */
  42192. static readonly CUT: number;
  42193. /**
  42194. * The clipboard event is fired when a paste command is active (pressed).
  42195. */
  42196. static readonly PASTE: number;
  42197. }
  42198. /**
  42199. * This class is used to store clipboard related info for the onClipboardObservable event.
  42200. */
  42201. export class ClipboardInfo {
  42202. /**
  42203. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42204. */
  42205. type: number;
  42206. /**
  42207. * Defines the related dom event
  42208. */
  42209. event: ClipboardEvent;
  42210. /**
  42211. *Creates an instance of ClipboardInfo.
  42212. * @param {number} type
  42213. * @param {ClipboardEvent} event
  42214. */
  42215. constructor(
  42216. /**
  42217. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42218. */
  42219. type: number,
  42220. /**
  42221. * Defines the related dom event
  42222. */
  42223. event: ClipboardEvent);
  42224. /**
  42225. * Get the clipboard event's type from the keycode.
  42226. * @param keyCode Defines the keyCode for the current keyboard event.
  42227. * @return {number}
  42228. */
  42229. static GetTypeFromCharacter(keyCode: number): number;
  42230. }
  42231. }
  42232. declare module "babylonjs/Events/index" {
  42233. export * from "babylonjs/Events/keyboardEvents";
  42234. export * from "babylonjs/Events/pointerEvents";
  42235. export * from "babylonjs/Events/clipboardEvents";
  42236. }
  42237. declare module "babylonjs/Loading/sceneLoader" {
  42238. import { Observable } from "babylonjs/Misc/observable";
  42239. import { Nullable } from "babylonjs/types";
  42240. import { Scene } from "babylonjs/scene";
  42241. import { Engine } from "babylonjs/Engines/engine";
  42242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42243. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42244. import { AssetContainer } from "babylonjs/assetContainer";
  42245. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42246. import { Skeleton } from "babylonjs/Bones/skeleton";
  42247. /**
  42248. * Class used to represent data loading progression
  42249. */
  42250. export class SceneLoaderProgressEvent {
  42251. /** defines if data length to load can be evaluated */
  42252. readonly lengthComputable: boolean;
  42253. /** defines the loaded data length */
  42254. readonly loaded: number;
  42255. /** defines the data length to load */
  42256. readonly total: number;
  42257. /**
  42258. * Create a new progress event
  42259. * @param lengthComputable defines if data length to load can be evaluated
  42260. * @param loaded defines the loaded data length
  42261. * @param total defines the data length to load
  42262. */
  42263. constructor(
  42264. /** defines if data length to load can be evaluated */
  42265. lengthComputable: boolean,
  42266. /** defines the loaded data length */
  42267. loaded: number,
  42268. /** defines the data length to load */
  42269. total: number);
  42270. /**
  42271. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42272. * @param event defines the source event
  42273. * @returns a new SceneLoaderProgressEvent
  42274. */
  42275. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42276. }
  42277. /**
  42278. * Interface used by SceneLoader plugins to define supported file extensions
  42279. */
  42280. export interface ISceneLoaderPluginExtensions {
  42281. /**
  42282. * Defines the list of supported extensions
  42283. */
  42284. [extension: string]: {
  42285. isBinary: boolean;
  42286. };
  42287. }
  42288. /**
  42289. * Interface used by SceneLoader plugin factory
  42290. */
  42291. export interface ISceneLoaderPluginFactory {
  42292. /**
  42293. * Defines the name of the factory
  42294. */
  42295. name: string;
  42296. /**
  42297. * Function called to create a new plugin
  42298. * @return the new plugin
  42299. */
  42300. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42301. /**
  42302. * Boolean indicating if the plugin can direct load specific data
  42303. */
  42304. canDirectLoad?: (data: string) => boolean;
  42305. }
  42306. /**
  42307. * Interface used to define a SceneLoader plugin
  42308. */
  42309. export interface ISceneLoaderPlugin {
  42310. /**
  42311. * The friendly name of this plugin.
  42312. */
  42313. name: string;
  42314. /**
  42315. * The file extensions supported by this plugin.
  42316. */
  42317. extensions: string | ISceneLoaderPluginExtensions;
  42318. /**
  42319. * Import meshes into a scene.
  42320. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42321. * @param scene The scene to import into
  42322. * @param data The data to import
  42323. * @param rootUrl The root url for scene and resources
  42324. * @param meshes The meshes array to import into
  42325. * @param particleSystems The particle systems array to import into
  42326. * @param skeletons The skeletons array to import into
  42327. * @param onError The callback when import fails
  42328. * @returns True if successful or false otherwise
  42329. */
  42330. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42331. /**
  42332. * Load into a scene.
  42333. * @param scene The scene to load into
  42334. * @param data The data to import
  42335. * @param rootUrl The root url for scene and resources
  42336. * @param onError The callback when import fails
  42337. * @returns true if successful or false otherwise
  42338. */
  42339. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42340. /**
  42341. * The callback that returns true if the data can be directly loaded.
  42342. */
  42343. canDirectLoad?: (data: string) => boolean;
  42344. /**
  42345. * The callback that allows custom handling of the root url based on the response url.
  42346. */
  42347. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42348. /**
  42349. * Load into an asset container.
  42350. * @param scene The scene to load into
  42351. * @param data The data to import
  42352. * @param rootUrl The root url for scene and resources
  42353. * @param onError The callback when import fails
  42354. * @returns The loaded asset container
  42355. */
  42356. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42357. }
  42358. /**
  42359. * Interface used to define an async SceneLoader plugin
  42360. */
  42361. export interface ISceneLoaderPluginAsync {
  42362. /**
  42363. * The friendly name of this plugin.
  42364. */
  42365. name: string;
  42366. /**
  42367. * The file extensions supported by this plugin.
  42368. */
  42369. extensions: string | ISceneLoaderPluginExtensions;
  42370. /**
  42371. * Import meshes into a scene.
  42372. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42373. * @param scene The scene to import into
  42374. * @param data The data to import
  42375. * @param rootUrl The root url for scene and resources
  42376. * @param onProgress The callback when the load progresses
  42377. * @param fileName Defines the name of the file to load
  42378. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42379. */
  42380. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42381. meshes: AbstractMesh[];
  42382. particleSystems: IParticleSystem[];
  42383. skeletons: Skeleton[];
  42384. animationGroups: AnimationGroup[];
  42385. }>;
  42386. /**
  42387. * Load into a scene.
  42388. * @param scene The scene to load into
  42389. * @param data The data to import
  42390. * @param rootUrl The root url for scene and resources
  42391. * @param onProgress The callback when the load progresses
  42392. * @param fileName Defines the name of the file to load
  42393. * @returns Nothing
  42394. */
  42395. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42396. /**
  42397. * The callback that returns true if the data can be directly loaded.
  42398. */
  42399. canDirectLoad?: (data: string) => boolean;
  42400. /**
  42401. * The callback that allows custom handling of the root url based on the response url.
  42402. */
  42403. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42404. /**
  42405. * Load into an asset container.
  42406. * @param scene The scene to load into
  42407. * @param data The data to import
  42408. * @param rootUrl The root url for scene and resources
  42409. * @param onProgress The callback when the load progresses
  42410. * @param fileName Defines the name of the file to load
  42411. * @returns The loaded asset container
  42412. */
  42413. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42414. }
  42415. /**
  42416. * Class used to load scene from various file formats using registered plugins
  42417. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42418. */
  42419. export class SceneLoader {
  42420. /**
  42421. * No logging while loading
  42422. */
  42423. static readonly NO_LOGGING: number;
  42424. /**
  42425. * Minimal logging while loading
  42426. */
  42427. static readonly MINIMAL_LOGGING: number;
  42428. /**
  42429. * Summary logging while loading
  42430. */
  42431. static readonly SUMMARY_LOGGING: number;
  42432. /**
  42433. * Detailled logging while loading
  42434. */
  42435. static readonly DETAILED_LOGGING: number;
  42436. /**
  42437. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42438. */
  42439. static ForceFullSceneLoadingForIncremental: boolean;
  42440. /**
  42441. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42442. */
  42443. static ShowLoadingScreen: boolean;
  42444. /**
  42445. * Defines the current logging level (while loading the scene)
  42446. * @ignorenaming
  42447. */
  42448. static loggingLevel: number;
  42449. /**
  42450. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42451. */
  42452. static CleanBoneMatrixWeights: boolean;
  42453. /**
  42454. * Event raised when a plugin is used to load a scene
  42455. */
  42456. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42457. private static _registeredPlugins;
  42458. private static _getDefaultPlugin;
  42459. private static _getPluginForExtension;
  42460. private static _getPluginForDirectLoad;
  42461. private static _getPluginForFilename;
  42462. private static _getDirectLoad;
  42463. private static _loadData;
  42464. private static _getFileInfo;
  42465. /**
  42466. * Gets a plugin that can load the given extension
  42467. * @param extension defines the extension to load
  42468. * @returns a plugin or null if none works
  42469. */
  42470. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42471. /**
  42472. * Gets a boolean indicating that the given extension can be loaded
  42473. * @param extension defines the extension to load
  42474. * @returns true if the extension is supported
  42475. */
  42476. static IsPluginForExtensionAvailable(extension: string): boolean;
  42477. /**
  42478. * Adds a new plugin to the list of registered plugins
  42479. * @param plugin defines the plugin to add
  42480. */
  42481. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42482. /**
  42483. * Import meshes into a scene
  42484. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42485. * @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)
  42486. * @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)
  42487. * @param scene the instance of BABYLON.Scene to append to
  42488. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42489. * @param onProgress a callback with a progress event for each file being loaded
  42490. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42491. * @param pluginExtension the extension used to determine the plugin
  42492. * @returns The loaded plugin
  42493. */
  42494. 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: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42495. /**
  42496. * Import meshes into a scene
  42497. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42498. * @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)
  42499. * @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)
  42500. * @param scene the instance of BABYLON.Scene to append to
  42501. * @param onProgress a callback with a progress event for each file being loaded
  42502. * @param pluginExtension the extension used to determine the plugin
  42503. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42504. */
  42505. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42506. meshes: AbstractMesh[];
  42507. particleSystems: IParticleSystem[];
  42508. skeletons: Skeleton[];
  42509. animationGroups: AnimationGroup[];
  42510. }>;
  42511. /**
  42512. * Load a scene
  42513. * @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)
  42514. * @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)
  42515. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42516. * @param onSuccess a callback with the scene when import succeeds
  42517. * @param onProgress a callback with a progress event for each file being loaded
  42518. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42519. * @param pluginExtension the extension used to determine the plugin
  42520. * @returns The loaded plugin
  42521. */
  42522. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42523. /**
  42524. * Load a scene
  42525. * @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)
  42526. * @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)
  42527. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42528. * @param onProgress a callback with a progress event for each file being loaded
  42529. * @param pluginExtension the extension used to determine the plugin
  42530. * @returns The loaded scene
  42531. */
  42532. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42533. /**
  42534. * Append a scene
  42535. * @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)
  42536. * @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)
  42537. * @param scene is the instance of BABYLON.Scene to append to
  42538. * @param onSuccess a callback with the scene when import succeeds
  42539. * @param onProgress a callback with a progress event for each file being loaded
  42540. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42541. * @param pluginExtension the extension used to determine the plugin
  42542. * @returns The loaded plugin
  42543. */
  42544. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42545. /**
  42546. * Append a scene
  42547. * @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)
  42548. * @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)
  42549. * @param scene is the instance of BABYLON.Scene to append to
  42550. * @param onProgress a callback with a progress event for each file being loaded
  42551. * @param pluginExtension the extension used to determine the plugin
  42552. * @returns The given scene
  42553. */
  42554. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42555. /**
  42556. * Load a scene into an asset container
  42557. * @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)
  42558. * @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)
  42559. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42560. * @param onSuccess a callback with the scene when import succeeds
  42561. * @param onProgress a callback with a progress event for each file being loaded
  42562. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42563. * @param pluginExtension the extension used to determine the plugin
  42564. * @returns The loaded plugin
  42565. */
  42566. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42567. /**
  42568. * Load a scene into an asset container
  42569. * @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)
  42570. * @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)
  42571. * @param scene is the instance of Scene to append to
  42572. * @param onProgress a callback with a progress event for each file being loaded
  42573. * @param pluginExtension the extension used to determine the plugin
  42574. * @returns The loaded asset container
  42575. */
  42576. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42577. }
  42578. }
  42579. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42580. import { Scene } from "babylonjs/scene";
  42581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42582. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42583. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42584. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42585. /**
  42586. * Google Daydream controller
  42587. */
  42588. export class DaydreamController extends WebVRController {
  42589. /**
  42590. * Base Url for the controller model.
  42591. */
  42592. static MODEL_BASE_URL: string;
  42593. /**
  42594. * File name for the controller model.
  42595. */
  42596. static MODEL_FILENAME: string;
  42597. /**
  42598. * Gamepad Id prefix used to identify Daydream Controller.
  42599. */
  42600. static readonly GAMEPAD_ID_PREFIX: string;
  42601. /**
  42602. * Creates a new DaydreamController from a gamepad
  42603. * @param vrGamepad the gamepad that the controller should be created from
  42604. */
  42605. constructor(vrGamepad: any);
  42606. /**
  42607. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42608. * @param scene scene in which to add meshes
  42609. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42610. */
  42611. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42612. /**
  42613. * Called once for each button that changed state since the last frame
  42614. * @param buttonIdx Which button index changed
  42615. * @param state New state of the button
  42616. * @param changes Which properties on the state changed since last frame
  42617. */
  42618. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42619. }
  42620. }
  42621. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42622. import { Scene } from "babylonjs/scene";
  42623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42624. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42625. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42626. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42627. /**
  42628. * Gear VR Controller
  42629. */
  42630. export class GearVRController extends WebVRController {
  42631. /**
  42632. * Base Url for the controller model.
  42633. */
  42634. static MODEL_BASE_URL: string;
  42635. /**
  42636. * File name for the controller model.
  42637. */
  42638. static MODEL_FILENAME: string;
  42639. /**
  42640. * Gamepad Id prefix used to identify this controller.
  42641. */
  42642. static readonly GAMEPAD_ID_PREFIX: string;
  42643. private readonly _buttonIndexToObservableNameMap;
  42644. /**
  42645. * Creates a new GearVRController from a gamepad
  42646. * @param vrGamepad the gamepad that the controller should be created from
  42647. */
  42648. constructor(vrGamepad: any);
  42649. /**
  42650. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42651. * @param scene scene in which to add meshes
  42652. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42653. */
  42654. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42655. /**
  42656. * Called once for each button that changed state since the last frame
  42657. * @param buttonIdx Which button index changed
  42658. * @param state New state of the button
  42659. * @param changes Which properties on the state changed since last frame
  42660. */
  42661. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42662. }
  42663. }
  42664. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42665. import { Scene } from "babylonjs/scene";
  42666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42667. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42668. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42669. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42670. /**
  42671. * Generic Controller
  42672. */
  42673. export class GenericController extends WebVRController {
  42674. /**
  42675. * Base Url for the controller model.
  42676. */
  42677. static readonly MODEL_BASE_URL: string;
  42678. /**
  42679. * File name for the controller model.
  42680. */
  42681. static readonly MODEL_FILENAME: string;
  42682. /**
  42683. * Creates a new GenericController from a gamepad
  42684. * @param vrGamepad the gamepad that the controller should be created from
  42685. */
  42686. constructor(vrGamepad: any);
  42687. /**
  42688. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42689. * @param scene scene in which to add meshes
  42690. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42691. */
  42692. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42693. /**
  42694. * Called once for each button that changed state since the last frame
  42695. * @param buttonIdx Which button index changed
  42696. * @param state New state of the button
  42697. * @param changes Which properties on the state changed since last frame
  42698. */
  42699. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42700. }
  42701. }
  42702. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42703. import { Observable } from "babylonjs/Misc/observable";
  42704. import { Scene } from "babylonjs/scene";
  42705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42706. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42707. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42708. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42709. /**
  42710. * Oculus Touch Controller
  42711. */
  42712. export class OculusTouchController extends WebVRController {
  42713. /**
  42714. * Base Url for the controller model.
  42715. */
  42716. static MODEL_BASE_URL: string;
  42717. /**
  42718. * File name for the left controller model.
  42719. */
  42720. static MODEL_LEFT_FILENAME: string;
  42721. /**
  42722. * File name for the right controller model.
  42723. */
  42724. static MODEL_RIGHT_FILENAME: string;
  42725. /**
  42726. * Fired when the secondary trigger on this controller is modified
  42727. */
  42728. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42729. /**
  42730. * Fired when the thumb rest on this controller is modified
  42731. */
  42732. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42733. /**
  42734. * Creates a new OculusTouchController from a gamepad
  42735. * @param vrGamepad the gamepad that the controller should be created from
  42736. */
  42737. constructor(vrGamepad: any);
  42738. /**
  42739. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42740. * @param scene scene in which to add meshes
  42741. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42742. */
  42743. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42744. /**
  42745. * Fired when the A button on this controller is modified
  42746. */
  42747. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42748. /**
  42749. * Fired when the B button on this controller is modified
  42750. */
  42751. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42752. /**
  42753. * Fired when the X button on this controller is modified
  42754. */
  42755. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42756. /**
  42757. * Fired when the Y button on this controller is modified
  42758. */
  42759. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42760. /**
  42761. * Called once for each button that changed state since the last frame
  42762. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42763. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42764. * 2) secondary trigger (same)
  42765. * 3) A (right) X (left), touch, pressed = value
  42766. * 4) B / Y
  42767. * 5) thumb rest
  42768. * @param buttonIdx Which button index changed
  42769. * @param state New state of the button
  42770. * @param changes Which properties on the state changed since last frame
  42771. */
  42772. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42773. }
  42774. }
  42775. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42776. import { Scene } from "babylonjs/scene";
  42777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42778. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42779. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42780. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42781. import { Observable } from "babylonjs/Misc/observable";
  42782. /**
  42783. * Vive Controller
  42784. */
  42785. export class ViveController extends WebVRController {
  42786. /**
  42787. * Base Url for the controller model.
  42788. */
  42789. static MODEL_BASE_URL: string;
  42790. /**
  42791. * File name for the controller model.
  42792. */
  42793. static MODEL_FILENAME: string;
  42794. /**
  42795. * Creates a new ViveController from a gamepad
  42796. * @param vrGamepad the gamepad that the controller should be created from
  42797. */
  42798. constructor(vrGamepad: any);
  42799. /**
  42800. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42801. * @param scene scene in which to add meshes
  42802. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42803. */
  42804. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42805. /**
  42806. * Fired when the left button on this controller is modified
  42807. */
  42808. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42809. /**
  42810. * Fired when the right button on this controller is modified
  42811. */
  42812. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42813. /**
  42814. * Fired when the menu button on this controller is modified
  42815. */
  42816. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42817. /**
  42818. * Called once for each button that changed state since the last frame
  42819. * Vive mapping:
  42820. * 0: touchpad
  42821. * 1: trigger
  42822. * 2: left AND right buttons
  42823. * 3: menu button
  42824. * @param buttonIdx Which button index changed
  42825. * @param state New state of the button
  42826. * @param changes Which properties on the state changed since last frame
  42827. */
  42828. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42829. }
  42830. }
  42831. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42832. import { Observable } from "babylonjs/Misc/observable";
  42833. import { Scene } from "babylonjs/scene";
  42834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42835. import { Ray } from "babylonjs/Culling/ray";
  42836. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42837. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42838. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42839. /**
  42840. * Defines the WindowsMotionController object that the state of the windows motion controller
  42841. */
  42842. export class WindowsMotionController extends WebVRController {
  42843. /**
  42844. * The base url used to load the left and right controller models
  42845. */
  42846. static MODEL_BASE_URL: string;
  42847. /**
  42848. * The name of the left controller model file
  42849. */
  42850. static MODEL_LEFT_FILENAME: string;
  42851. /**
  42852. * The name of the right controller model file
  42853. */
  42854. static MODEL_RIGHT_FILENAME: string;
  42855. /**
  42856. * The controller name prefix for this controller type
  42857. */
  42858. static readonly GAMEPAD_ID_PREFIX: string;
  42859. /**
  42860. * The controller id pattern for this controller type
  42861. */
  42862. private static readonly GAMEPAD_ID_PATTERN;
  42863. private _loadedMeshInfo;
  42864. private readonly _mapping;
  42865. /**
  42866. * Fired when the trackpad on this controller is clicked
  42867. */
  42868. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42869. /**
  42870. * Fired when the trackpad on this controller is modified
  42871. */
  42872. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42873. /**
  42874. * The current x and y values of this controller's trackpad
  42875. */
  42876. trackpad: StickValues;
  42877. /**
  42878. * Creates a new WindowsMotionController from a gamepad
  42879. * @param vrGamepad the gamepad that the controller should be created from
  42880. */
  42881. constructor(vrGamepad: any);
  42882. /**
  42883. * Fired when the trigger on this controller is modified
  42884. */
  42885. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42886. /**
  42887. * Fired when the menu button on this controller is modified
  42888. */
  42889. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42890. /**
  42891. * Fired when the grip button on this controller is modified
  42892. */
  42893. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42894. /**
  42895. * Fired when the thumbstick button on this controller is modified
  42896. */
  42897. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42898. /**
  42899. * Fired when the touchpad button on this controller is modified
  42900. */
  42901. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42902. /**
  42903. * Fired when the touchpad values on this controller are modified
  42904. */
  42905. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42906. private _updateTrackpad;
  42907. /**
  42908. * Called once per frame by the engine.
  42909. */
  42910. update(): void;
  42911. /**
  42912. * Called once for each button that changed state since the last frame
  42913. * @param buttonIdx Which button index changed
  42914. * @param state New state of the button
  42915. * @param changes Which properties on the state changed since last frame
  42916. */
  42917. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42918. /**
  42919. * Moves the buttons on the controller mesh based on their current state
  42920. * @param buttonName the name of the button to move
  42921. * @param buttonValue the value of the button which determines the buttons new position
  42922. */
  42923. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42924. /**
  42925. * Moves the axis on the controller mesh based on its current state
  42926. * @param axis the index of the axis
  42927. * @param axisValue the value of the axis which determines the meshes new position
  42928. * @hidden
  42929. */
  42930. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42931. /**
  42932. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42933. * @param scene scene in which to add meshes
  42934. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42935. */
  42936. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42937. /**
  42938. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42939. * can be transformed by button presses and axes values, based on this._mapping.
  42940. *
  42941. * @param scene scene in which the meshes exist
  42942. * @param meshes list of meshes that make up the controller model to process
  42943. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42944. */
  42945. private processModel;
  42946. private createMeshInfo;
  42947. /**
  42948. * Gets the ray of the controller in the direction the controller is pointing
  42949. * @param length the length the resulting ray should be
  42950. * @returns a ray in the direction the controller is pointing
  42951. */
  42952. getForwardRay(length?: number): Ray;
  42953. /**
  42954. * Disposes of the controller
  42955. */
  42956. dispose(): void;
  42957. }
  42958. }
  42959. declare module "babylonjs/Gamepads/Controllers/index" {
  42960. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42961. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42962. export * from "babylonjs/Gamepads/Controllers/genericController";
  42963. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42964. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42965. export * from "babylonjs/Gamepads/Controllers/viveController";
  42966. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42967. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42968. }
  42969. declare module "babylonjs/Gamepads/gamepadManager" {
  42970. import { Observable } from "babylonjs/Misc/observable";
  42971. import { Nullable } from "babylonjs/types";
  42972. import { Scene } from "babylonjs/scene";
  42973. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42974. /**
  42975. * Manager for handling gamepads
  42976. */
  42977. export class GamepadManager {
  42978. private _scene?;
  42979. private _babylonGamepads;
  42980. private _oneGamepadConnected;
  42981. /** @hidden */
  42982. _isMonitoring: boolean;
  42983. private _gamepadEventSupported;
  42984. private _gamepadSupport;
  42985. /**
  42986. * observable to be triggered when the gamepad controller has been connected
  42987. */
  42988. onGamepadConnectedObservable: Observable<Gamepad>;
  42989. /**
  42990. * observable to be triggered when the gamepad controller has been disconnected
  42991. */
  42992. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42993. private _onGamepadConnectedEvent;
  42994. private _onGamepadDisconnectedEvent;
  42995. /**
  42996. * Initializes the gamepad manager
  42997. * @param _scene BabylonJS scene
  42998. */
  42999. constructor(_scene?: Scene | undefined);
  43000. /**
  43001. * The gamepads in the game pad manager
  43002. */
  43003. readonly gamepads: Gamepad[];
  43004. /**
  43005. * Get the gamepad controllers based on type
  43006. * @param type The type of gamepad controller
  43007. * @returns Nullable gamepad
  43008. */
  43009. getGamepadByType(type?: number): Nullable<Gamepad>;
  43010. /**
  43011. * Disposes the gamepad manager
  43012. */
  43013. dispose(): void;
  43014. private _addNewGamepad;
  43015. private _startMonitoringGamepads;
  43016. private _stopMonitoringGamepads;
  43017. /** @hidden */
  43018. _checkGamepadsStatus(): void;
  43019. private _updateGamepadObjects;
  43020. }
  43021. }
  43022. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43023. import { Nullable } from "babylonjs/types";
  43024. import { Scene } from "babylonjs/scene";
  43025. import { ISceneComponent } from "babylonjs/sceneComponent";
  43026. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43027. module "babylonjs/scene" {
  43028. interface Scene {
  43029. /** @hidden */
  43030. _gamepadManager: Nullable<GamepadManager>;
  43031. /**
  43032. * Gets the gamepad manager associated with the scene
  43033. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43034. */
  43035. gamepadManager: GamepadManager;
  43036. }
  43037. }
  43038. module "babylonjs/Cameras/freeCameraInputsManager" {
  43039. /**
  43040. * Interface representing a free camera inputs manager
  43041. */
  43042. interface FreeCameraInputsManager {
  43043. /**
  43044. * Adds gamepad input support to the FreeCameraInputsManager.
  43045. * @returns the FreeCameraInputsManager
  43046. */
  43047. addGamepad(): FreeCameraInputsManager;
  43048. }
  43049. }
  43050. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43051. /**
  43052. * Interface representing an arc rotate camera inputs manager
  43053. */
  43054. interface ArcRotateCameraInputsManager {
  43055. /**
  43056. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43057. * @returns the camera inputs manager
  43058. */
  43059. addGamepad(): ArcRotateCameraInputsManager;
  43060. }
  43061. }
  43062. /**
  43063. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43064. */
  43065. export class GamepadSystemSceneComponent implements ISceneComponent {
  43066. /**
  43067. * The component name helpfull to identify the component in the list of scene components.
  43068. */
  43069. readonly name: string;
  43070. /**
  43071. * The scene the component belongs to.
  43072. */
  43073. scene: Scene;
  43074. /**
  43075. * Creates a new instance of the component for the given scene
  43076. * @param scene Defines the scene to register the component in
  43077. */
  43078. constructor(scene: Scene);
  43079. /**
  43080. * Registers the component in a given scene
  43081. */
  43082. register(): void;
  43083. /**
  43084. * Rebuilds the elements related to this component in case of
  43085. * context lost for instance.
  43086. */
  43087. rebuild(): void;
  43088. /**
  43089. * Disposes the component and the associated ressources
  43090. */
  43091. dispose(): void;
  43092. private _beforeCameraUpdate;
  43093. }
  43094. }
  43095. declare module "babylonjs/Gamepads/index" {
  43096. export * from "babylonjs/Gamepads/Controllers/index";
  43097. export * from "babylonjs/Gamepads/gamepad";
  43098. export * from "babylonjs/Gamepads/gamepadManager";
  43099. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43100. export * from "babylonjs/Gamepads/xboxGamepad";
  43101. }
  43102. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43103. import { Observable } from "babylonjs/Misc/observable";
  43104. import { Nullable } from "babylonjs/types";
  43105. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43107. import { Mesh } from "babylonjs/Meshes/mesh";
  43108. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43109. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43110. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43111. /**
  43112. * Single axis scale gizmo
  43113. */
  43114. export class AxisScaleGizmo extends Gizmo {
  43115. private _coloredMaterial;
  43116. /**
  43117. * Drag behavior responsible for the gizmos dragging interactions
  43118. */
  43119. dragBehavior: PointerDragBehavior;
  43120. private _pointerObserver;
  43121. /**
  43122. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43123. */
  43124. snapDistance: number;
  43125. /**
  43126. * Event that fires each time the gizmo snaps to a new location.
  43127. * * snapDistance is the the change in distance
  43128. */
  43129. onSnapObservable: Observable<{
  43130. snapDistance: number;
  43131. }>;
  43132. /**
  43133. * If the scaling operation should be done on all axis (default: false)
  43134. */
  43135. uniformScaling: boolean;
  43136. /**
  43137. * Creates an AxisScaleGizmo
  43138. * @param gizmoLayer The utility layer the gizmo will be added to
  43139. * @param dragAxis The axis which the gizmo will be able to scale on
  43140. * @param color The color of the gizmo
  43141. */
  43142. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43143. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43144. /**
  43145. * Disposes of the gizmo
  43146. */
  43147. dispose(): void;
  43148. /**
  43149. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43150. * @param mesh The mesh to replace the default mesh of the gizmo
  43151. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43152. */
  43153. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43154. }
  43155. }
  43156. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43157. import { Observable } from "babylonjs/Misc/observable";
  43158. import { Nullable } from "babylonjs/types";
  43159. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43161. import { Mesh } from "babylonjs/Meshes/mesh";
  43162. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43163. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43164. /**
  43165. * Bounding box gizmo
  43166. */
  43167. export class BoundingBoxGizmo extends Gizmo {
  43168. private _lineBoundingBox;
  43169. private _rotateSpheresParent;
  43170. private _scaleBoxesParent;
  43171. private _boundingDimensions;
  43172. private _renderObserver;
  43173. private _pointerObserver;
  43174. private _scaleDragSpeed;
  43175. private _tmpQuaternion;
  43176. private _tmpVector;
  43177. private _tmpRotationMatrix;
  43178. /**
  43179. * 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)
  43180. */
  43181. ignoreChildren: boolean;
  43182. /**
  43183. * 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)
  43184. */
  43185. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43186. /**
  43187. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43188. */
  43189. rotationSphereSize: number;
  43190. /**
  43191. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43192. */
  43193. scaleBoxSize: number;
  43194. /**
  43195. * 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)
  43196. */
  43197. fixedDragMeshScreenSize: boolean;
  43198. /**
  43199. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43200. */
  43201. fixedDragMeshScreenSizeDistanceFactor: number;
  43202. /**
  43203. * Fired when a rotation sphere or scale box is dragged
  43204. */
  43205. onDragStartObservable: Observable<{}>;
  43206. /**
  43207. * Fired when a scale box is dragged
  43208. */
  43209. onScaleBoxDragObservable: Observable<{}>;
  43210. /**
  43211. * Fired when a scale box drag is ended
  43212. */
  43213. onScaleBoxDragEndObservable: Observable<{}>;
  43214. /**
  43215. * Fired when a rotation sphere is dragged
  43216. */
  43217. onRotationSphereDragObservable: Observable<{}>;
  43218. /**
  43219. * Fired when a rotation sphere drag is ended
  43220. */
  43221. onRotationSphereDragEndObservable: Observable<{}>;
  43222. /**
  43223. * 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)
  43224. */
  43225. scalePivot: Nullable<Vector3>;
  43226. private _anchorMesh;
  43227. private _existingMeshScale;
  43228. private _dragMesh;
  43229. private pointerDragBehavior;
  43230. /**
  43231. * Creates an BoundingBoxGizmo
  43232. * @param gizmoLayer The utility layer the gizmo will be added to
  43233. * @param color The color of the gizmo
  43234. */
  43235. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43236. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43237. private _selectNode;
  43238. /**
  43239. * Updates the bounding box information for the Gizmo
  43240. */
  43241. updateBoundingBox(): void;
  43242. private _updateRotationSpheres;
  43243. private _updateScaleBoxes;
  43244. /**
  43245. * Enables rotation on the specified axis and disables rotation on the others
  43246. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43247. */
  43248. setEnabledRotationAxis(axis: string): void;
  43249. /**
  43250. * Enables/disables scaling
  43251. * @param enable if scaling should be enabled
  43252. */
  43253. setEnabledScaling(enable: boolean): void;
  43254. private _updateDummy;
  43255. /**
  43256. * Enables a pointer drag behavior on the bounding box of the gizmo
  43257. */
  43258. enableDragBehavior(): void;
  43259. /**
  43260. * Disposes of the gizmo
  43261. */
  43262. dispose(): void;
  43263. /**
  43264. * 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)
  43265. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43266. * @returns the bounding box mesh with the passed in mesh as a child
  43267. */
  43268. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43269. /**
  43270. * CustomMeshes are not supported by this gizmo
  43271. * @param mesh The mesh to replace the default mesh of the gizmo
  43272. */
  43273. setCustomMesh(mesh: Mesh): void;
  43274. }
  43275. }
  43276. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43277. import { Observable } from "babylonjs/Misc/observable";
  43278. import { Nullable } from "babylonjs/types";
  43279. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43281. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43282. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43283. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43284. /**
  43285. * Single plane rotation gizmo
  43286. */
  43287. export class PlaneRotationGizmo extends Gizmo {
  43288. /**
  43289. * Drag behavior responsible for the gizmos dragging interactions
  43290. */
  43291. dragBehavior: PointerDragBehavior;
  43292. private _pointerObserver;
  43293. /**
  43294. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43295. */
  43296. snapDistance: number;
  43297. /**
  43298. * Event that fires each time the gizmo snaps to a new location.
  43299. * * snapDistance is the the change in distance
  43300. */
  43301. onSnapObservable: Observable<{
  43302. snapDistance: number;
  43303. }>;
  43304. /**
  43305. * Creates a PlaneRotationGizmo
  43306. * @param gizmoLayer The utility layer the gizmo will be added to
  43307. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43308. * @param color The color of the gizmo
  43309. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43310. */
  43311. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43312. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43313. /**
  43314. * Disposes of the gizmo
  43315. */
  43316. dispose(): void;
  43317. }
  43318. }
  43319. declare module "babylonjs/Gizmos/rotationGizmo" {
  43320. import { Observable } from "babylonjs/Misc/observable";
  43321. import { Nullable } from "babylonjs/types";
  43322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43323. import { Mesh } from "babylonjs/Meshes/mesh";
  43324. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43325. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43326. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43327. /**
  43328. * Gizmo that enables rotating a mesh along 3 axis
  43329. */
  43330. export class RotationGizmo extends Gizmo {
  43331. /**
  43332. * Internal gizmo used for interactions on the x axis
  43333. */
  43334. xGizmo: PlaneRotationGizmo;
  43335. /**
  43336. * Internal gizmo used for interactions on the y axis
  43337. */
  43338. yGizmo: PlaneRotationGizmo;
  43339. /**
  43340. * Internal gizmo used for interactions on the z axis
  43341. */
  43342. zGizmo: PlaneRotationGizmo;
  43343. /** Fires an event when any of it's sub gizmos are dragged */
  43344. onDragStartObservable: Observable<{}>;
  43345. /** Fires an event when any of it's sub gizmos are released from dragging */
  43346. onDragEndObservable: Observable<{}>;
  43347. attachedMesh: Nullable<AbstractMesh>;
  43348. /**
  43349. * Creates a RotationGizmo
  43350. * @param gizmoLayer The utility layer the gizmo will be added to
  43351. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43352. */
  43353. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43354. updateGizmoRotationToMatchAttachedMesh: boolean;
  43355. /**
  43356. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43357. */
  43358. snapDistance: number;
  43359. /**
  43360. * Ratio for the scale of the gizmo (Default: 1)
  43361. */
  43362. scaleRatio: number;
  43363. /**
  43364. * Disposes of the gizmo
  43365. */
  43366. dispose(): void;
  43367. /**
  43368. * CustomMeshes are not supported by this gizmo
  43369. * @param mesh The mesh to replace the default mesh of the gizmo
  43370. */
  43371. setCustomMesh(mesh: Mesh): void;
  43372. }
  43373. }
  43374. declare module "babylonjs/Gizmos/positionGizmo" {
  43375. import { Observable } from "babylonjs/Misc/observable";
  43376. import { Nullable } from "babylonjs/types";
  43377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43378. import { Mesh } from "babylonjs/Meshes/mesh";
  43379. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43380. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43381. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43382. /**
  43383. * Gizmo that enables dragging a mesh along 3 axis
  43384. */
  43385. export class PositionGizmo extends Gizmo {
  43386. /**
  43387. * Internal gizmo used for interactions on the x axis
  43388. */
  43389. xGizmo: AxisDragGizmo;
  43390. /**
  43391. * Internal gizmo used for interactions on the y axis
  43392. */
  43393. yGizmo: AxisDragGizmo;
  43394. /**
  43395. * Internal gizmo used for interactions on the z axis
  43396. */
  43397. zGizmo: AxisDragGizmo;
  43398. /** Fires an event when any of it's sub gizmos are dragged */
  43399. onDragStartObservable: Observable<{}>;
  43400. /** Fires an event when any of it's sub gizmos are released from dragging */
  43401. onDragEndObservable: Observable<{}>;
  43402. attachedMesh: Nullable<AbstractMesh>;
  43403. /**
  43404. * Creates a PositionGizmo
  43405. * @param gizmoLayer The utility layer the gizmo will be added to
  43406. */
  43407. constructor(gizmoLayer?: UtilityLayerRenderer);
  43408. updateGizmoRotationToMatchAttachedMesh: boolean;
  43409. /**
  43410. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43411. */
  43412. snapDistance: number;
  43413. /**
  43414. * Ratio for the scale of the gizmo (Default: 1)
  43415. */
  43416. scaleRatio: number;
  43417. /**
  43418. * Disposes of the gizmo
  43419. */
  43420. dispose(): void;
  43421. /**
  43422. * CustomMeshes are not supported by this gizmo
  43423. * @param mesh The mesh to replace the default mesh of the gizmo
  43424. */
  43425. setCustomMesh(mesh: Mesh): void;
  43426. }
  43427. }
  43428. declare module "babylonjs/Gizmos/scaleGizmo" {
  43429. import { Observable } from "babylonjs/Misc/observable";
  43430. import { Nullable } from "babylonjs/types";
  43431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43432. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43433. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43434. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43435. /**
  43436. * Gizmo that enables scaling a mesh along 3 axis
  43437. */
  43438. export class ScaleGizmo extends Gizmo {
  43439. /**
  43440. * Internal gizmo used for interactions on the x axis
  43441. */
  43442. xGizmo: AxisScaleGizmo;
  43443. /**
  43444. * Internal gizmo used for interactions on the y axis
  43445. */
  43446. yGizmo: AxisScaleGizmo;
  43447. /**
  43448. * Internal gizmo used for interactions on the z axis
  43449. */
  43450. zGizmo: AxisScaleGizmo;
  43451. /**
  43452. * Internal gizmo used to scale all axis equally
  43453. */
  43454. uniformScaleGizmo: AxisScaleGizmo;
  43455. /** Fires an event when any of it's sub gizmos are dragged */
  43456. onDragStartObservable: Observable<{}>;
  43457. /** Fires an event when any of it's sub gizmos are released from dragging */
  43458. onDragEndObservable: Observable<{}>;
  43459. attachedMesh: Nullable<AbstractMesh>;
  43460. /**
  43461. * Creates a ScaleGizmo
  43462. * @param gizmoLayer The utility layer the gizmo will be added to
  43463. */
  43464. constructor(gizmoLayer?: UtilityLayerRenderer);
  43465. updateGizmoRotationToMatchAttachedMesh: boolean;
  43466. /**
  43467. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43468. */
  43469. snapDistance: number;
  43470. /**
  43471. * Ratio for the scale of the gizmo (Default: 1)
  43472. */
  43473. scaleRatio: number;
  43474. /**
  43475. * Disposes of the gizmo
  43476. */
  43477. dispose(): void;
  43478. }
  43479. }
  43480. declare module "babylonjs/Gizmos/gizmoManager" {
  43481. import { Observable } from "babylonjs/Misc/observable";
  43482. import { Nullable } from "babylonjs/types";
  43483. import { Scene, IDisposable } from "babylonjs/scene";
  43484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43485. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43486. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43487. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43488. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43489. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43490. /**
  43491. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43492. */
  43493. export class GizmoManager implements IDisposable {
  43494. private scene;
  43495. /**
  43496. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43497. */
  43498. gizmos: {
  43499. positionGizmo: Nullable<PositionGizmo>;
  43500. rotationGizmo: Nullable<RotationGizmo>;
  43501. scaleGizmo: Nullable<ScaleGizmo>;
  43502. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43503. };
  43504. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43505. clearGizmoOnEmptyPointerEvent: boolean;
  43506. /** Fires an event when the manager is attached to a mesh */
  43507. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43508. private _gizmosEnabled;
  43509. private _pointerObserver;
  43510. private _attachedMesh;
  43511. private _boundingBoxColor;
  43512. private _defaultUtilityLayer;
  43513. private _defaultKeepDepthUtilityLayer;
  43514. /**
  43515. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43516. */
  43517. boundingBoxDragBehavior: SixDofDragBehavior;
  43518. /**
  43519. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43520. */
  43521. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43522. /**
  43523. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43524. */
  43525. usePointerToAttachGizmos: boolean;
  43526. /**
  43527. * Instatiates a gizmo manager
  43528. * @param scene the scene to overlay the gizmos on top of
  43529. */
  43530. constructor(scene: Scene);
  43531. /**
  43532. * Attaches a set of gizmos to the specified mesh
  43533. * @param mesh The mesh the gizmo's should be attached to
  43534. */
  43535. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43536. /**
  43537. * If the position gizmo is enabled
  43538. */
  43539. positionGizmoEnabled: boolean;
  43540. /**
  43541. * If the rotation gizmo is enabled
  43542. */
  43543. rotationGizmoEnabled: boolean;
  43544. /**
  43545. * If the scale gizmo is enabled
  43546. */
  43547. scaleGizmoEnabled: boolean;
  43548. /**
  43549. * If the boundingBox gizmo is enabled
  43550. */
  43551. boundingBoxGizmoEnabled: boolean;
  43552. /**
  43553. * Disposes of the gizmo manager
  43554. */
  43555. dispose(): void;
  43556. }
  43557. }
  43558. declare module "babylonjs/Gizmos/index" {
  43559. export * from "babylonjs/Gizmos/axisDragGizmo";
  43560. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43561. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43562. export * from "babylonjs/Gizmos/gizmo";
  43563. export * from "babylonjs/Gizmos/gizmoManager";
  43564. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43565. export * from "babylonjs/Gizmos/positionGizmo";
  43566. export * from "babylonjs/Gizmos/rotationGizmo";
  43567. export * from "babylonjs/Gizmos/scaleGizmo";
  43568. }
  43569. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43570. /** @hidden */
  43571. export var backgroundFragmentDeclaration: {
  43572. name: string;
  43573. shader: string;
  43574. };
  43575. }
  43576. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43577. /** @hidden */
  43578. export var backgroundUboDeclaration: {
  43579. name: string;
  43580. shader: string;
  43581. };
  43582. }
  43583. declare module "babylonjs/Shaders/background.fragment" {
  43584. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43585. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43586. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43587. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43588. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43589. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43590. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43591. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43592. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43593. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43594. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43595. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43596. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43597. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43598. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43599. /** @hidden */
  43600. export var backgroundPixelShader: {
  43601. name: string;
  43602. shader: string;
  43603. };
  43604. }
  43605. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43606. /** @hidden */
  43607. export var backgroundVertexDeclaration: {
  43608. name: string;
  43609. shader: string;
  43610. };
  43611. }
  43612. declare module "babylonjs/Shaders/background.vertex" {
  43613. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43614. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43615. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43616. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43617. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43618. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43619. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43620. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43621. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43622. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43623. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43624. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43625. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43626. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43627. /** @hidden */
  43628. export var backgroundVertexShader: {
  43629. name: string;
  43630. shader: string;
  43631. };
  43632. }
  43633. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43634. import { Nullable, int, float } from "babylonjs/types";
  43635. import { Scene } from "babylonjs/scene";
  43636. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43637. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43639. import { Mesh } from "babylonjs/Meshes/mesh";
  43640. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43641. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43642. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43643. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43644. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43645. import "babylonjs/Shaders/background.fragment";
  43646. import "babylonjs/Shaders/background.vertex";
  43647. /**
  43648. * Background material used to create an efficient environement around your scene.
  43649. */
  43650. export class BackgroundMaterial extends PushMaterial {
  43651. /**
  43652. * Standard reflectance value at parallel view angle.
  43653. */
  43654. static StandardReflectance0: number;
  43655. /**
  43656. * Standard reflectance value at grazing angle.
  43657. */
  43658. static StandardReflectance90: number;
  43659. protected _primaryColor: Color3;
  43660. /**
  43661. * Key light Color (multiply against the environement texture)
  43662. */
  43663. primaryColor: Color3;
  43664. protected __perceptualColor: Nullable<Color3>;
  43665. /**
  43666. * Experimental Internal Use Only.
  43667. *
  43668. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43669. * This acts as a helper to set the primary color to a more "human friendly" value.
  43670. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43671. * output color as close as possible from the chosen value.
  43672. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43673. * part of lighting setup.)
  43674. */
  43675. _perceptualColor: Nullable<Color3>;
  43676. protected _primaryColorShadowLevel: float;
  43677. /**
  43678. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43679. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43680. */
  43681. primaryColorShadowLevel: float;
  43682. protected _primaryColorHighlightLevel: float;
  43683. /**
  43684. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43685. * The primary color is used at the level chosen to define what the white area would look.
  43686. */
  43687. primaryColorHighlightLevel: float;
  43688. protected _reflectionTexture: Nullable<BaseTexture>;
  43689. /**
  43690. * Reflection Texture used in the material.
  43691. * Should be author in a specific way for the best result (refer to the documentation).
  43692. */
  43693. reflectionTexture: Nullable<BaseTexture>;
  43694. protected _reflectionBlur: float;
  43695. /**
  43696. * Reflection Texture level of blur.
  43697. *
  43698. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43699. * texture twice.
  43700. */
  43701. reflectionBlur: float;
  43702. protected _diffuseTexture: Nullable<BaseTexture>;
  43703. /**
  43704. * Diffuse Texture used in the material.
  43705. * Should be author in a specific way for the best result (refer to the documentation).
  43706. */
  43707. diffuseTexture: Nullable<BaseTexture>;
  43708. protected _shadowLights: Nullable<IShadowLight[]>;
  43709. /**
  43710. * Specify the list of lights casting shadow on the material.
  43711. * All scene shadow lights will be included if null.
  43712. */
  43713. shadowLights: Nullable<IShadowLight[]>;
  43714. protected _shadowLevel: float;
  43715. /**
  43716. * Helps adjusting the shadow to a softer level if required.
  43717. * 0 means black shadows and 1 means no shadows.
  43718. */
  43719. shadowLevel: float;
  43720. protected _sceneCenter: Vector3;
  43721. /**
  43722. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43723. * It is usually zero but might be interesting to modify according to your setup.
  43724. */
  43725. sceneCenter: Vector3;
  43726. protected _opacityFresnel: boolean;
  43727. /**
  43728. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43729. * This helps ensuring a nice transition when the camera goes under the ground.
  43730. */
  43731. opacityFresnel: boolean;
  43732. protected _reflectionFresnel: boolean;
  43733. /**
  43734. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43735. * This helps adding a mirror texture on the ground.
  43736. */
  43737. reflectionFresnel: boolean;
  43738. protected _reflectionFalloffDistance: number;
  43739. /**
  43740. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43741. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43742. */
  43743. reflectionFalloffDistance: number;
  43744. protected _reflectionAmount: number;
  43745. /**
  43746. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43747. */
  43748. reflectionAmount: number;
  43749. protected _reflectionReflectance0: number;
  43750. /**
  43751. * This specifies the weight of the reflection at grazing angle.
  43752. */
  43753. reflectionReflectance0: number;
  43754. protected _reflectionReflectance90: number;
  43755. /**
  43756. * This specifies the weight of the reflection at a perpendicular point of view.
  43757. */
  43758. reflectionReflectance90: number;
  43759. /**
  43760. * Sets the reflection reflectance fresnel values according to the default standard
  43761. * empirically know to work well :-)
  43762. */
  43763. reflectionStandardFresnelWeight: number;
  43764. protected _useRGBColor: boolean;
  43765. /**
  43766. * Helps to directly use the maps channels instead of their level.
  43767. */
  43768. useRGBColor: boolean;
  43769. protected _enableNoise: boolean;
  43770. /**
  43771. * This helps reducing the banding effect that could occur on the background.
  43772. */
  43773. enableNoise: boolean;
  43774. /**
  43775. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43776. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43777. * Recommended to be keep at 1.0 except for special cases.
  43778. */
  43779. fovMultiplier: number;
  43780. private _fovMultiplier;
  43781. /**
  43782. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43783. */
  43784. useEquirectangularFOV: boolean;
  43785. private _maxSimultaneousLights;
  43786. /**
  43787. * Number of Simultaneous lights allowed on the material.
  43788. */
  43789. maxSimultaneousLights: int;
  43790. /**
  43791. * Default configuration related to image processing available in the Background Material.
  43792. */
  43793. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43794. /**
  43795. * Keep track of the image processing observer to allow dispose and replace.
  43796. */
  43797. private _imageProcessingObserver;
  43798. /**
  43799. * Attaches a new image processing configuration to the PBR Material.
  43800. * @param configuration (if null the scene configuration will be use)
  43801. */
  43802. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43803. /**
  43804. * Gets the image processing configuration used either in this material.
  43805. */
  43806. /**
  43807. * Sets the Default image processing configuration used either in the this material.
  43808. *
  43809. * If sets to null, the scene one is in use.
  43810. */
  43811. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43812. /**
  43813. * Gets wether the color curves effect is enabled.
  43814. */
  43815. /**
  43816. * Sets wether the color curves effect is enabled.
  43817. */
  43818. cameraColorCurvesEnabled: boolean;
  43819. /**
  43820. * Gets wether the color grading effect is enabled.
  43821. */
  43822. /**
  43823. * Gets wether the color grading effect is enabled.
  43824. */
  43825. cameraColorGradingEnabled: boolean;
  43826. /**
  43827. * Gets wether tonemapping is enabled or not.
  43828. */
  43829. /**
  43830. * Sets wether tonemapping is enabled or not
  43831. */
  43832. cameraToneMappingEnabled: boolean;
  43833. /**
  43834. * The camera exposure used on this material.
  43835. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43836. * This corresponds to a photographic exposure.
  43837. */
  43838. /**
  43839. * The camera exposure used on this material.
  43840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43841. * This corresponds to a photographic exposure.
  43842. */
  43843. cameraExposure: float;
  43844. /**
  43845. * Gets The camera contrast used on this material.
  43846. */
  43847. /**
  43848. * Sets The camera contrast used on this material.
  43849. */
  43850. cameraContrast: float;
  43851. /**
  43852. * Gets the Color Grading 2D Lookup Texture.
  43853. */
  43854. /**
  43855. * Sets the Color Grading 2D Lookup Texture.
  43856. */
  43857. cameraColorGradingTexture: Nullable<BaseTexture>;
  43858. /**
  43859. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43860. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43861. * 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;
  43862. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43863. */
  43864. /**
  43865. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43866. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43867. * 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;
  43868. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43869. */
  43870. cameraColorCurves: Nullable<ColorCurves>;
  43871. /**
  43872. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43873. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43874. */
  43875. switchToBGR: boolean;
  43876. private _renderTargets;
  43877. private _reflectionControls;
  43878. private _white;
  43879. private _primaryShadowColor;
  43880. private _primaryHighlightColor;
  43881. /**
  43882. * Instantiates a Background Material in the given scene
  43883. * @param name The friendly name of the material
  43884. * @param scene The scene to add the material to
  43885. */
  43886. constructor(name: string, scene: Scene);
  43887. /**
  43888. * Gets a boolean indicating that current material needs to register RTT
  43889. */
  43890. readonly hasRenderTargetTextures: boolean;
  43891. /**
  43892. * The entire material has been created in order to prevent overdraw.
  43893. * @returns false
  43894. */
  43895. needAlphaTesting(): boolean;
  43896. /**
  43897. * The entire material has been created in order to prevent overdraw.
  43898. * @returns true if blending is enable
  43899. */
  43900. needAlphaBlending(): boolean;
  43901. /**
  43902. * Checks wether the material is ready to be rendered for a given mesh.
  43903. * @param mesh The mesh to render
  43904. * @param subMesh The submesh to check against
  43905. * @param useInstances Specify wether or not the material is used with instances
  43906. * @returns true if all the dependencies are ready (Textures, Effects...)
  43907. */
  43908. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43909. /**
  43910. * Compute the primary color according to the chosen perceptual color.
  43911. */
  43912. private _computePrimaryColorFromPerceptualColor;
  43913. /**
  43914. * Compute the highlights and shadow colors according to their chosen levels.
  43915. */
  43916. private _computePrimaryColors;
  43917. /**
  43918. * Build the uniform buffer used in the material.
  43919. */
  43920. buildUniformLayout(): void;
  43921. /**
  43922. * Unbind the material.
  43923. */
  43924. unbind(): void;
  43925. /**
  43926. * Bind only the world matrix to the material.
  43927. * @param world The world matrix to bind.
  43928. */
  43929. bindOnlyWorldMatrix(world: Matrix): void;
  43930. /**
  43931. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43932. * @param world The world matrix to bind.
  43933. * @param subMesh The submesh to bind for.
  43934. */
  43935. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43936. /**
  43937. * Dispose the material.
  43938. * @param forceDisposeEffect Force disposal of the associated effect.
  43939. * @param forceDisposeTextures Force disposal of the associated textures.
  43940. */
  43941. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43942. /**
  43943. * Clones the material.
  43944. * @param name The cloned name.
  43945. * @returns The cloned material.
  43946. */
  43947. clone(name: string): BackgroundMaterial;
  43948. /**
  43949. * Serializes the current material to its JSON representation.
  43950. * @returns The JSON representation.
  43951. */
  43952. serialize(): any;
  43953. /**
  43954. * Gets the class name of the material
  43955. * @returns "BackgroundMaterial"
  43956. */
  43957. getClassName(): string;
  43958. /**
  43959. * Parse a JSON input to create back a background material.
  43960. * @param source The JSON data to parse
  43961. * @param scene The scene to create the parsed material in
  43962. * @param rootUrl The root url of the assets the material depends upon
  43963. * @returns the instantiated BackgroundMaterial.
  43964. */
  43965. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43966. }
  43967. }
  43968. declare module "babylonjs/Helpers/environmentHelper" {
  43969. import { Observable } from "babylonjs/Misc/observable";
  43970. import { Nullable } from "babylonjs/types";
  43971. import { Scene } from "babylonjs/scene";
  43972. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43974. import { Mesh } from "babylonjs/Meshes/mesh";
  43975. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43976. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43977. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43978. /**
  43979. * Represents the different options available during the creation of
  43980. * a Environment helper.
  43981. *
  43982. * This can control the default ground, skybox and image processing setup of your scene.
  43983. */
  43984. export interface IEnvironmentHelperOptions {
  43985. /**
  43986. * Specifies wether or not to create a ground.
  43987. * True by default.
  43988. */
  43989. createGround: boolean;
  43990. /**
  43991. * Specifies the ground size.
  43992. * 15 by default.
  43993. */
  43994. groundSize: number;
  43995. /**
  43996. * The texture used on the ground for the main color.
  43997. * Comes from the BabylonJS CDN by default.
  43998. *
  43999. * Remarks: Can be either a texture or a url.
  44000. */
  44001. groundTexture: string | BaseTexture;
  44002. /**
  44003. * The color mixed in the ground texture by default.
  44004. * BabylonJS clearColor by default.
  44005. */
  44006. groundColor: Color3;
  44007. /**
  44008. * Specifies the ground opacity.
  44009. * 1 by default.
  44010. */
  44011. groundOpacity: number;
  44012. /**
  44013. * Enables the ground to receive shadows.
  44014. * True by default.
  44015. */
  44016. enableGroundShadow: boolean;
  44017. /**
  44018. * Helps preventing the shadow to be fully black on the ground.
  44019. * 0.5 by default.
  44020. */
  44021. groundShadowLevel: number;
  44022. /**
  44023. * Creates a mirror texture attach to the ground.
  44024. * false by default.
  44025. */
  44026. enableGroundMirror: boolean;
  44027. /**
  44028. * Specifies the ground mirror size ratio.
  44029. * 0.3 by default as the default kernel is 64.
  44030. */
  44031. groundMirrorSizeRatio: number;
  44032. /**
  44033. * Specifies the ground mirror blur kernel size.
  44034. * 64 by default.
  44035. */
  44036. groundMirrorBlurKernel: number;
  44037. /**
  44038. * Specifies the ground mirror visibility amount.
  44039. * 1 by default
  44040. */
  44041. groundMirrorAmount: number;
  44042. /**
  44043. * Specifies the ground mirror reflectance weight.
  44044. * This uses the standard weight of the background material to setup the fresnel effect
  44045. * of the mirror.
  44046. * 1 by default.
  44047. */
  44048. groundMirrorFresnelWeight: number;
  44049. /**
  44050. * Specifies the ground mirror Falloff distance.
  44051. * This can helps reducing the size of the reflection.
  44052. * 0 by Default.
  44053. */
  44054. groundMirrorFallOffDistance: number;
  44055. /**
  44056. * Specifies the ground mirror texture type.
  44057. * Unsigned Int by Default.
  44058. */
  44059. groundMirrorTextureType: number;
  44060. /**
  44061. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44062. * the shown objects.
  44063. */
  44064. groundYBias: number;
  44065. /**
  44066. * Specifies wether or not to create a skybox.
  44067. * True by default.
  44068. */
  44069. createSkybox: boolean;
  44070. /**
  44071. * Specifies the skybox size.
  44072. * 20 by default.
  44073. */
  44074. skyboxSize: number;
  44075. /**
  44076. * The texture used on the skybox for the main color.
  44077. * Comes from the BabylonJS CDN by default.
  44078. *
  44079. * Remarks: Can be either a texture or a url.
  44080. */
  44081. skyboxTexture: string | BaseTexture;
  44082. /**
  44083. * The color mixed in the skybox texture by default.
  44084. * BabylonJS clearColor by default.
  44085. */
  44086. skyboxColor: Color3;
  44087. /**
  44088. * The background rotation around the Y axis of the scene.
  44089. * This helps aligning the key lights of your scene with the background.
  44090. * 0 by default.
  44091. */
  44092. backgroundYRotation: number;
  44093. /**
  44094. * Compute automatically the size of the elements to best fit with the scene.
  44095. */
  44096. sizeAuto: boolean;
  44097. /**
  44098. * Default position of the rootMesh if autoSize is not true.
  44099. */
  44100. rootPosition: Vector3;
  44101. /**
  44102. * Sets up the image processing in the scene.
  44103. * true by default.
  44104. */
  44105. setupImageProcessing: boolean;
  44106. /**
  44107. * The texture used as your environment texture in the scene.
  44108. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44109. *
  44110. * Remarks: Can be either a texture or a url.
  44111. */
  44112. environmentTexture: string | BaseTexture;
  44113. /**
  44114. * The value of the exposure to apply to the scene.
  44115. * 0.6 by default if setupImageProcessing is true.
  44116. */
  44117. cameraExposure: number;
  44118. /**
  44119. * The value of the contrast to apply to the scene.
  44120. * 1.6 by default if setupImageProcessing is true.
  44121. */
  44122. cameraContrast: number;
  44123. /**
  44124. * Specifies wether or not tonemapping should be enabled in the scene.
  44125. * true by default if setupImageProcessing is true.
  44126. */
  44127. toneMappingEnabled: boolean;
  44128. }
  44129. /**
  44130. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44131. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44132. * It also helps with the default setup of your imageProcessing configuration.
  44133. */
  44134. export class EnvironmentHelper {
  44135. /**
  44136. * Default ground texture URL.
  44137. */
  44138. private static _groundTextureCDNUrl;
  44139. /**
  44140. * Default skybox texture URL.
  44141. */
  44142. private static _skyboxTextureCDNUrl;
  44143. /**
  44144. * Default environment texture URL.
  44145. */
  44146. private static _environmentTextureCDNUrl;
  44147. /**
  44148. * Creates the default options for the helper.
  44149. */
  44150. private static _getDefaultOptions;
  44151. private _rootMesh;
  44152. /**
  44153. * Gets the root mesh created by the helper.
  44154. */
  44155. readonly rootMesh: Mesh;
  44156. private _skybox;
  44157. /**
  44158. * Gets the skybox created by the helper.
  44159. */
  44160. readonly skybox: Nullable<Mesh>;
  44161. private _skyboxTexture;
  44162. /**
  44163. * Gets the skybox texture created by the helper.
  44164. */
  44165. readonly skyboxTexture: Nullable<BaseTexture>;
  44166. private _skyboxMaterial;
  44167. /**
  44168. * Gets the skybox material created by the helper.
  44169. */
  44170. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44171. private _ground;
  44172. /**
  44173. * Gets the ground mesh created by the helper.
  44174. */
  44175. readonly ground: Nullable<Mesh>;
  44176. private _groundTexture;
  44177. /**
  44178. * Gets the ground texture created by the helper.
  44179. */
  44180. readonly groundTexture: Nullable<BaseTexture>;
  44181. private _groundMirror;
  44182. /**
  44183. * Gets the ground mirror created by the helper.
  44184. */
  44185. readonly groundMirror: Nullable<MirrorTexture>;
  44186. /**
  44187. * Gets the ground mirror render list to helps pushing the meshes
  44188. * you wish in the ground reflection.
  44189. */
  44190. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44191. private _groundMaterial;
  44192. /**
  44193. * Gets the ground material created by the helper.
  44194. */
  44195. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44196. /**
  44197. * Stores the creation options.
  44198. */
  44199. private readonly _scene;
  44200. private _options;
  44201. /**
  44202. * This observable will be notified with any error during the creation of the environment,
  44203. * mainly texture creation errors.
  44204. */
  44205. onErrorObservable: Observable<{
  44206. message?: string;
  44207. exception?: any;
  44208. }>;
  44209. /**
  44210. * constructor
  44211. * @param options
  44212. * @param scene The scene to add the material to
  44213. */
  44214. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44215. /**
  44216. * Updates the background according to the new options
  44217. * @param options
  44218. */
  44219. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44220. /**
  44221. * Sets the primary color of all the available elements.
  44222. * @param color the main color to affect to the ground and the background
  44223. */
  44224. setMainColor(color: Color3): void;
  44225. /**
  44226. * Setup the image processing according to the specified options.
  44227. */
  44228. private _setupImageProcessing;
  44229. /**
  44230. * Setup the environment texture according to the specified options.
  44231. */
  44232. private _setupEnvironmentTexture;
  44233. /**
  44234. * Setup the background according to the specified options.
  44235. */
  44236. private _setupBackground;
  44237. /**
  44238. * Get the scene sizes according to the setup.
  44239. */
  44240. private _getSceneSize;
  44241. /**
  44242. * Setup the ground according to the specified options.
  44243. */
  44244. private _setupGround;
  44245. /**
  44246. * Setup the ground material according to the specified options.
  44247. */
  44248. private _setupGroundMaterial;
  44249. /**
  44250. * Setup the ground diffuse texture according to the specified options.
  44251. */
  44252. private _setupGroundDiffuseTexture;
  44253. /**
  44254. * Setup the ground mirror texture according to the specified options.
  44255. */
  44256. private _setupGroundMirrorTexture;
  44257. /**
  44258. * Setup the ground to receive the mirror texture.
  44259. */
  44260. private _setupMirrorInGroundMaterial;
  44261. /**
  44262. * Setup the skybox according to the specified options.
  44263. */
  44264. private _setupSkybox;
  44265. /**
  44266. * Setup the skybox material according to the specified options.
  44267. */
  44268. private _setupSkyboxMaterial;
  44269. /**
  44270. * Setup the skybox reflection texture according to the specified options.
  44271. */
  44272. private _setupSkyboxReflectionTexture;
  44273. private _errorHandler;
  44274. /**
  44275. * Dispose all the elements created by the Helper.
  44276. */
  44277. dispose(): void;
  44278. }
  44279. }
  44280. declare module "babylonjs/Helpers/photoDome" {
  44281. import { Observable } from "babylonjs/Misc/observable";
  44282. import { Nullable } from "babylonjs/types";
  44283. import { Scene } from "babylonjs/scene";
  44284. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44285. import { Mesh } from "babylonjs/Meshes/mesh";
  44286. import { Texture } from "babylonjs/Materials/Textures/texture";
  44287. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44288. import "babylonjs/Meshes/meshBuilder";
  44289. /**
  44290. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44291. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44292. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44293. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44294. */
  44295. export class PhotoDome extends TransformNode {
  44296. private _useDirectMapping;
  44297. /**
  44298. * The texture being displayed on the sphere
  44299. */
  44300. protected _photoTexture: Texture;
  44301. /**
  44302. * Gets or sets the texture being displayed on the sphere
  44303. */
  44304. photoTexture: Texture;
  44305. /**
  44306. * Observable raised when an error occured while loading the 360 image
  44307. */
  44308. onLoadErrorObservable: Observable<string>;
  44309. /**
  44310. * The skybox material
  44311. */
  44312. protected _material: BackgroundMaterial;
  44313. /**
  44314. * The surface used for the skybox
  44315. */
  44316. protected _mesh: Mesh;
  44317. /**
  44318. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44319. * Also see the options.resolution property.
  44320. */
  44321. fovMultiplier: number;
  44322. /**
  44323. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44324. * @param name Element's name, child elements will append suffixes for their own names.
  44325. * @param urlsOfPhoto defines the url of the photo to display
  44326. * @param options defines an object containing optional or exposed sub element properties
  44327. * @param onError defines a callback called when an error occured while loading the texture
  44328. */
  44329. constructor(name: string, urlOfPhoto: string, options: {
  44330. resolution?: number;
  44331. size?: number;
  44332. useDirectMapping?: boolean;
  44333. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44334. /**
  44335. * Releases resources associated with this node.
  44336. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44337. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44338. */
  44339. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44340. }
  44341. }
  44342. declare module "babylonjs/Misc/textureTools" {
  44343. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44344. import { Texture } from "babylonjs/Materials/Textures/texture";
  44345. import { Scene } from "babylonjs/scene";
  44346. /**
  44347. * Class used to host texture specific utilities
  44348. */
  44349. export class TextureTools {
  44350. /**
  44351. * Uses the GPU to create a copy texture rescaled at a given size
  44352. * @param texture Texture to copy from
  44353. * @param width defines the desired width
  44354. * @param height defines the desired height
  44355. * @param useBilinearMode defines if bilinear mode has to be used
  44356. * @return the generated texture
  44357. */
  44358. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44359. /**
  44360. * Gets an environment BRDF texture for a given scene
  44361. * @param scene defines the hosting scene
  44362. * @returns the environment BRDF texture
  44363. */
  44364. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44365. private static _environmentBRDFBase64Texture;
  44366. }
  44367. }
  44368. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44369. /** @hidden */
  44370. export var pbrFragmentDeclaration: {
  44371. name: string;
  44372. shader: string;
  44373. };
  44374. }
  44375. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44376. /** @hidden */
  44377. export var pbrUboDeclaration: {
  44378. name: string;
  44379. shader: string;
  44380. };
  44381. }
  44382. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44383. /** @hidden */
  44384. export var pbrFunctions: {
  44385. name: string;
  44386. shader: string;
  44387. };
  44388. }
  44389. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44390. /** @hidden */
  44391. export var harmonicsFunctions: {
  44392. name: string;
  44393. shader: string;
  44394. };
  44395. }
  44396. declare module "babylonjs/Shaders/ShadersInclude/pbrLightFunctions" {
  44397. /** @hidden */
  44398. export var pbrLightFunctions: {
  44399. name: string;
  44400. shader: string;
  44401. };
  44402. }
  44403. declare module "babylonjs/Shaders/pbr.fragment" {
  44404. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44405. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44406. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44407. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44408. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44409. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44410. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44411. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44412. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44413. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44414. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44415. import "babylonjs/Shaders/ShadersInclude/pbrLightFunctions";
  44416. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44417. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44418. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44419. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44420. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44421. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44422. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44423. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44424. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44425. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44426. /** @hidden */
  44427. export var pbrPixelShader: {
  44428. name: string;
  44429. shader: string;
  44430. };
  44431. }
  44432. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44433. /** @hidden */
  44434. export var pbrVertexDeclaration: {
  44435. name: string;
  44436. shader: string;
  44437. };
  44438. }
  44439. declare module "babylonjs/Shaders/pbr.vertex" {
  44440. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44441. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44442. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44443. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44444. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44445. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44446. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44447. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44448. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44449. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44450. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44451. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44452. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44453. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44454. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44455. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44456. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44457. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44458. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44459. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44460. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44461. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44462. /** @hidden */
  44463. export var pbrVertexShader: {
  44464. name: string;
  44465. shader: string;
  44466. };
  44467. }
  44468. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44469. import { IAnimatable } from "babylonjs/Misc/tools";
  44470. import { Nullable } from "babylonjs/types";
  44471. import { Scene } from "babylonjs/scene";
  44472. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44473. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44475. import { Mesh } from "babylonjs/Meshes/mesh";
  44476. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44477. import { Material } from "babylonjs/Materials/material";
  44478. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44479. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44480. import "babylonjs/Shaders/pbr.fragment";
  44481. import "babylonjs/Shaders/pbr.vertex";
  44482. /**
  44483. * The Physically based material base class of BJS.
  44484. *
  44485. * This offers the main features of a standard PBR material.
  44486. * For more information, please refer to the documentation :
  44487. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44488. */
  44489. export abstract class PBRBaseMaterial extends PushMaterial {
  44490. /**
  44491. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44492. */
  44493. static readonly PBRMATERIAL_OPAQUE: number;
  44494. /**
  44495. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44496. */
  44497. static readonly PBRMATERIAL_ALPHATEST: number;
  44498. /**
  44499. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44500. */
  44501. static readonly PBRMATERIAL_ALPHABLEND: number;
  44502. /**
  44503. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44504. * They are also discarded below the alpha cutoff threshold to improve performances.
  44505. */
  44506. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44507. /**
  44508. * Defines the default value of how much AO map is occluding the analytical lights
  44509. * (point spot...).
  44510. */
  44511. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44512. /**
  44513. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44514. */
  44515. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44516. /**
  44517. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44518. * to enhance interoperability with other engines.
  44519. */
  44520. static readonly LIGHTFALLOFF_GLTF: number;
  44521. /**
  44522. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44523. * to enhance interoperability with other materials.
  44524. */
  44525. static readonly LIGHTFALLOFF_STANDARD: number;
  44526. /**
  44527. * Intensity of the direct lights e.g. the four lights available in your scene.
  44528. * This impacts both the direct diffuse and specular highlights.
  44529. */
  44530. protected _directIntensity: number;
  44531. /**
  44532. * Intensity of the emissive part of the material.
  44533. * This helps controlling the emissive effect without modifying the emissive color.
  44534. */
  44535. protected _emissiveIntensity: number;
  44536. /**
  44537. * Intensity of the environment e.g. how much the environment will light the object
  44538. * either through harmonics for rough material or through the refelction for shiny ones.
  44539. */
  44540. protected _environmentIntensity: number;
  44541. /**
  44542. * This is a special control allowing the reduction of the specular highlights coming from the
  44543. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44544. */
  44545. protected _specularIntensity: number;
  44546. /**
  44547. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44548. */
  44549. private _lightingInfos;
  44550. /**
  44551. * Debug Control allowing disabling the bump map on this material.
  44552. */
  44553. protected _disableBumpMap: boolean;
  44554. /**
  44555. * AKA Diffuse Texture in standard nomenclature.
  44556. */
  44557. protected _albedoTexture: BaseTexture;
  44558. /**
  44559. * AKA Occlusion Texture in other nomenclature.
  44560. */
  44561. protected _ambientTexture: BaseTexture;
  44562. /**
  44563. * AKA Occlusion Texture Intensity in other nomenclature.
  44564. */
  44565. protected _ambientTextureStrength: number;
  44566. /**
  44567. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44568. * 1 means it completely occludes it
  44569. * 0 mean it has no impact
  44570. */
  44571. protected _ambientTextureImpactOnAnalyticalLights: number;
  44572. /**
  44573. * Stores the alpha values in a texture.
  44574. */
  44575. protected _opacityTexture: BaseTexture;
  44576. /**
  44577. * Stores the reflection values in a texture.
  44578. */
  44579. protected _reflectionTexture: BaseTexture;
  44580. /**
  44581. * Stores the refraction values in a texture.
  44582. */
  44583. protected _refractionTexture: BaseTexture;
  44584. /**
  44585. * Stores the emissive values in a texture.
  44586. */
  44587. protected _emissiveTexture: BaseTexture;
  44588. /**
  44589. * AKA Specular texture in other nomenclature.
  44590. */
  44591. protected _reflectivityTexture: BaseTexture;
  44592. /**
  44593. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44594. */
  44595. protected _metallicTexture: BaseTexture;
  44596. /**
  44597. * Specifies the metallic scalar of the metallic/roughness workflow.
  44598. * Can also be used to scale the metalness values of the metallic texture.
  44599. */
  44600. protected _metallic: Nullable<number>;
  44601. /**
  44602. * Specifies the roughness scalar of the metallic/roughness workflow.
  44603. * Can also be used to scale the roughness values of the metallic texture.
  44604. */
  44605. protected _roughness: Nullable<number>;
  44606. /**
  44607. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44608. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44609. */
  44610. protected _microSurfaceTexture: BaseTexture;
  44611. /**
  44612. * Stores surface normal data used to displace a mesh in a texture.
  44613. */
  44614. protected _bumpTexture: BaseTexture;
  44615. /**
  44616. * Stores the pre-calculated light information of a mesh in a texture.
  44617. */
  44618. protected _lightmapTexture: BaseTexture;
  44619. /**
  44620. * The color of a material in ambient lighting.
  44621. */
  44622. protected _ambientColor: Color3;
  44623. /**
  44624. * AKA Diffuse Color in other nomenclature.
  44625. */
  44626. protected _albedoColor: Color3;
  44627. /**
  44628. * AKA Specular Color in other nomenclature.
  44629. */
  44630. protected _reflectivityColor: Color3;
  44631. /**
  44632. * The color applied when light is reflected from a material.
  44633. */
  44634. protected _reflectionColor: Color3;
  44635. /**
  44636. * The color applied when light is emitted from a material.
  44637. */
  44638. protected _emissiveColor: Color3;
  44639. /**
  44640. * AKA Glossiness in other nomenclature.
  44641. */
  44642. protected _microSurface: number;
  44643. /**
  44644. * source material index of refraction (IOR)' / 'destination material IOR.
  44645. */
  44646. protected _indexOfRefraction: number;
  44647. /**
  44648. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44649. */
  44650. protected _invertRefractionY: boolean;
  44651. /**
  44652. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44653. * Materials half opaque for instance using refraction could benefit from this control.
  44654. */
  44655. protected _linkRefractionWithTransparency: boolean;
  44656. /**
  44657. * Specifies that the material will use the light map as a show map.
  44658. */
  44659. protected _useLightmapAsShadowmap: boolean;
  44660. /**
  44661. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44662. * makes the reflect vector face the model (under horizon).
  44663. */
  44664. protected _useHorizonOcclusion: boolean;
  44665. /**
  44666. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44667. * too much the area relying on ambient texture to define their ambient occlusion.
  44668. */
  44669. protected _useRadianceOcclusion: boolean;
  44670. /**
  44671. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44672. */
  44673. protected _useAlphaFromAlbedoTexture: boolean;
  44674. /**
  44675. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44676. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44677. */
  44678. protected _useSpecularOverAlpha: boolean;
  44679. /**
  44680. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44681. */
  44682. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44683. /**
  44684. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44685. */
  44686. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44687. /**
  44688. * Specifies if the metallic texture contains the roughness information in its green channel.
  44689. */
  44690. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44691. /**
  44692. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44693. */
  44694. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44695. /**
  44696. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44697. */
  44698. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44699. /**
  44700. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44701. */
  44702. protected _useAmbientInGrayScale: boolean;
  44703. /**
  44704. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44705. * The material will try to infer what glossiness each pixel should be.
  44706. */
  44707. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44708. /**
  44709. * Defines the falloff type used in this material.
  44710. * It by default is Physical.
  44711. */
  44712. protected _lightFalloff: number;
  44713. /**
  44714. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44715. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44716. */
  44717. protected _useRadianceOverAlpha: boolean;
  44718. /**
  44719. * Allows using an object space normal map (instead of tangent space).
  44720. */
  44721. protected _useObjectSpaceNormalMap: boolean;
  44722. /**
  44723. * Allows using the bump map in parallax mode.
  44724. */
  44725. protected _useParallax: boolean;
  44726. /**
  44727. * Allows using the bump map in parallax occlusion mode.
  44728. */
  44729. protected _useParallaxOcclusion: boolean;
  44730. /**
  44731. * Controls the scale bias of the parallax mode.
  44732. */
  44733. protected _parallaxScaleBias: number;
  44734. /**
  44735. * If sets to true, disables all the lights affecting the material.
  44736. */
  44737. protected _disableLighting: boolean;
  44738. /**
  44739. * Number of Simultaneous lights allowed on the material.
  44740. */
  44741. protected _maxSimultaneousLights: number;
  44742. /**
  44743. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44744. */
  44745. protected _invertNormalMapX: boolean;
  44746. /**
  44747. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44748. */
  44749. protected _invertNormalMapY: boolean;
  44750. /**
  44751. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44752. */
  44753. protected _twoSidedLighting: boolean;
  44754. /**
  44755. * Defines the alpha limits in alpha test mode.
  44756. */
  44757. protected _alphaCutOff: number;
  44758. /**
  44759. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44760. */
  44761. protected _forceAlphaTest: boolean;
  44762. /**
  44763. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44764. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44765. */
  44766. protected _useAlphaFresnel: boolean;
  44767. /**
  44768. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44769. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44770. */
  44771. protected _useLinearAlphaFresnel: boolean;
  44772. /**
  44773. * The transparency mode of the material.
  44774. */
  44775. protected _transparencyMode: Nullable<number>;
  44776. /**
  44777. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44778. * from cos thetav and roughness:
  44779. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44780. */
  44781. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44782. /**
  44783. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44784. */
  44785. protected _forceIrradianceInFragment: boolean;
  44786. /**
  44787. * Force normal to face away from face.
  44788. */
  44789. protected _forceNormalForward: boolean;
  44790. /**
  44791. * Enables specular anti aliasing in the PBR shader.
  44792. * It will both interacts on the Geometry for analytical and IBL lighting.
  44793. * It also prefilter the roughness map based on the bump values.
  44794. */
  44795. protected _enableSpecularAntiAliasing: boolean;
  44796. /**
  44797. * Default configuration related to image processing available in the PBR Material.
  44798. */
  44799. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44800. /**
  44801. * Keep track of the image processing observer to allow dispose and replace.
  44802. */
  44803. private _imageProcessingObserver;
  44804. /**
  44805. * Attaches a new image processing configuration to the PBR Material.
  44806. * @param configuration
  44807. */
  44808. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44809. /**
  44810. * Stores the available render targets.
  44811. */
  44812. private _renderTargets;
  44813. /**
  44814. * Sets the global ambient color for the material used in lighting calculations.
  44815. */
  44816. private _globalAmbientColor;
  44817. /**
  44818. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44819. */
  44820. private _useLogarithmicDepth;
  44821. /**
  44822. * If set to true, no lighting calculations will be applied.
  44823. */
  44824. private _unlit;
  44825. /**
  44826. * Instantiates a new PBRMaterial instance.
  44827. *
  44828. * @param name The material name
  44829. * @param scene The scene the material will be use in.
  44830. */
  44831. constructor(name: string, scene: Scene);
  44832. /**
  44833. * Gets a boolean indicating that current material needs to register RTT
  44834. */
  44835. readonly hasRenderTargetTextures: boolean;
  44836. /**
  44837. * Gets the name of the material class.
  44838. */
  44839. getClassName(): string;
  44840. /**
  44841. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44842. */
  44843. /**
  44844. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44845. */
  44846. useLogarithmicDepth: boolean;
  44847. /**
  44848. * Gets the current transparency mode.
  44849. */
  44850. /**
  44851. * Sets the transparency mode of the material.
  44852. *
  44853. * | Value | Type | Description |
  44854. * | ----- | ----------------------------------- | ----------- |
  44855. * | 0 | OPAQUE | |
  44856. * | 1 | ALPHATEST | |
  44857. * | 2 | ALPHABLEND | |
  44858. * | 3 | ALPHATESTANDBLEND | |
  44859. *
  44860. */
  44861. transparencyMode: Nullable<number>;
  44862. /**
  44863. * Returns true if alpha blending should be disabled.
  44864. */
  44865. private readonly _disableAlphaBlending;
  44866. /**
  44867. * Specifies whether or not this material should be rendered in alpha blend mode.
  44868. */
  44869. needAlphaBlending(): boolean;
  44870. /**
  44871. * Specifies if the mesh will require alpha blending.
  44872. * @param mesh - BJS mesh.
  44873. */
  44874. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44875. /**
  44876. * Specifies whether or not this material should be rendered in alpha test mode.
  44877. */
  44878. needAlphaTesting(): boolean;
  44879. /**
  44880. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44881. */
  44882. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44883. /**
  44884. * Gets the texture used for the alpha test.
  44885. */
  44886. getAlphaTestTexture(): BaseTexture;
  44887. /**
  44888. * Specifies that the submesh is ready to be used.
  44889. * @param mesh - BJS mesh.
  44890. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44891. * @param useInstances - Specifies that instances should be used.
  44892. * @returns - boolean indicating that the submesh is ready or not.
  44893. */
  44894. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44895. /**
  44896. * Specifies if the material uses metallic roughness workflow.
  44897. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44898. */
  44899. isMetallicWorkflow(): boolean;
  44900. private _prepareEffect;
  44901. private _prepareDefines;
  44902. /**
  44903. * Force shader compilation
  44904. */
  44905. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44906. clipPlane: boolean;
  44907. }>): void;
  44908. /**
  44909. * Initializes the uniform buffer layout for the shader.
  44910. */
  44911. buildUniformLayout(): void;
  44912. /**
  44913. * Unbinds the textures.
  44914. */
  44915. unbind(): void;
  44916. /**
  44917. * Binds the submesh data.
  44918. * @param world - The world matrix.
  44919. * @param mesh - The BJS mesh.
  44920. * @param subMesh - A submesh of the BJS mesh.
  44921. */
  44922. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44923. /**
  44924. * Returns the animatable textures.
  44925. * @returns - Array of animatable textures.
  44926. */
  44927. getAnimatables(): IAnimatable[];
  44928. /**
  44929. * Returns the texture used for reflections.
  44930. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44931. */
  44932. private _getReflectionTexture;
  44933. /**
  44934. * Returns the texture used for refraction or null if none is used.
  44935. * @returns - Refection texture if present. If no refraction texture and refraction
  44936. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44937. */
  44938. private _getRefractionTexture;
  44939. /**
  44940. * Disposes the resources of the material.
  44941. * @param forceDisposeEffect - Forces the disposal of effects.
  44942. * @param forceDisposeTextures - Forces the disposal of all textures.
  44943. */
  44944. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44945. }
  44946. }
  44947. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  44948. import { Nullable } from "babylonjs/types";
  44949. import { Scene } from "babylonjs/scene";
  44950. import { Color3 } from "babylonjs/Maths/math";
  44951. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44952. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44954. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  44955. /**
  44956. * The Physically based material of BJS.
  44957. *
  44958. * This offers the main features of a standard PBR material.
  44959. * For more information, please refer to the documentation :
  44960. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44961. */
  44962. export class PBRMaterial extends PBRBaseMaterial {
  44963. /**
  44964. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44965. */
  44966. static readonly PBRMATERIAL_OPAQUE: number;
  44967. /**
  44968. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44969. */
  44970. static readonly PBRMATERIAL_ALPHATEST: number;
  44971. /**
  44972. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44973. */
  44974. static readonly PBRMATERIAL_ALPHABLEND: number;
  44975. /**
  44976. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44977. * They are also discarded below the alpha cutoff threshold to improve performances.
  44978. */
  44979. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44980. /**
  44981. * Defines the default value of how much AO map is occluding the analytical lights
  44982. * (point spot...).
  44983. */
  44984. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44985. /**
  44986. * Intensity of the direct lights e.g. the four lights available in your scene.
  44987. * This impacts both the direct diffuse and specular highlights.
  44988. */
  44989. directIntensity: number;
  44990. /**
  44991. * Intensity of the emissive part of the material.
  44992. * This helps controlling the emissive effect without modifying the emissive color.
  44993. */
  44994. emissiveIntensity: number;
  44995. /**
  44996. * Intensity of the environment e.g. how much the environment will light the object
  44997. * either through harmonics for rough material or through the refelction for shiny ones.
  44998. */
  44999. environmentIntensity: number;
  45000. /**
  45001. * This is a special control allowing the reduction of the specular highlights coming from the
  45002. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45003. */
  45004. specularIntensity: number;
  45005. /**
  45006. * Debug Control allowing disabling the bump map on this material.
  45007. */
  45008. disableBumpMap: boolean;
  45009. /**
  45010. * AKA Diffuse Texture in standard nomenclature.
  45011. */
  45012. albedoTexture: BaseTexture;
  45013. /**
  45014. * AKA Occlusion Texture in other nomenclature.
  45015. */
  45016. ambientTexture: BaseTexture;
  45017. /**
  45018. * AKA Occlusion Texture Intensity in other nomenclature.
  45019. */
  45020. ambientTextureStrength: number;
  45021. /**
  45022. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45023. * 1 means it completely occludes it
  45024. * 0 mean it has no impact
  45025. */
  45026. ambientTextureImpactOnAnalyticalLights: number;
  45027. /**
  45028. * Stores the alpha values in a texture.
  45029. */
  45030. opacityTexture: BaseTexture;
  45031. /**
  45032. * Stores the reflection values in a texture.
  45033. */
  45034. reflectionTexture: Nullable<BaseTexture>;
  45035. /**
  45036. * Stores the emissive values in a texture.
  45037. */
  45038. emissiveTexture: BaseTexture;
  45039. /**
  45040. * AKA Specular texture in other nomenclature.
  45041. */
  45042. reflectivityTexture: BaseTexture;
  45043. /**
  45044. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45045. */
  45046. metallicTexture: BaseTexture;
  45047. /**
  45048. * Specifies the metallic scalar of the metallic/roughness workflow.
  45049. * Can also be used to scale the metalness values of the metallic texture.
  45050. */
  45051. metallic: Nullable<number>;
  45052. /**
  45053. * Specifies the roughness scalar of the metallic/roughness workflow.
  45054. * Can also be used to scale the roughness values of the metallic texture.
  45055. */
  45056. roughness: Nullable<number>;
  45057. /**
  45058. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45059. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45060. */
  45061. microSurfaceTexture: BaseTexture;
  45062. /**
  45063. * Stores surface normal data used to displace a mesh in a texture.
  45064. */
  45065. bumpTexture: BaseTexture;
  45066. /**
  45067. * Stores the pre-calculated light information of a mesh in a texture.
  45068. */
  45069. lightmapTexture: BaseTexture;
  45070. /**
  45071. * Stores the refracted light information in a texture.
  45072. */
  45073. refractionTexture: BaseTexture;
  45074. /**
  45075. * The color of a material in ambient lighting.
  45076. */
  45077. ambientColor: Color3;
  45078. /**
  45079. * AKA Diffuse Color in other nomenclature.
  45080. */
  45081. albedoColor: Color3;
  45082. /**
  45083. * AKA Specular Color in other nomenclature.
  45084. */
  45085. reflectivityColor: Color3;
  45086. /**
  45087. * The color reflected from the material.
  45088. */
  45089. reflectionColor: Color3;
  45090. /**
  45091. * The color emitted from the material.
  45092. */
  45093. emissiveColor: Color3;
  45094. /**
  45095. * AKA Glossiness in other nomenclature.
  45096. */
  45097. microSurface: number;
  45098. /**
  45099. * source material index of refraction (IOR)' / 'destination material IOR.
  45100. */
  45101. indexOfRefraction: number;
  45102. /**
  45103. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45104. */
  45105. invertRefractionY: boolean;
  45106. /**
  45107. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45108. * Materials half opaque for instance using refraction could benefit from this control.
  45109. */
  45110. linkRefractionWithTransparency: boolean;
  45111. /**
  45112. * If true, the light map contains occlusion information instead of lighting info.
  45113. */
  45114. useLightmapAsShadowmap: boolean;
  45115. /**
  45116. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45117. */
  45118. useAlphaFromAlbedoTexture: boolean;
  45119. /**
  45120. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45121. */
  45122. forceAlphaTest: boolean;
  45123. /**
  45124. * Defines the alpha limits in alpha test mode.
  45125. */
  45126. alphaCutOff: number;
  45127. /**
  45128. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45129. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45130. */
  45131. useSpecularOverAlpha: boolean;
  45132. /**
  45133. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45134. */
  45135. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45136. /**
  45137. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45138. */
  45139. useRoughnessFromMetallicTextureAlpha: boolean;
  45140. /**
  45141. * Specifies if the metallic texture contains the roughness information in its green channel.
  45142. */
  45143. useRoughnessFromMetallicTextureGreen: boolean;
  45144. /**
  45145. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45146. */
  45147. useMetallnessFromMetallicTextureBlue: boolean;
  45148. /**
  45149. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45150. */
  45151. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45152. /**
  45153. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45154. */
  45155. useAmbientInGrayScale: boolean;
  45156. /**
  45157. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45158. * The material will try to infer what glossiness each pixel should be.
  45159. */
  45160. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45161. /**
  45162. * BJS is using an harcoded light falloff based on a manually sets up range.
  45163. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45164. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45165. */
  45166. /**
  45167. * BJS is using an harcoded light falloff based on a manually sets up range.
  45168. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45169. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45170. */
  45171. usePhysicalLightFalloff: boolean;
  45172. /**
  45173. * In order to support the falloff compatibility with gltf, a special mode has been added
  45174. * to reproduce the gltf light falloff.
  45175. */
  45176. /**
  45177. * In order to support the falloff compatibility with gltf, a special mode has been added
  45178. * to reproduce the gltf light falloff.
  45179. */
  45180. useGLTFLightFalloff: boolean;
  45181. /**
  45182. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45183. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45184. */
  45185. useRadianceOverAlpha: boolean;
  45186. /**
  45187. * Allows using an object space normal map (instead of tangent space).
  45188. */
  45189. useObjectSpaceNormalMap: boolean;
  45190. /**
  45191. * Allows using the bump map in parallax mode.
  45192. */
  45193. useParallax: boolean;
  45194. /**
  45195. * Allows using the bump map in parallax occlusion mode.
  45196. */
  45197. useParallaxOcclusion: boolean;
  45198. /**
  45199. * Controls the scale bias of the parallax mode.
  45200. */
  45201. parallaxScaleBias: number;
  45202. /**
  45203. * If sets to true, disables all the lights affecting the material.
  45204. */
  45205. disableLighting: boolean;
  45206. /**
  45207. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45208. */
  45209. forceIrradianceInFragment: boolean;
  45210. /**
  45211. * Number of Simultaneous lights allowed on the material.
  45212. */
  45213. maxSimultaneousLights: number;
  45214. /**
  45215. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45216. */
  45217. invertNormalMapX: boolean;
  45218. /**
  45219. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45220. */
  45221. invertNormalMapY: boolean;
  45222. /**
  45223. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45224. */
  45225. twoSidedLighting: boolean;
  45226. /**
  45227. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45228. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45229. */
  45230. useAlphaFresnel: boolean;
  45231. /**
  45232. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45233. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45234. */
  45235. useLinearAlphaFresnel: boolean;
  45236. /**
  45237. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45238. * And/Or occlude the blended part.
  45239. */
  45240. environmentBRDFTexture: Nullable<BaseTexture>;
  45241. /**
  45242. * Force normal to face away from face.
  45243. */
  45244. forceNormalForward: boolean;
  45245. /**
  45246. * Enables specular anti aliasing in the PBR shader.
  45247. * It will both interacts on the Geometry for analytical and IBL lighting.
  45248. * It also prefilter the roughness map based on the bump values.
  45249. */
  45250. enableSpecularAntiAliasing: boolean;
  45251. /**
  45252. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45253. * makes the reflect vector face the model (under horizon).
  45254. */
  45255. useHorizonOcclusion: boolean;
  45256. /**
  45257. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45258. * too much the area relying on ambient texture to define their ambient occlusion.
  45259. */
  45260. useRadianceOcclusion: boolean;
  45261. /**
  45262. * If set to true, no lighting calculations will be applied.
  45263. */
  45264. unlit: boolean;
  45265. /**
  45266. * Gets the image processing configuration used either in this material.
  45267. */
  45268. /**
  45269. * Sets the Default image processing configuration used either in the this material.
  45270. *
  45271. * If sets to null, the scene one is in use.
  45272. */
  45273. imageProcessingConfiguration: ImageProcessingConfiguration;
  45274. /**
  45275. * Gets wether the color curves effect is enabled.
  45276. */
  45277. /**
  45278. * Sets wether the color curves effect is enabled.
  45279. */
  45280. cameraColorCurvesEnabled: boolean;
  45281. /**
  45282. * Gets wether the color grading effect is enabled.
  45283. */
  45284. /**
  45285. * Gets wether the color grading effect is enabled.
  45286. */
  45287. cameraColorGradingEnabled: boolean;
  45288. /**
  45289. * Gets wether tonemapping is enabled or not.
  45290. */
  45291. /**
  45292. * Sets wether tonemapping is enabled or not
  45293. */
  45294. cameraToneMappingEnabled: boolean;
  45295. /**
  45296. * The camera exposure used on this material.
  45297. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45298. * This corresponds to a photographic exposure.
  45299. */
  45300. /**
  45301. * The camera exposure used on this material.
  45302. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45303. * This corresponds to a photographic exposure.
  45304. */
  45305. cameraExposure: number;
  45306. /**
  45307. * Gets The camera contrast used on this material.
  45308. */
  45309. /**
  45310. * Sets The camera contrast used on this material.
  45311. */
  45312. cameraContrast: number;
  45313. /**
  45314. * Gets the Color Grading 2D Lookup Texture.
  45315. */
  45316. /**
  45317. * Sets the Color Grading 2D Lookup Texture.
  45318. */
  45319. cameraColorGradingTexture: Nullable<BaseTexture>;
  45320. /**
  45321. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45322. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45323. * 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;
  45324. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45325. */
  45326. /**
  45327. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45328. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45329. * 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;
  45330. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45331. */
  45332. cameraColorCurves: Nullable<ColorCurves>;
  45333. /**
  45334. * Instantiates a new PBRMaterial instance.
  45335. *
  45336. * @param name The material name
  45337. * @param scene The scene the material will be use in.
  45338. */
  45339. constructor(name: string, scene: Scene);
  45340. /**
  45341. * Returns the name of this material class.
  45342. */
  45343. getClassName(): string;
  45344. /**
  45345. * Returns an array of the actively used textures.
  45346. * @returns - Array of BaseTextures
  45347. */
  45348. getActiveTextures(): BaseTexture[];
  45349. /**
  45350. * Checks to see if a texture is used in the material.
  45351. * @param texture - Base texture to use.
  45352. * @returns - Boolean specifying if a texture is used in the material.
  45353. */
  45354. hasTexture(texture: BaseTexture): boolean;
  45355. /**
  45356. * Makes a duplicate of the current material.
  45357. * @param name - name to use for the new material.
  45358. */
  45359. clone(name: string): PBRMaterial;
  45360. /**
  45361. * Serializes this PBR Material.
  45362. * @returns - An object with the serialized material.
  45363. */
  45364. serialize(): any;
  45365. /**
  45366. * Parses a PBR Material from a serialized object.
  45367. * @param source - Serialized object.
  45368. * @param scene - BJS scene instance.
  45369. * @param rootUrl - url for the scene object
  45370. * @returns - PBRMaterial
  45371. */
  45372. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45373. }
  45374. }
  45375. declare module "babylonjs/Helpers/sceneHelpers" {
  45376. import { Nullable } from "babylonjs/types";
  45377. import { Mesh } from "babylonjs/Meshes/mesh";
  45378. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45379. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  45380. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45381. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  45382. import "babylonjs/Meshes/meshBuilder";
  45383. /** @hidden */
  45384. export var _forceSceneHelpersToBundle: boolean;
  45385. module "babylonjs/scene" {
  45386. interface Scene {
  45387. /**
  45388. * Creates a default light for the scene.
  45389. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45390. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45391. */
  45392. createDefaultLight(replace?: boolean): void;
  45393. /**
  45394. * Creates a default camera for the scene.
  45395. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45396. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45397. * @param replace has default false, when true replaces the active camera in the scene
  45398. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45399. */
  45400. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45401. /**
  45402. * Creates a default camera and a default light.
  45403. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45404. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45405. * @param replace has the default false, when true replaces the active camera/light in the scene
  45406. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45407. */
  45408. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45409. /**
  45410. * Creates a new sky box
  45411. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45412. * @param environmentTexture defines the texture to use as environment texture
  45413. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45414. * @param scale defines the overall scale of the skybox
  45415. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45416. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45417. * @returns a new mesh holding the sky box
  45418. */
  45419. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45420. /**
  45421. * Creates a new environment
  45422. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45423. * @param options defines the options you can use to configure the environment
  45424. * @returns the new EnvironmentHelper
  45425. */
  45426. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45427. /**
  45428. * Creates a new VREXperienceHelper
  45429. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45430. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45431. * @returns a new VREXperienceHelper
  45432. */
  45433. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45434. /**
  45435. * Creates a new XREXperienceHelper
  45436. * @see http://doc.babylonjs.com/how_to/webxr
  45437. * @returns a promise for a new XREXperienceHelper
  45438. */
  45439. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45440. }
  45441. }
  45442. }
  45443. declare module "babylonjs/Helpers/videoDome" {
  45444. import { Scene } from "babylonjs/scene";
  45445. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45446. import { Mesh } from "babylonjs/Meshes/mesh";
  45447. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  45448. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45449. import "babylonjs/Meshes/meshBuilder";
  45450. /**
  45451. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45452. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45453. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45454. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45455. */
  45456. export class VideoDome extends TransformNode {
  45457. private _useDirectMapping;
  45458. /**
  45459. * The video texture being displayed on the sphere
  45460. */
  45461. protected _videoTexture: VideoTexture;
  45462. /**
  45463. * Gets the video texture being displayed on the sphere
  45464. */
  45465. readonly videoTexture: VideoTexture;
  45466. /**
  45467. * The skybox material
  45468. */
  45469. protected _material: BackgroundMaterial;
  45470. /**
  45471. * The surface used for the skybox
  45472. */
  45473. protected _mesh: Mesh;
  45474. /**
  45475. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45476. * Also see the options.resolution property.
  45477. */
  45478. fovMultiplier: number;
  45479. /**
  45480. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45481. * @param name Element's name, child elements will append suffixes for their own names.
  45482. * @param urlsOrVideo defines the url(s) or the video element to use
  45483. * @param options An object containing optional or exposed sub element properties
  45484. */
  45485. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45486. resolution?: number;
  45487. clickToPlay?: boolean;
  45488. autoPlay?: boolean;
  45489. loop?: boolean;
  45490. size?: number;
  45491. poster?: string;
  45492. useDirectMapping?: boolean;
  45493. }, scene: Scene);
  45494. /**
  45495. * Releases resources associated with this node.
  45496. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45497. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45498. */
  45499. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45500. }
  45501. }
  45502. declare module "babylonjs/Helpers/index" {
  45503. export * from "babylonjs/Helpers/environmentHelper";
  45504. export * from "babylonjs/Helpers/photoDome";
  45505. export * from "babylonjs/Helpers/sceneHelpers";
  45506. export * from "babylonjs/Helpers/videoDome";
  45507. }
  45508. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45509. import { PerfCounter } from "babylonjs/Misc/tools";
  45510. import { IDisposable } from "babylonjs/scene";
  45511. import { Engine } from "babylonjs/Engines/engine";
  45512. /**
  45513. * This class can be used to get instrumentation data from a Babylon engine
  45514. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45515. */
  45516. export class EngineInstrumentation implements IDisposable {
  45517. /**
  45518. * Define the instrumented engine.
  45519. */
  45520. engine: Engine;
  45521. private _captureGPUFrameTime;
  45522. private _gpuFrameTimeToken;
  45523. private _gpuFrameTime;
  45524. private _captureShaderCompilationTime;
  45525. private _shaderCompilationTime;
  45526. private _onBeginFrameObserver;
  45527. private _onEndFrameObserver;
  45528. private _onBeforeShaderCompilationObserver;
  45529. private _onAfterShaderCompilationObserver;
  45530. /**
  45531. * Gets the perf counter used for GPU frame time
  45532. */
  45533. readonly gpuFrameTimeCounter: PerfCounter;
  45534. /**
  45535. * Gets the GPU frame time capture status
  45536. */
  45537. /**
  45538. * Enable or disable the GPU frame time capture
  45539. */
  45540. captureGPUFrameTime: boolean;
  45541. /**
  45542. * Gets the perf counter used for shader compilation time
  45543. */
  45544. readonly shaderCompilationTimeCounter: PerfCounter;
  45545. /**
  45546. * Gets the shader compilation time capture status
  45547. */
  45548. /**
  45549. * Enable or disable the shader compilation time capture
  45550. */
  45551. captureShaderCompilationTime: boolean;
  45552. /**
  45553. * Instantiates a new engine instrumentation.
  45554. * This class can be used to get instrumentation data from a Babylon engine
  45555. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45556. * @param engine Defines the engine to instrument
  45557. */
  45558. constructor(
  45559. /**
  45560. * Define the instrumented engine.
  45561. */
  45562. engine: Engine);
  45563. /**
  45564. * Dispose and release associated resources.
  45565. */
  45566. dispose(): void;
  45567. }
  45568. }
  45569. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45570. import { PerfCounter } from "babylonjs/Misc/tools";
  45571. import { Scene, IDisposable } from "babylonjs/scene";
  45572. /**
  45573. * This class can be used to get instrumentation data from a Babylon engine
  45574. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45575. */
  45576. export class SceneInstrumentation implements IDisposable {
  45577. /**
  45578. * Defines the scene to instrument
  45579. */
  45580. scene: Scene;
  45581. private _captureActiveMeshesEvaluationTime;
  45582. private _activeMeshesEvaluationTime;
  45583. private _captureRenderTargetsRenderTime;
  45584. private _renderTargetsRenderTime;
  45585. private _captureFrameTime;
  45586. private _frameTime;
  45587. private _captureRenderTime;
  45588. private _renderTime;
  45589. private _captureInterFrameTime;
  45590. private _interFrameTime;
  45591. private _captureParticlesRenderTime;
  45592. private _particlesRenderTime;
  45593. private _captureSpritesRenderTime;
  45594. private _spritesRenderTime;
  45595. private _capturePhysicsTime;
  45596. private _physicsTime;
  45597. private _captureAnimationsTime;
  45598. private _animationsTime;
  45599. private _captureCameraRenderTime;
  45600. private _cameraRenderTime;
  45601. private _onBeforeActiveMeshesEvaluationObserver;
  45602. private _onAfterActiveMeshesEvaluationObserver;
  45603. private _onBeforeRenderTargetsRenderObserver;
  45604. private _onAfterRenderTargetsRenderObserver;
  45605. private _onAfterRenderObserver;
  45606. private _onBeforeDrawPhaseObserver;
  45607. private _onAfterDrawPhaseObserver;
  45608. private _onBeforeAnimationsObserver;
  45609. private _onBeforeParticlesRenderingObserver;
  45610. private _onAfterParticlesRenderingObserver;
  45611. private _onBeforeSpritesRenderingObserver;
  45612. private _onAfterSpritesRenderingObserver;
  45613. private _onBeforePhysicsObserver;
  45614. private _onAfterPhysicsObserver;
  45615. private _onAfterAnimationsObserver;
  45616. private _onBeforeCameraRenderObserver;
  45617. private _onAfterCameraRenderObserver;
  45618. /**
  45619. * Gets the perf counter used for active meshes evaluation time
  45620. */
  45621. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45622. /**
  45623. * Gets the active meshes evaluation time capture status
  45624. */
  45625. /**
  45626. * Enable or disable the active meshes evaluation time capture
  45627. */
  45628. captureActiveMeshesEvaluationTime: boolean;
  45629. /**
  45630. * Gets the perf counter used for render targets render time
  45631. */
  45632. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45633. /**
  45634. * Gets the render targets render time capture status
  45635. */
  45636. /**
  45637. * Enable or disable the render targets render time capture
  45638. */
  45639. captureRenderTargetsRenderTime: boolean;
  45640. /**
  45641. * Gets the perf counter used for particles render time
  45642. */
  45643. readonly particlesRenderTimeCounter: PerfCounter;
  45644. /**
  45645. * Gets the particles render time capture status
  45646. */
  45647. /**
  45648. * Enable or disable the particles render time capture
  45649. */
  45650. captureParticlesRenderTime: boolean;
  45651. /**
  45652. * Gets the perf counter used for sprites render time
  45653. */
  45654. readonly spritesRenderTimeCounter: PerfCounter;
  45655. /**
  45656. * Gets the sprites render time capture status
  45657. */
  45658. /**
  45659. * Enable or disable the sprites render time capture
  45660. */
  45661. captureSpritesRenderTime: boolean;
  45662. /**
  45663. * Gets the perf counter used for physics time
  45664. */
  45665. readonly physicsTimeCounter: PerfCounter;
  45666. /**
  45667. * Gets the physics time capture status
  45668. */
  45669. /**
  45670. * Enable or disable the physics time capture
  45671. */
  45672. capturePhysicsTime: boolean;
  45673. /**
  45674. * Gets the perf counter used for animations time
  45675. */
  45676. readonly animationsTimeCounter: PerfCounter;
  45677. /**
  45678. * Gets the animations time capture status
  45679. */
  45680. /**
  45681. * Enable or disable the animations time capture
  45682. */
  45683. captureAnimationsTime: boolean;
  45684. /**
  45685. * Gets the perf counter used for frame time capture
  45686. */
  45687. readonly frameTimeCounter: PerfCounter;
  45688. /**
  45689. * Gets the frame time capture status
  45690. */
  45691. /**
  45692. * Enable or disable the frame time capture
  45693. */
  45694. captureFrameTime: boolean;
  45695. /**
  45696. * Gets the perf counter used for inter-frames time capture
  45697. */
  45698. readonly interFrameTimeCounter: PerfCounter;
  45699. /**
  45700. * Gets the inter-frames time capture status
  45701. */
  45702. /**
  45703. * Enable or disable the inter-frames time capture
  45704. */
  45705. captureInterFrameTime: boolean;
  45706. /**
  45707. * Gets the perf counter used for render time capture
  45708. */
  45709. readonly renderTimeCounter: PerfCounter;
  45710. /**
  45711. * Gets the render time capture status
  45712. */
  45713. /**
  45714. * Enable or disable the render time capture
  45715. */
  45716. captureRenderTime: boolean;
  45717. /**
  45718. * Gets the perf counter used for camera render time capture
  45719. */
  45720. readonly cameraRenderTimeCounter: PerfCounter;
  45721. /**
  45722. * Gets the camera render time capture status
  45723. */
  45724. /**
  45725. * Enable or disable the camera render time capture
  45726. */
  45727. captureCameraRenderTime: boolean;
  45728. /**
  45729. * Gets the perf counter used for draw calls
  45730. */
  45731. readonly drawCallsCounter: PerfCounter;
  45732. /**
  45733. * Gets the perf counter used for texture collisions
  45734. */
  45735. readonly textureCollisionsCounter: PerfCounter;
  45736. /**
  45737. * Instantiates a new scene instrumentation.
  45738. * This class can be used to get instrumentation data from a Babylon engine
  45739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45740. * @param scene Defines the scene to instrument
  45741. */
  45742. constructor(
  45743. /**
  45744. * Defines the scene to instrument
  45745. */
  45746. scene: Scene);
  45747. /**
  45748. * Dispose and release associated resources.
  45749. */
  45750. dispose(): void;
  45751. }
  45752. }
  45753. declare module "babylonjs/Instrumentation/index" {
  45754. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45755. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45756. export * from "babylonjs/Instrumentation/timeToken";
  45757. }
  45758. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45759. /** @hidden */
  45760. export var glowMapGenerationPixelShader: {
  45761. name: string;
  45762. shader: string;
  45763. };
  45764. }
  45765. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45766. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45767. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45768. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45769. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45770. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45771. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45772. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45773. /** @hidden */
  45774. export var glowMapGenerationVertexShader: {
  45775. name: string;
  45776. shader: string;
  45777. };
  45778. }
  45779. declare module "babylonjs/Layers/effectLayer" {
  45780. import { Observable } from "babylonjs/Misc/observable";
  45781. import { Nullable } from "babylonjs/types";
  45782. import { Camera } from "babylonjs/Cameras/camera";
  45783. import { Scene } from "babylonjs/scene";
  45784. import { Color4, ISize } from "babylonjs/Maths/math";
  45785. import { Engine } from "babylonjs/Engines/engine";
  45786. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45788. import { Mesh } from "babylonjs/Meshes/mesh";
  45789. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45790. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45791. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45792. import { Effect } from "babylonjs/Materials/effect";
  45793. import { Material } from "babylonjs/Materials/material";
  45794. import "babylonjs/Shaders/glowMapGeneration.fragment";
  45795. import "babylonjs/Shaders/glowMapGeneration.vertex";
  45796. /**
  45797. * Effect layer options. This helps customizing the behaviour
  45798. * of the effect layer.
  45799. */
  45800. export interface IEffectLayerOptions {
  45801. /**
  45802. * Multiplication factor apply to the canvas size to compute the render target size
  45803. * used to generated the objects (the smaller the faster).
  45804. */
  45805. mainTextureRatio: number;
  45806. /**
  45807. * Enforces a fixed size texture to ensure effect stability across devices.
  45808. */
  45809. mainTextureFixedSize?: number;
  45810. /**
  45811. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45812. */
  45813. alphaBlendingMode: number;
  45814. /**
  45815. * The camera attached to the layer.
  45816. */
  45817. camera: Nullable<Camera>;
  45818. /**
  45819. * The rendering group to draw the layer in.
  45820. */
  45821. renderingGroupId: number;
  45822. }
  45823. /**
  45824. * The effect layer Helps adding post process effect blended with the main pass.
  45825. *
  45826. * This can be for instance use to generate glow or higlight effects on the scene.
  45827. *
  45828. * The effect layer class can not be used directly and is intented to inherited from to be
  45829. * customized per effects.
  45830. */
  45831. export abstract class EffectLayer {
  45832. private _vertexBuffers;
  45833. private _indexBuffer;
  45834. private _cachedDefines;
  45835. private _effectLayerMapGenerationEffect;
  45836. private _effectLayerOptions;
  45837. private _mergeEffect;
  45838. protected _scene: Scene;
  45839. protected _engine: Engine;
  45840. protected _maxSize: number;
  45841. protected _mainTextureDesiredSize: ISize;
  45842. protected _mainTexture: RenderTargetTexture;
  45843. protected _shouldRender: boolean;
  45844. protected _postProcesses: PostProcess[];
  45845. protected _textures: BaseTexture[];
  45846. protected _emissiveTextureAndColor: {
  45847. texture: Nullable<BaseTexture>;
  45848. color: Color4;
  45849. };
  45850. /**
  45851. * The name of the layer
  45852. */
  45853. name: string;
  45854. /**
  45855. * The clear color of the texture used to generate the glow map.
  45856. */
  45857. neutralColor: Color4;
  45858. /**
  45859. * Specifies wether the highlight layer is enabled or not.
  45860. */
  45861. isEnabled: boolean;
  45862. /**
  45863. * Gets the camera attached to the layer.
  45864. */
  45865. readonly camera: Nullable<Camera>;
  45866. /**
  45867. * Gets the rendering group id the layer should render in.
  45868. */
  45869. readonly renderingGroupId: number;
  45870. /**
  45871. * An event triggered when the effect layer has been disposed.
  45872. */
  45873. onDisposeObservable: Observable<EffectLayer>;
  45874. /**
  45875. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45876. */
  45877. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45878. /**
  45879. * An event triggered when the generated texture is being merged in the scene.
  45880. */
  45881. onBeforeComposeObservable: Observable<EffectLayer>;
  45882. /**
  45883. * An event triggered when the generated texture has been merged in the scene.
  45884. */
  45885. onAfterComposeObservable: Observable<EffectLayer>;
  45886. /**
  45887. * An event triggered when the efffect layer changes its size.
  45888. */
  45889. onSizeChangedObservable: Observable<EffectLayer>;
  45890. /** @hidden */
  45891. static _SceneComponentInitialization: (scene: Scene) => void;
  45892. /**
  45893. * Instantiates a new effect Layer and references it in the scene.
  45894. * @param name The name of the layer
  45895. * @param scene The scene to use the layer in
  45896. */
  45897. constructor(
  45898. /** The Friendly of the effect in the scene */
  45899. name: string, scene: Scene);
  45900. /**
  45901. * Get the effect name of the layer.
  45902. * @return The effect name
  45903. */
  45904. abstract getEffectName(): string;
  45905. /**
  45906. * Checks for the readiness of the element composing the layer.
  45907. * @param subMesh the mesh to check for
  45908. * @param useInstances specify wether or not to use instances to render the mesh
  45909. * @return true if ready otherwise, false
  45910. */
  45911. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45912. /**
  45913. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45914. * @returns true if the effect requires stencil during the main canvas render pass.
  45915. */
  45916. abstract needStencil(): boolean;
  45917. /**
  45918. * Create the merge effect. This is the shader use to blit the information back
  45919. * to the main canvas at the end of the scene rendering.
  45920. * @returns The effect containing the shader used to merge the effect on the main canvas
  45921. */
  45922. protected abstract _createMergeEffect(): Effect;
  45923. /**
  45924. * Creates the render target textures and post processes used in the effect layer.
  45925. */
  45926. protected abstract _createTextureAndPostProcesses(): void;
  45927. /**
  45928. * Implementation specific of rendering the generating effect on the main canvas.
  45929. * @param effect The effect used to render through
  45930. */
  45931. protected abstract _internalRender(effect: Effect): void;
  45932. /**
  45933. * Sets the required values for both the emissive texture and and the main color.
  45934. */
  45935. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45936. /**
  45937. * Free any resources and references associated to a mesh.
  45938. * Internal use
  45939. * @param mesh The mesh to free.
  45940. */
  45941. abstract _disposeMesh(mesh: Mesh): void;
  45942. /**
  45943. * Serializes this layer (Glow or Highlight for example)
  45944. * @returns a serialized layer object
  45945. */
  45946. abstract serialize?(): any;
  45947. /**
  45948. * Initializes the effect layer with the required options.
  45949. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45950. */
  45951. protected _init(options: Partial<IEffectLayerOptions>): void;
  45952. /**
  45953. * Generates the index buffer of the full screen quad blending to the main canvas.
  45954. */
  45955. private _generateIndexBuffer;
  45956. /**
  45957. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45958. */
  45959. private _genrateVertexBuffer;
  45960. /**
  45961. * Sets the main texture desired size which is the closest power of two
  45962. * of the engine canvas size.
  45963. */
  45964. private _setMainTextureSize;
  45965. /**
  45966. * Creates the main texture for the effect layer.
  45967. */
  45968. protected _createMainTexture(): void;
  45969. /**
  45970. * Adds specific effects defines.
  45971. * @param defines The defines to add specifics to.
  45972. */
  45973. protected _addCustomEffectDefines(defines: string[]): void;
  45974. /**
  45975. * Checks for the readiness of the element composing the layer.
  45976. * @param subMesh the mesh to check for
  45977. * @param useInstances specify wether or not to use instances to render the mesh
  45978. * @param emissiveTexture the associated emissive texture used to generate the glow
  45979. * @return true if ready otherwise, false
  45980. */
  45981. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45982. /**
  45983. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45984. */
  45985. render(): void;
  45986. /**
  45987. * Determine if a given mesh will be used in the current effect.
  45988. * @param mesh mesh to test
  45989. * @returns true if the mesh will be used
  45990. */
  45991. hasMesh(mesh: AbstractMesh): boolean;
  45992. /**
  45993. * Returns true if the layer contains information to display, otherwise false.
  45994. * @returns true if the glow layer should be rendered
  45995. */
  45996. shouldRender(): boolean;
  45997. /**
  45998. * Returns true if the mesh should render, otherwise false.
  45999. * @param mesh The mesh to render
  46000. * @returns true if it should render otherwise false
  46001. */
  46002. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46003. /**
  46004. * Returns true if the mesh can be rendered, otherwise false.
  46005. * @param mesh The mesh to render
  46006. * @param material The material used on the mesh
  46007. * @returns true if it can be rendered otherwise false
  46008. */
  46009. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46010. /**
  46011. * Returns true if the mesh should render, otherwise false.
  46012. * @param mesh The mesh to render
  46013. * @returns true if it should render otherwise false
  46014. */
  46015. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46016. /**
  46017. * Renders the submesh passed in parameter to the generation map.
  46018. */
  46019. protected _renderSubMesh(subMesh: SubMesh): void;
  46020. /**
  46021. * Rebuild the required buffers.
  46022. * @hidden Internal use only.
  46023. */
  46024. _rebuild(): void;
  46025. /**
  46026. * Dispose only the render target textures and post process.
  46027. */
  46028. private _disposeTextureAndPostProcesses;
  46029. /**
  46030. * Dispose the highlight layer and free resources.
  46031. */
  46032. dispose(): void;
  46033. /**
  46034. * Gets the class name of the effect layer
  46035. * @returns the string with the class name of the effect layer
  46036. */
  46037. getClassName(): string;
  46038. /**
  46039. * Creates an effect layer from parsed effect layer data
  46040. * @param parsedEffectLayer defines effect layer data
  46041. * @param scene defines the current scene
  46042. * @param rootUrl defines the root URL containing the effect layer information
  46043. * @returns a parsed effect Layer
  46044. */
  46045. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46046. }
  46047. }
  46048. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  46049. import { Scene } from "babylonjs/scene";
  46050. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46051. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46052. import { AbstractScene } from "babylonjs/abstractScene";
  46053. module "babylonjs/abstractScene" {
  46054. interface AbstractScene {
  46055. /**
  46056. * The list of effect layers (highlights/glow) added to the scene
  46057. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46058. * @see http://doc.babylonjs.com/how_to/glow_layer
  46059. */
  46060. effectLayers: Array<EffectLayer>;
  46061. /**
  46062. * Removes the given effect layer from this scene.
  46063. * @param toRemove defines the effect layer to remove
  46064. * @returns the index of the removed effect layer
  46065. */
  46066. removeEffectLayer(toRemove: EffectLayer): number;
  46067. /**
  46068. * Adds the given effect layer to this scene
  46069. * @param newEffectLayer defines the effect layer to add
  46070. */
  46071. addEffectLayer(newEffectLayer: EffectLayer): void;
  46072. }
  46073. }
  46074. /**
  46075. * Defines the layer scene component responsible to manage any effect layers
  46076. * in a given scene.
  46077. */
  46078. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46079. /**
  46080. * The component name helpfull to identify the component in the list of scene components.
  46081. */
  46082. readonly name: string;
  46083. /**
  46084. * The scene the component belongs to.
  46085. */
  46086. scene: Scene;
  46087. private _engine;
  46088. private _renderEffects;
  46089. private _needStencil;
  46090. private _previousStencilState;
  46091. /**
  46092. * Creates a new instance of the component for the given scene
  46093. * @param scene Defines the scene to register the component in
  46094. */
  46095. constructor(scene: Scene);
  46096. /**
  46097. * Registers the component in a given scene
  46098. */
  46099. register(): void;
  46100. /**
  46101. * Rebuilds the elements related to this component in case of
  46102. * context lost for instance.
  46103. */
  46104. rebuild(): void;
  46105. /**
  46106. * Serializes the component data to the specified json object
  46107. * @param serializationObject The object to serialize to
  46108. */
  46109. serialize(serializationObject: any): void;
  46110. /**
  46111. * Adds all the element from the container to the scene
  46112. * @param container the container holding the elements
  46113. */
  46114. addFromContainer(container: AbstractScene): void;
  46115. /**
  46116. * Removes all the elements in the container from the scene
  46117. * @param container contains the elements to remove
  46118. */
  46119. removeFromContainer(container: AbstractScene): void;
  46120. /**
  46121. * Disposes the component and the associated ressources.
  46122. */
  46123. dispose(): void;
  46124. private _isReadyForMesh;
  46125. private _renderMainTexture;
  46126. private _setStencil;
  46127. private _setStencilBack;
  46128. private _draw;
  46129. private _drawCamera;
  46130. private _drawRenderingGroup;
  46131. }
  46132. }
  46133. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  46134. /** @hidden */
  46135. export var glowMapMergePixelShader: {
  46136. name: string;
  46137. shader: string;
  46138. };
  46139. }
  46140. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  46141. /** @hidden */
  46142. export var glowMapMergeVertexShader: {
  46143. name: string;
  46144. shader: string;
  46145. };
  46146. }
  46147. declare module "babylonjs/Layers/glowLayer" {
  46148. import { Nullable } from "babylonjs/types";
  46149. import { Camera } from "babylonjs/Cameras/camera";
  46150. import { Scene } from "babylonjs/scene";
  46151. import { Color4 } from "babylonjs/Maths/math";
  46152. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46154. import { Mesh } from "babylonjs/Meshes/mesh";
  46155. import { Texture } from "babylonjs/Materials/Textures/texture";
  46156. import { Effect } from "babylonjs/Materials/effect";
  46157. import { Material } from "babylonjs/Materials/material";
  46158. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46159. import "babylonjs/Shaders/glowMapMerge.fragment";
  46160. import "babylonjs/Shaders/glowMapMerge.vertex";
  46161. module "babylonjs/abstractScene" {
  46162. interface AbstractScene {
  46163. /**
  46164. * Return a the first highlight layer of the scene with a given name.
  46165. * @param name The name of the highlight layer to look for.
  46166. * @return The highlight layer if found otherwise null.
  46167. */
  46168. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46169. }
  46170. }
  46171. /**
  46172. * Glow layer options. This helps customizing the behaviour
  46173. * of the glow layer.
  46174. */
  46175. export interface IGlowLayerOptions {
  46176. /**
  46177. * Multiplication factor apply to the canvas size to compute the render target size
  46178. * used to generated the glowing objects (the smaller the faster).
  46179. */
  46180. mainTextureRatio: number;
  46181. /**
  46182. * Enforces a fixed size texture to ensure resize independant blur.
  46183. */
  46184. mainTextureFixedSize?: number;
  46185. /**
  46186. * How big is the kernel of the blur texture.
  46187. */
  46188. blurKernelSize: number;
  46189. /**
  46190. * The camera attached to the layer.
  46191. */
  46192. camera: Nullable<Camera>;
  46193. /**
  46194. * Enable MSAA by chosing the number of samples.
  46195. */
  46196. mainTextureSamples?: number;
  46197. /**
  46198. * The rendering group to draw the layer in.
  46199. */
  46200. renderingGroupId: number;
  46201. }
  46202. /**
  46203. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46204. *
  46205. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46206. * glowy meshes to your scene.
  46207. *
  46208. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46209. */
  46210. export class GlowLayer extends EffectLayer {
  46211. /**
  46212. * Effect Name of the layer.
  46213. */
  46214. static readonly EffectName: string;
  46215. /**
  46216. * The default blur kernel size used for the glow.
  46217. */
  46218. static DefaultBlurKernelSize: number;
  46219. /**
  46220. * The default texture size ratio used for the glow.
  46221. */
  46222. static DefaultTextureRatio: number;
  46223. /**
  46224. * Sets the kernel size of the blur.
  46225. */
  46226. /**
  46227. * Gets the kernel size of the blur.
  46228. */
  46229. blurKernelSize: number;
  46230. /**
  46231. * Sets the glow intensity.
  46232. */
  46233. /**
  46234. * Gets the glow intensity.
  46235. */
  46236. intensity: number;
  46237. private _options;
  46238. private _intensity;
  46239. private _horizontalBlurPostprocess1;
  46240. private _verticalBlurPostprocess1;
  46241. private _horizontalBlurPostprocess2;
  46242. private _verticalBlurPostprocess2;
  46243. private _blurTexture1;
  46244. private _blurTexture2;
  46245. private _postProcesses1;
  46246. private _postProcesses2;
  46247. private _includedOnlyMeshes;
  46248. private _excludedMeshes;
  46249. /**
  46250. * Callback used to let the user override the color selection on a per mesh basis
  46251. */
  46252. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46253. /**
  46254. * Callback used to let the user override the texture selection on a per mesh basis
  46255. */
  46256. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46257. /**
  46258. * Instantiates a new glow Layer and references it to the scene.
  46259. * @param name The name of the layer
  46260. * @param scene The scene to use the layer in
  46261. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46262. */
  46263. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46264. /**
  46265. * Get the effect name of the layer.
  46266. * @return The effect name
  46267. */
  46268. getEffectName(): string;
  46269. /**
  46270. * Create the merge effect. This is the shader use to blit the information back
  46271. * to the main canvas at the end of the scene rendering.
  46272. */
  46273. protected _createMergeEffect(): Effect;
  46274. /**
  46275. * Creates the render target textures and post processes used in the glow layer.
  46276. */
  46277. protected _createTextureAndPostProcesses(): void;
  46278. /**
  46279. * Checks for the readiness of the element composing the layer.
  46280. * @param subMesh the mesh to check for
  46281. * @param useInstances specify wether or not to use instances to render the mesh
  46282. * @param emissiveTexture the associated emissive texture used to generate the glow
  46283. * @return true if ready otherwise, false
  46284. */
  46285. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46286. /**
  46287. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46288. */
  46289. needStencil(): boolean;
  46290. /**
  46291. * Returns true if the mesh can be rendered, otherwise false.
  46292. * @param mesh The mesh to render
  46293. * @param material The material used on the mesh
  46294. * @returns true if it can be rendered otherwise false
  46295. */
  46296. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46297. /**
  46298. * Implementation specific of rendering the generating effect on the main canvas.
  46299. * @param effect The effect used to render through
  46300. */
  46301. protected _internalRender(effect: Effect): void;
  46302. /**
  46303. * Sets the required values for both the emissive texture and and the main color.
  46304. */
  46305. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46306. /**
  46307. * Returns true if the mesh should render, otherwise false.
  46308. * @param mesh The mesh to render
  46309. * @returns true if it should render otherwise false
  46310. */
  46311. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46312. /**
  46313. * Adds specific effects defines.
  46314. * @param defines The defines to add specifics to.
  46315. */
  46316. protected _addCustomEffectDefines(defines: string[]): void;
  46317. /**
  46318. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46319. * @param mesh The mesh to exclude from the glow layer
  46320. */
  46321. addExcludedMesh(mesh: Mesh): void;
  46322. /**
  46323. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46324. * @param mesh The mesh to remove
  46325. */
  46326. removeExcludedMesh(mesh: Mesh): void;
  46327. /**
  46328. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46329. * @param mesh The mesh to include in the glow layer
  46330. */
  46331. addIncludedOnlyMesh(mesh: Mesh): void;
  46332. /**
  46333. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46334. * @param mesh The mesh to remove
  46335. */
  46336. removeIncludedOnlyMesh(mesh: Mesh): void;
  46337. /**
  46338. * Determine if a given mesh will be used in the glow layer
  46339. * @param mesh The mesh to test
  46340. * @returns true if the mesh will be highlighted by the current glow layer
  46341. */
  46342. hasMesh(mesh: AbstractMesh): boolean;
  46343. /**
  46344. * Free any resources and references associated to a mesh.
  46345. * Internal use
  46346. * @param mesh The mesh to free.
  46347. * @hidden
  46348. */
  46349. _disposeMesh(mesh: Mesh): void;
  46350. /**
  46351. * Gets the class name of the effect layer
  46352. * @returns the string with the class name of the effect layer
  46353. */
  46354. getClassName(): string;
  46355. /**
  46356. * Serializes this glow layer
  46357. * @returns a serialized glow layer object
  46358. */
  46359. serialize(): any;
  46360. /**
  46361. * Creates a Glow Layer from parsed glow layer data
  46362. * @param parsedGlowLayer defines glow layer data
  46363. * @param scene defines the current scene
  46364. * @param rootUrl defines the root URL containing the glow layer information
  46365. * @returns a parsed Glow Layer
  46366. */
  46367. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46368. }
  46369. }
  46370. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  46371. /** @hidden */
  46372. export var glowBlurPostProcessPixelShader: {
  46373. name: string;
  46374. shader: string;
  46375. };
  46376. }
  46377. declare module "babylonjs/Layers/highlightLayer" {
  46378. import { Observable } from "babylonjs/Misc/observable";
  46379. import { Nullable } from "babylonjs/types";
  46380. import { Camera } from "babylonjs/Cameras/camera";
  46381. import { Scene } from "babylonjs/scene";
  46382. import { Color3, Color4 } from "babylonjs/Maths/math";
  46383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46385. import { Mesh } from "babylonjs/Meshes/mesh";
  46386. import { Effect } from "babylonjs/Materials/effect";
  46387. import { Material } from "babylonjs/Materials/material";
  46388. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46389. import "babylonjs/Shaders/glowMapMerge.fragment";
  46390. import "babylonjs/Shaders/glowMapMerge.vertex";
  46391. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  46392. module "babylonjs/abstractScene" {
  46393. interface AbstractScene {
  46394. /**
  46395. * Return a the first highlight layer of the scene with a given name.
  46396. * @param name The name of the highlight layer to look for.
  46397. * @return The highlight layer if found otherwise null.
  46398. */
  46399. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46400. }
  46401. }
  46402. /**
  46403. * Highlight layer options. This helps customizing the behaviour
  46404. * of the highlight layer.
  46405. */
  46406. export interface IHighlightLayerOptions {
  46407. /**
  46408. * Multiplication factor apply to the canvas size to compute the render target size
  46409. * used to generated the glowing objects (the smaller the faster).
  46410. */
  46411. mainTextureRatio: number;
  46412. /**
  46413. * Enforces a fixed size texture to ensure resize independant blur.
  46414. */
  46415. mainTextureFixedSize?: number;
  46416. /**
  46417. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46418. * of the picture to blur (the smaller the faster).
  46419. */
  46420. blurTextureSizeRatio: number;
  46421. /**
  46422. * How big in texel of the blur texture is the vertical blur.
  46423. */
  46424. blurVerticalSize: number;
  46425. /**
  46426. * How big in texel of the blur texture is the horizontal blur.
  46427. */
  46428. blurHorizontalSize: number;
  46429. /**
  46430. * Alpha blending mode used to apply the blur. Default is combine.
  46431. */
  46432. alphaBlendingMode: number;
  46433. /**
  46434. * The camera attached to the layer.
  46435. */
  46436. camera: Nullable<Camera>;
  46437. /**
  46438. * Should we display highlight as a solid stroke?
  46439. */
  46440. isStroke?: boolean;
  46441. /**
  46442. * The rendering group to draw the layer in.
  46443. */
  46444. renderingGroupId: number;
  46445. }
  46446. /**
  46447. * The highlight layer Helps adding a glow effect around a mesh.
  46448. *
  46449. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46450. * glowy meshes to your scene.
  46451. *
  46452. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46453. */
  46454. export class HighlightLayer extends EffectLayer {
  46455. name: string;
  46456. /**
  46457. * Effect Name of the highlight layer.
  46458. */
  46459. static readonly EffectName: string;
  46460. /**
  46461. * The neutral color used during the preparation of the glow effect.
  46462. * This is black by default as the blend operation is a blend operation.
  46463. */
  46464. static NeutralColor: Color4;
  46465. /**
  46466. * Stencil value used for glowing meshes.
  46467. */
  46468. static GlowingMeshStencilReference: number;
  46469. /**
  46470. * Stencil value used for the other meshes in the scene.
  46471. */
  46472. static NormalMeshStencilReference: number;
  46473. /**
  46474. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46475. */
  46476. innerGlow: boolean;
  46477. /**
  46478. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46479. */
  46480. outerGlow: boolean;
  46481. /**
  46482. * Specifies the horizontal size of the blur.
  46483. */
  46484. /**
  46485. * Gets the horizontal size of the blur.
  46486. */
  46487. blurHorizontalSize: number;
  46488. /**
  46489. * Specifies the vertical size of the blur.
  46490. */
  46491. /**
  46492. * Gets the vertical size of the blur.
  46493. */
  46494. blurVerticalSize: number;
  46495. /**
  46496. * An event triggered when the highlight layer is being blurred.
  46497. */
  46498. onBeforeBlurObservable: Observable<HighlightLayer>;
  46499. /**
  46500. * An event triggered when the highlight layer has been blurred.
  46501. */
  46502. onAfterBlurObservable: Observable<HighlightLayer>;
  46503. private _instanceGlowingMeshStencilReference;
  46504. private _options;
  46505. private _downSamplePostprocess;
  46506. private _horizontalBlurPostprocess;
  46507. private _verticalBlurPostprocess;
  46508. private _blurTexture;
  46509. private _meshes;
  46510. private _excludedMeshes;
  46511. /**
  46512. * Instantiates a new highlight Layer and references it to the scene..
  46513. * @param name The name of the layer
  46514. * @param scene The scene to use the layer in
  46515. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46516. */
  46517. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46518. /**
  46519. * Get the effect name of the layer.
  46520. * @return The effect name
  46521. */
  46522. getEffectName(): string;
  46523. /**
  46524. * Create the merge effect. This is the shader use to blit the information back
  46525. * to the main canvas at the end of the scene rendering.
  46526. */
  46527. protected _createMergeEffect(): Effect;
  46528. /**
  46529. * Creates the render target textures and post processes used in the highlight layer.
  46530. */
  46531. protected _createTextureAndPostProcesses(): void;
  46532. /**
  46533. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46534. */
  46535. needStencil(): boolean;
  46536. /**
  46537. * Checks for the readiness of the element composing the layer.
  46538. * @param subMesh the mesh to check for
  46539. * @param useInstances specify wether or not to use instances to render the mesh
  46540. * @param emissiveTexture the associated emissive texture used to generate the glow
  46541. * @return true if ready otherwise, false
  46542. */
  46543. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46544. /**
  46545. * Implementation specific of rendering the generating effect on the main canvas.
  46546. * @param effect The effect used to render through
  46547. */
  46548. protected _internalRender(effect: Effect): void;
  46549. /**
  46550. * Returns true if the layer contains information to display, otherwise false.
  46551. */
  46552. shouldRender(): boolean;
  46553. /**
  46554. * Returns true if the mesh should render, otherwise false.
  46555. * @param mesh The mesh to render
  46556. * @returns true if it should render otherwise false
  46557. */
  46558. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46559. /**
  46560. * Sets the required values for both the emissive texture and and the main color.
  46561. */
  46562. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46563. /**
  46564. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46565. * @param mesh The mesh to exclude from the highlight layer
  46566. */
  46567. addExcludedMesh(mesh: Mesh): void;
  46568. /**
  46569. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46570. * @param mesh The mesh to highlight
  46571. */
  46572. removeExcludedMesh(mesh: Mesh): void;
  46573. /**
  46574. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46575. * @param mesh mesh to test
  46576. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46577. */
  46578. hasMesh(mesh: AbstractMesh): boolean;
  46579. /**
  46580. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46581. * @param mesh The mesh to highlight
  46582. * @param color The color of the highlight
  46583. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46584. */
  46585. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46586. /**
  46587. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46588. * @param mesh The mesh to highlight
  46589. */
  46590. removeMesh(mesh: Mesh): void;
  46591. /**
  46592. * Force the stencil to the normal expected value for none glowing parts
  46593. */
  46594. private _defaultStencilReference;
  46595. /**
  46596. * Free any resources and references associated to a mesh.
  46597. * Internal use
  46598. * @param mesh The mesh to free.
  46599. * @hidden
  46600. */
  46601. _disposeMesh(mesh: Mesh): void;
  46602. /**
  46603. * Dispose the highlight layer and free resources.
  46604. */
  46605. dispose(): void;
  46606. /**
  46607. * Gets the class name of the effect layer
  46608. * @returns the string with the class name of the effect layer
  46609. */
  46610. getClassName(): string;
  46611. /**
  46612. * Serializes this Highlight layer
  46613. * @returns a serialized Highlight layer object
  46614. */
  46615. serialize(): any;
  46616. /**
  46617. * Creates a Highlight layer from parsed Highlight layer data
  46618. * @param parsedHightlightLayer defines the Highlight layer data
  46619. * @param scene defines the current scene
  46620. * @param rootUrl defines the root URL containing the Highlight layer information
  46621. * @returns a parsed Highlight layer
  46622. */
  46623. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46624. }
  46625. }
  46626. declare module "babylonjs/Layers/index" {
  46627. export * from "babylonjs/Layers/effectLayer";
  46628. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46629. export * from "babylonjs/Layers/glowLayer";
  46630. export * from "babylonjs/Layers/highlightLayer";
  46631. export * from "babylonjs/Layers/layer";
  46632. export * from "babylonjs/Layers/layerSceneComponent";
  46633. }
  46634. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46635. /** @hidden */
  46636. export var lensFlarePixelShader: {
  46637. name: string;
  46638. shader: string;
  46639. };
  46640. }
  46641. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46642. /** @hidden */
  46643. export var lensFlareVertexShader: {
  46644. name: string;
  46645. shader: string;
  46646. };
  46647. }
  46648. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46649. import { Scene } from "babylonjs/scene";
  46650. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46652. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46653. import "babylonjs/Shaders/lensFlare.fragment";
  46654. import "babylonjs/Shaders/lensFlare.vertex";
  46655. /**
  46656. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46657. * It is usually composed of several `lensFlare`.
  46658. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46659. */
  46660. export class LensFlareSystem {
  46661. /**
  46662. * Define the name of the lens flare system
  46663. */
  46664. name: string;
  46665. /**
  46666. * List of lens flares used in this system.
  46667. */
  46668. lensFlares: LensFlare[];
  46669. /**
  46670. * Define a limit from the border the lens flare can be visible.
  46671. */
  46672. borderLimit: number;
  46673. /**
  46674. * Define a viewport border we do not want to see the lens flare in.
  46675. */
  46676. viewportBorder: number;
  46677. /**
  46678. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46679. */
  46680. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46681. /**
  46682. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46683. */
  46684. layerMask: number;
  46685. /**
  46686. * Define the id of the lens flare system in the scene.
  46687. * (equal to name by default)
  46688. */
  46689. id: string;
  46690. private _scene;
  46691. private _emitter;
  46692. private _vertexBuffers;
  46693. private _indexBuffer;
  46694. private _effect;
  46695. private _positionX;
  46696. private _positionY;
  46697. private _isEnabled;
  46698. /** @hidden */
  46699. static _SceneComponentInitialization: (scene: Scene) => void;
  46700. /**
  46701. * Instantiates a lens flare system.
  46702. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46703. * It is usually composed of several `lensFlare`.
  46704. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46705. * @param name Define the name of the lens flare system in the scene
  46706. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46707. * @param scene Define the scene the lens flare system belongs to
  46708. */
  46709. constructor(
  46710. /**
  46711. * Define the name of the lens flare system
  46712. */
  46713. name: string, emitter: any, scene: Scene);
  46714. /**
  46715. * Define if the lens flare system is enabled.
  46716. */
  46717. isEnabled: boolean;
  46718. /**
  46719. * Get the scene the effects belongs to.
  46720. * @returns the scene holding the lens flare system
  46721. */
  46722. getScene(): Scene;
  46723. /**
  46724. * Get the emitter of the lens flare system.
  46725. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46726. * @returns the emitter of the lens flare system
  46727. */
  46728. getEmitter(): any;
  46729. /**
  46730. * Set the emitter of the lens flare system.
  46731. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46732. * @param newEmitter Define the new emitter of the system
  46733. */
  46734. setEmitter(newEmitter: any): void;
  46735. /**
  46736. * Get the lens flare system emitter position.
  46737. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46738. * @returns the position
  46739. */
  46740. getEmitterPosition(): Vector3;
  46741. /**
  46742. * @hidden
  46743. */
  46744. computeEffectivePosition(globalViewport: Viewport): boolean;
  46745. /** @hidden */
  46746. _isVisible(): boolean;
  46747. /**
  46748. * @hidden
  46749. */
  46750. render(): boolean;
  46751. /**
  46752. * Dispose and release the lens flare with its associated resources.
  46753. */
  46754. dispose(): void;
  46755. /**
  46756. * Parse a lens flare system from a JSON repressentation
  46757. * @param parsedLensFlareSystem Define the JSON to parse
  46758. * @param scene Define the scene the parsed system should be instantiated in
  46759. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46760. * @returns the parsed system
  46761. */
  46762. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46763. /**
  46764. * Serialize the current Lens Flare System into a JSON representation.
  46765. * @returns the serialized JSON
  46766. */
  46767. serialize(): any;
  46768. }
  46769. }
  46770. declare module "babylonjs/LensFlares/lensFlare" {
  46771. import { Nullable } from "babylonjs/types";
  46772. import { Color3 } from "babylonjs/Maths/math";
  46773. import { Texture } from "babylonjs/Materials/Textures/texture";
  46774. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46775. /**
  46776. * This represents one of the lens effect in a `lensFlareSystem`.
  46777. * It controls one of the indiviual texture used in the effect.
  46778. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46779. */
  46780. export class LensFlare {
  46781. /**
  46782. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46783. */
  46784. size: number;
  46785. /**
  46786. * 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.
  46787. */
  46788. position: number;
  46789. /**
  46790. * Define the lens color.
  46791. */
  46792. color: Color3;
  46793. /**
  46794. * Define the lens texture.
  46795. */
  46796. texture: Nullable<Texture>;
  46797. /**
  46798. * Define the alpha mode to render this particular lens.
  46799. */
  46800. alphaMode: number;
  46801. private _system;
  46802. /**
  46803. * Creates a new Lens Flare.
  46804. * This represents one of the lens effect in a `lensFlareSystem`.
  46805. * It controls one of the indiviual texture used in the effect.
  46806. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46807. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46808. * @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.
  46809. * @param color Define the lens color
  46810. * @param imgUrl Define the lens texture url
  46811. * @param system Define the `lensFlareSystem` this flare is part of
  46812. * @returns The newly created Lens Flare
  46813. */
  46814. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46815. /**
  46816. * Instantiates a new Lens Flare.
  46817. * This represents one of the lens effect in a `lensFlareSystem`.
  46818. * It controls one of the indiviual texture used in the effect.
  46819. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46820. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46821. * @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.
  46822. * @param color Define the lens color
  46823. * @param imgUrl Define the lens texture url
  46824. * @param system Define the `lensFlareSystem` this flare is part of
  46825. */
  46826. constructor(
  46827. /**
  46828. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46829. */
  46830. size: number,
  46831. /**
  46832. * 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.
  46833. */
  46834. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46835. /**
  46836. * Dispose and release the lens flare with its associated resources.
  46837. */
  46838. dispose(): void;
  46839. }
  46840. }
  46841. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46842. import { Nullable } from "babylonjs/types";
  46843. import { Scene } from "babylonjs/scene";
  46844. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46845. import { AbstractScene } from "babylonjs/abstractScene";
  46846. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46847. module "babylonjs/abstractScene" {
  46848. interface AbstractScene {
  46849. /**
  46850. * The list of lens flare system added to the scene
  46851. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46852. */
  46853. lensFlareSystems: Array<LensFlareSystem>;
  46854. /**
  46855. * Removes the given lens flare system from this scene.
  46856. * @param toRemove The lens flare system to remove
  46857. * @returns The index of the removed lens flare system
  46858. */
  46859. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46860. /**
  46861. * Adds the given lens flare system to this scene
  46862. * @param newLensFlareSystem The lens flare system to add
  46863. */
  46864. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46865. /**
  46866. * Gets a lens flare system using its name
  46867. * @param name defines the name to look for
  46868. * @returns the lens flare system or null if not found
  46869. */
  46870. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46871. /**
  46872. * Gets a lens flare system using its id
  46873. * @param id defines the id to look for
  46874. * @returns the lens flare system or null if not found
  46875. */
  46876. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46877. }
  46878. }
  46879. /**
  46880. * Defines the lens flare scene component responsible to manage any lens flares
  46881. * in a given scene.
  46882. */
  46883. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46884. /**
  46885. * The component name helpfull to identify the component in the list of scene components.
  46886. */
  46887. readonly name: string;
  46888. /**
  46889. * The scene the component belongs to.
  46890. */
  46891. scene: Scene;
  46892. /**
  46893. * Creates a new instance of the component for the given scene
  46894. * @param scene Defines the scene to register the component in
  46895. */
  46896. constructor(scene: Scene);
  46897. /**
  46898. * Registers the component in a given scene
  46899. */
  46900. register(): void;
  46901. /**
  46902. * Rebuilds the elements related to this component in case of
  46903. * context lost for instance.
  46904. */
  46905. rebuild(): void;
  46906. /**
  46907. * Adds all the element from the container to the scene
  46908. * @param container the container holding the elements
  46909. */
  46910. addFromContainer(container: AbstractScene): void;
  46911. /**
  46912. * Removes all the elements in the container from the scene
  46913. * @param container contains the elements to remove
  46914. */
  46915. removeFromContainer(container: AbstractScene): void;
  46916. /**
  46917. * Serializes the component data to the specified json object
  46918. * @param serializationObject The object to serialize to
  46919. */
  46920. serialize(serializationObject: any): void;
  46921. /**
  46922. * Disposes the component and the associated ressources.
  46923. */
  46924. dispose(): void;
  46925. private _draw;
  46926. }
  46927. }
  46928. declare module "babylonjs/LensFlares/index" {
  46929. export * from "babylonjs/LensFlares/lensFlare";
  46930. export * from "babylonjs/LensFlares/lensFlareSystem";
  46931. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  46932. }
  46933. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  46934. import { Scene } from "babylonjs/scene";
  46935. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46936. import { AbstractScene } from "babylonjs/abstractScene";
  46937. /**
  46938. * Defines the shadow generator component responsible to manage any shadow generators
  46939. * in a given scene.
  46940. */
  46941. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46942. /**
  46943. * The component name helpfull to identify the component in the list of scene components.
  46944. */
  46945. readonly name: string;
  46946. /**
  46947. * The scene the component belongs to.
  46948. */
  46949. scene: Scene;
  46950. /**
  46951. * Creates a new instance of the component for the given scene
  46952. * @param scene Defines the scene to register the component in
  46953. */
  46954. constructor(scene: Scene);
  46955. /**
  46956. * Registers the component in a given scene
  46957. */
  46958. register(): void;
  46959. /**
  46960. * Rebuilds the elements related to this component in case of
  46961. * context lost for instance.
  46962. */
  46963. rebuild(): void;
  46964. /**
  46965. * Serializes the component data to the specified json object
  46966. * @param serializationObject The object to serialize to
  46967. */
  46968. serialize(serializationObject: any): void;
  46969. /**
  46970. * Adds all the element from the container to the scene
  46971. * @param container the container holding the elements
  46972. */
  46973. addFromContainer(container: AbstractScene): void;
  46974. /**
  46975. * Removes all the elements in the container from the scene
  46976. * @param container contains the elements to remove
  46977. */
  46978. removeFromContainer(container: AbstractScene): void;
  46979. /**
  46980. * Rebuilds the elements related to this component in case of
  46981. * context lost for instance.
  46982. */
  46983. dispose(): void;
  46984. private _gatherRenderTargets;
  46985. }
  46986. }
  46987. declare module "babylonjs/Lights/Shadows/index" {
  46988. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  46989. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  46990. }
  46991. declare module "babylonjs/Lights/directionalLight" {
  46992. import { Camera } from "babylonjs/Cameras/camera";
  46993. import { Scene } from "babylonjs/scene";
  46994. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46996. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46997. import { Effect } from "babylonjs/Materials/effect";
  46998. /**
  46999. * A directional light is defined by a direction (what a surprise!).
  47000. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47001. * 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.
  47002. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47003. */
  47004. export class DirectionalLight extends ShadowLight {
  47005. private _shadowFrustumSize;
  47006. /**
  47007. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47008. */
  47009. /**
  47010. * Specifies a fix frustum size for the shadow generation.
  47011. */
  47012. shadowFrustumSize: number;
  47013. private _shadowOrthoScale;
  47014. /**
  47015. * Gets the shadow projection scale against the optimal computed one.
  47016. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47017. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47018. */
  47019. /**
  47020. * Sets the shadow projection scale against the optimal computed one.
  47021. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47022. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47023. */
  47024. shadowOrthoScale: number;
  47025. /**
  47026. * Automatically compute the projection matrix to best fit (including all the casters)
  47027. * on each frame.
  47028. */
  47029. autoUpdateExtends: boolean;
  47030. private _orthoLeft;
  47031. private _orthoRight;
  47032. private _orthoTop;
  47033. private _orthoBottom;
  47034. /**
  47035. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47036. * The directional light is emitted from everywhere in the given direction.
  47037. * It can cast shadows.
  47038. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47039. * @param name The friendly name of the light
  47040. * @param direction The direction of the light
  47041. * @param scene The scene the light belongs to
  47042. */
  47043. constructor(name: string, direction: Vector3, scene: Scene);
  47044. /**
  47045. * Returns the string "DirectionalLight".
  47046. * @return The class name
  47047. */
  47048. getClassName(): string;
  47049. /**
  47050. * Returns the integer 1.
  47051. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47052. */
  47053. getTypeID(): number;
  47054. /**
  47055. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47056. * Returns the DirectionalLight Shadow projection matrix.
  47057. */
  47058. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47059. /**
  47060. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47061. * Returns the DirectionalLight Shadow projection matrix.
  47062. */
  47063. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47064. /**
  47065. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47066. * Returns the DirectionalLight Shadow projection matrix.
  47067. */
  47068. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47069. protected _buildUniformLayout(): void;
  47070. /**
  47071. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47072. * @param effect The effect to update
  47073. * @param lightIndex The index of the light in the effect to update
  47074. * @returns The directional light
  47075. */
  47076. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47077. /**
  47078. * Gets the minZ used for shadow according to both the scene and the light.
  47079. *
  47080. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47081. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47082. * @param activeCamera The camera we are returning the min for
  47083. * @returns the depth min z
  47084. */
  47085. getDepthMinZ(activeCamera: Camera): number;
  47086. /**
  47087. * Gets the maxZ used for shadow according to both the scene and the light.
  47088. *
  47089. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47090. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47091. * @param activeCamera The camera we are returning the max for
  47092. * @returns the depth max z
  47093. */
  47094. getDepthMaxZ(activeCamera: Camera): number;
  47095. /**
  47096. * Prepares the list of defines specific to the light type.
  47097. * @param defines the list of defines
  47098. * @param lightIndex defines the index of the light for the effect
  47099. */
  47100. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47101. }
  47102. }
  47103. declare module "babylonjs/Lights/pointLight" {
  47104. import { Scene } from "babylonjs/scene";
  47105. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47107. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47108. import { Effect } from "babylonjs/Materials/effect";
  47109. /**
  47110. * A point light is a light defined by an unique point in world space.
  47111. * The light is emitted in every direction from this point.
  47112. * A good example of a point light is a standard light bulb.
  47113. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47114. */
  47115. export class PointLight extends ShadowLight {
  47116. private _shadowAngle;
  47117. /**
  47118. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47119. * This specifies what angle the shadow will use to be created.
  47120. *
  47121. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47122. */
  47123. /**
  47124. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47125. * This specifies what angle the shadow will use to be created.
  47126. *
  47127. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47128. */
  47129. shadowAngle: number;
  47130. /**
  47131. * Gets the direction if it has been set.
  47132. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47133. */
  47134. /**
  47135. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47136. */
  47137. direction: Vector3;
  47138. /**
  47139. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47140. * A PointLight emits the light in every direction.
  47141. * It can cast shadows.
  47142. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47143. * ```javascript
  47144. * var pointLight = new PointLight("pl", camera.position, scene);
  47145. * ```
  47146. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47147. * @param name The light friendly name
  47148. * @param position The position of the point light in the scene
  47149. * @param scene The scene the lights belongs to
  47150. */
  47151. constructor(name: string, position: Vector3, scene: Scene);
  47152. /**
  47153. * Returns the string "PointLight"
  47154. * @returns the class name
  47155. */
  47156. getClassName(): string;
  47157. /**
  47158. * Returns the integer 0.
  47159. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47160. */
  47161. getTypeID(): number;
  47162. /**
  47163. * Specifies wether or not the shadowmap should be a cube texture.
  47164. * @returns true if the shadowmap needs to be a cube texture.
  47165. */
  47166. needCube(): boolean;
  47167. /**
  47168. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47169. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47170. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47171. */
  47172. getShadowDirection(faceIndex?: number): Vector3;
  47173. /**
  47174. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47175. * - fov = PI / 2
  47176. * - aspect ratio : 1.0
  47177. * - z-near and far equal to the active camera minZ and maxZ.
  47178. * Returns the PointLight.
  47179. */
  47180. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47181. protected _buildUniformLayout(): void;
  47182. /**
  47183. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47184. * @param effect The effect to update
  47185. * @param lightIndex The index of the light in the effect to update
  47186. * @returns The point light
  47187. */
  47188. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47189. /**
  47190. * Prepares the list of defines specific to the light type.
  47191. * @param defines the list of defines
  47192. * @param lightIndex defines the index of the light for the effect
  47193. */
  47194. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47195. }
  47196. }
  47197. declare module "babylonjs/Lights/spotLight" {
  47198. import { Nullable } from "babylonjs/types";
  47199. import { Scene } from "babylonjs/scene";
  47200. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47202. import { Effect } from "babylonjs/Materials/effect";
  47203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47204. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47205. /**
  47206. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47207. * These values define a cone of light starting from the position, emitting toward the direction.
  47208. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47209. * and the exponent defines the speed of the decay of the light with distance (reach).
  47210. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47211. */
  47212. export class SpotLight extends ShadowLight {
  47213. private _angle;
  47214. private _innerAngle;
  47215. private _cosHalfAngle;
  47216. private _lightAngleScale;
  47217. private _lightAngleOffset;
  47218. /**
  47219. * Gets the cone angle of the spot light in Radians.
  47220. */
  47221. /**
  47222. * Sets the cone angle of the spot light in Radians.
  47223. */
  47224. angle: number;
  47225. /**
  47226. * Only used in gltf falloff mode, this defines the angle where
  47227. * the directional falloff will start before cutting at angle which could be seen
  47228. * as outer angle.
  47229. */
  47230. /**
  47231. * Only used in gltf falloff mode, this defines the angle where
  47232. * the directional falloff will start before cutting at angle which could be seen
  47233. * as outer angle.
  47234. */
  47235. innerAngle: number;
  47236. private _shadowAngleScale;
  47237. /**
  47238. * Allows scaling the angle of the light for shadow generation only.
  47239. */
  47240. /**
  47241. * Allows scaling the angle of the light for shadow generation only.
  47242. */
  47243. shadowAngleScale: number;
  47244. /**
  47245. * The light decay speed with the distance from the emission spot.
  47246. */
  47247. exponent: number;
  47248. private _projectionTextureMatrix;
  47249. /**
  47250. * Allows reading the projecton texture
  47251. */
  47252. readonly projectionTextureMatrix: Matrix;
  47253. protected _projectionTextureLightNear: number;
  47254. /**
  47255. * Gets the near clip of the Spotlight for texture projection.
  47256. */
  47257. /**
  47258. * Sets the near clip of the Spotlight for texture projection.
  47259. */
  47260. projectionTextureLightNear: number;
  47261. protected _projectionTextureLightFar: number;
  47262. /**
  47263. * Gets the far clip of the Spotlight for texture projection.
  47264. */
  47265. /**
  47266. * Sets the far clip of the Spotlight for texture projection.
  47267. */
  47268. projectionTextureLightFar: number;
  47269. protected _projectionTextureUpDirection: Vector3;
  47270. /**
  47271. * Gets the Up vector of the Spotlight for texture projection.
  47272. */
  47273. /**
  47274. * Sets the Up vector of the Spotlight for texture projection.
  47275. */
  47276. projectionTextureUpDirection: Vector3;
  47277. private _projectionTexture;
  47278. /**
  47279. * Gets the projection texture of the light.
  47280. */
  47281. /**
  47282. * Sets the projection texture of the light.
  47283. */
  47284. projectionTexture: Nullable<BaseTexture>;
  47285. private _projectionTextureViewLightDirty;
  47286. private _projectionTextureProjectionLightDirty;
  47287. private _projectionTextureDirty;
  47288. private _projectionTextureViewTargetVector;
  47289. private _projectionTextureViewLightMatrix;
  47290. private _projectionTextureProjectionLightMatrix;
  47291. private _projectionTextureScalingMatrix;
  47292. /**
  47293. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47294. * It can cast shadows.
  47295. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47296. * @param name The light friendly name
  47297. * @param position The position of the spot light in the scene
  47298. * @param direction The direction of the light in the scene
  47299. * @param angle The cone angle of the light in Radians
  47300. * @param exponent The light decay speed with the distance from the emission spot
  47301. * @param scene The scene the lights belongs to
  47302. */
  47303. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47304. /**
  47305. * Returns the string "SpotLight".
  47306. * @returns the class name
  47307. */
  47308. getClassName(): string;
  47309. /**
  47310. * Returns the integer 2.
  47311. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47312. */
  47313. getTypeID(): number;
  47314. /**
  47315. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47316. */
  47317. protected _setDirection(value: Vector3): void;
  47318. /**
  47319. * Overrides the position setter to recompute the projection texture view light Matrix.
  47320. */
  47321. protected _setPosition(value: Vector3): void;
  47322. /**
  47323. * 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.
  47324. * Returns the SpotLight.
  47325. */
  47326. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47327. protected _computeProjectionTextureViewLightMatrix(): void;
  47328. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47329. /**
  47330. * Main function for light texture projection matrix computing.
  47331. */
  47332. protected _computeProjectionTextureMatrix(): void;
  47333. protected _buildUniformLayout(): void;
  47334. private _computeAngleValues;
  47335. /**
  47336. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47337. * @param effect The effect to update
  47338. * @param lightIndex The index of the light in the effect to update
  47339. * @returns The spot light
  47340. */
  47341. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47342. /**
  47343. * Disposes the light and the associated resources.
  47344. */
  47345. dispose(): void;
  47346. /**
  47347. * Prepares the list of defines specific to the light type.
  47348. * @param defines the list of defines
  47349. * @param lightIndex defines the index of the light for the effect
  47350. */
  47351. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47352. }
  47353. }
  47354. declare module "babylonjs/Lights/index" {
  47355. export * from "babylonjs/Lights/light";
  47356. export * from "babylonjs/Lights/shadowLight";
  47357. export * from "babylonjs/Lights/Shadows/index";
  47358. export * from "babylonjs/Lights/directionalLight";
  47359. export * from "babylonjs/Lights/hemisphericLight";
  47360. export * from "babylonjs/Lights/pointLight";
  47361. export * from "babylonjs/Lights/spotLight";
  47362. }
  47363. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  47364. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47365. /**
  47366. * Header information of HDR texture files.
  47367. */
  47368. export interface HDRInfo {
  47369. /**
  47370. * The height of the texture in pixels.
  47371. */
  47372. height: number;
  47373. /**
  47374. * The width of the texture in pixels.
  47375. */
  47376. width: number;
  47377. /**
  47378. * The index of the beginning of the data in the binary file.
  47379. */
  47380. dataPosition: number;
  47381. }
  47382. /**
  47383. * This groups tools to convert HDR texture to native colors array.
  47384. */
  47385. export class HDRTools {
  47386. private static Ldexp;
  47387. private static Rgbe2float;
  47388. private static readStringLine;
  47389. /**
  47390. * Reads header information from an RGBE texture stored in a native array.
  47391. * More information on this format are available here:
  47392. * https://en.wikipedia.org/wiki/RGBE_image_format
  47393. *
  47394. * @param uint8array The binary file stored in native array.
  47395. * @return The header information.
  47396. */
  47397. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47398. /**
  47399. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47400. * This RGBE texture needs to store the information as a panorama.
  47401. *
  47402. * More information on this format are available here:
  47403. * https://en.wikipedia.org/wiki/RGBE_image_format
  47404. *
  47405. * @param buffer The binary file stored in an array buffer.
  47406. * @param size The expected size of the extracted cubemap.
  47407. * @return The Cube Map information.
  47408. */
  47409. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47410. /**
  47411. * Returns the pixels data extracted from an RGBE texture.
  47412. * This pixels will be stored left to right up to down in the R G B order in one array.
  47413. *
  47414. * More information on this format are available here:
  47415. * https://en.wikipedia.org/wiki/RGBE_image_format
  47416. *
  47417. * @param uint8array The binary file stored in an array buffer.
  47418. * @param hdrInfo The header information of the file.
  47419. * @return The pixels data in RGB right to left up to down order.
  47420. */
  47421. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47422. private static RGBE_ReadPixels_RLE;
  47423. }
  47424. }
  47425. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  47426. import { Nullable } from "babylonjs/types";
  47427. import { Scene } from "babylonjs/scene";
  47428. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47430. /**
  47431. * This represents a texture coming from an HDR input.
  47432. *
  47433. * The only supported format is currently panorama picture stored in RGBE format.
  47434. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47435. */
  47436. export class HDRCubeTexture extends BaseTexture {
  47437. private static _facesMapping;
  47438. private _generateHarmonics;
  47439. private _noMipmap;
  47440. private _textureMatrix;
  47441. private _size;
  47442. private _onLoad;
  47443. private _onError;
  47444. /**
  47445. * The texture URL.
  47446. */
  47447. url: string;
  47448. /**
  47449. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47450. */
  47451. coordinatesMode: number;
  47452. protected _isBlocking: boolean;
  47453. /**
  47454. * Sets wether or not the texture is blocking during loading.
  47455. */
  47456. /**
  47457. * Gets wether or not the texture is blocking during loading.
  47458. */
  47459. isBlocking: boolean;
  47460. protected _rotationY: number;
  47461. /**
  47462. * Sets texture matrix rotation angle around Y axis in radians.
  47463. */
  47464. /**
  47465. * Gets texture matrix rotation angle around Y axis radians.
  47466. */
  47467. rotationY: number;
  47468. /**
  47469. * Gets or sets the center of the bounding box associated with the cube texture
  47470. * It must define where the camera used to render the texture was set
  47471. */
  47472. boundingBoxPosition: Vector3;
  47473. private _boundingBoxSize;
  47474. /**
  47475. * Gets or sets the size of the bounding box associated with the cube texture
  47476. * When defined, the cubemap will switch to local mode
  47477. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47478. * @example https://www.babylonjs-playground.com/#RNASML
  47479. */
  47480. boundingBoxSize: Vector3;
  47481. /**
  47482. * Instantiates an HDRTexture from the following parameters.
  47483. *
  47484. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47485. * @param scene The scene the texture will be used in
  47486. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47487. * @param noMipmap Forces to not generate the mipmap if true
  47488. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47489. * @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)
  47490. * @param reserved Reserved flag for internal use.
  47491. */
  47492. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  47493. /**
  47494. * Get the current class name of the texture useful for serialization or dynamic coding.
  47495. * @returns "HDRCubeTexture"
  47496. */
  47497. getClassName(): string;
  47498. /**
  47499. * Occurs when the file is raw .hdr file.
  47500. */
  47501. private loadTexture;
  47502. clone(): HDRCubeTexture;
  47503. delayLoad(): void;
  47504. /**
  47505. * Get the texture reflection matrix used to rotate/transform the reflection.
  47506. * @returns the reflection matrix
  47507. */
  47508. getReflectionTextureMatrix(): Matrix;
  47509. /**
  47510. * Set the texture reflection matrix used to rotate/transform the reflection.
  47511. * @param value Define the reflection matrix to set
  47512. */
  47513. setReflectionTextureMatrix(value: Matrix): void;
  47514. /**
  47515. * Parses a JSON representation of an HDR Texture in order to create the texture
  47516. * @param parsedTexture Define the JSON representation
  47517. * @param scene Define the scene the texture should be created in
  47518. * @param rootUrl Define the root url in case we need to load relative dependencies
  47519. * @returns the newly created texture after parsing
  47520. */
  47521. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47522. serialize(): any;
  47523. }
  47524. }
  47525. declare module "babylonjs/Physics/physicsEngine" {
  47526. import { Nullable } from "babylonjs/types";
  47527. import { Vector3 } from "babylonjs/Maths/math";
  47528. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47529. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47530. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47531. /**
  47532. * Class used to control physics engine
  47533. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47534. */
  47535. export class PhysicsEngine implements IPhysicsEngine {
  47536. private _physicsPlugin;
  47537. /**
  47538. * Global value used to control the smallest number supported by the simulation
  47539. */
  47540. static Epsilon: number;
  47541. private _impostors;
  47542. private _joints;
  47543. /**
  47544. * Gets the gravity vector used by the simulation
  47545. */
  47546. gravity: Vector3;
  47547. /**
  47548. * Factory used to create the default physics plugin.
  47549. * @returns The default physics plugin
  47550. */
  47551. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47552. /**
  47553. * Creates a new Physics Engine
  47554. * @param gravity defines the gravity vector used by the simulation
  47555. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47556. */
  47557. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47558. /**
  47559. * Sets the gravity vector used by the simulation
  47560. * @param gravity defines the gravity vector to use
  47561. */
  47562. setGravity(gravity: Vector3): void;
  47563. /**
  47564. * Set the time step of the physics engine.
  47565. * Default is 1/60.
  47566. * To slow it down, enter 1/600 for example.
  47567. * To speed it up, 1/30
  47568. * @param newTimeStep defines the new timestep to apply to this world.
  47569. */
  47570. setTimeStep(newTimeStep?: number): void;
  47571. /**
  47572. * Get the time step of the physics engine.
  47573. * @returns the current time step
  47574. */
  47575. getTimeStep(): number;
  47576. /**
  47577. * Release all resources
  47578. */
  47579. dispose(): void;
  47580. /**
  47581. * Gets the name of the current physics plugin
  47582. * @returns the name of the plugin
  47583. */
  47584. getPhysicsPluginName(): string;
  47585. /**
  47586. * Adding a new impostor for the impostor tracking.
  47587. * This will be done by the impostor itself.
  47588. * @param impostor the impostor to add
  47589. */
  47590. addImpostor(impostor: PhysicsImpostor): void;
  47591. /**
  47592. * Remove an impostor from the engine.
  47593. * This impostor and its mesh will not longer be updated by the physics engine.
  47594. * @param impostor the impostor to remove
  47595. */
  47596. removeImpostor(impostor: PhysicsImpostor): void;
  47597. /**
  47598. * Add a joint to the physics engine
  47599. * @param mainImpostor defines the main impostor to which the joint is added.
  47600. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47601. * @param joint defines the joint that will connect both impostors.
  47602. */
  47603. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47604. /**
  47605. * Removes a joint from the simulation
  47606. * @param mainImpostor defines the impostor used with the joint
  47607. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47608. * @param joint defines the joint to remove
  47609. */
  47610. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47611. /**
  47612. * Called by the scene. No need to call it.
  47613. * @param delta defines the timespam between frames
  47614. */
  47615. _step(delta: number): void;
  47616. /**
  47617. * Gets the current plugin used to run the simulation
  47618. * @returns current plugin
  47619. */
  47620. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47621. /**
  47622. * Gets the list of physic impostors
  47623. * @returns an array of PhysicsImpostor
  47624. */
  47625. getImpostors(): Array<PhysicsImpostor>;
  47626. /**
  47627. * Gets the impostor for a physics enabled object
  47628. * @param object defines the object impersonated by the impostor
  47629. * @returns the PhysicsImpostor or null if not found
  47630. */
  47631. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47632. /**
  47633. * Gets the impostor for a physics body object
  47634. * @param body defines physics body used by the impostor
  47635. * @returns the PhysicsImpostor or null if not found
  47636. */
  47637. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47638. }
  47639. }
  47640. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47641. import { Nullable } from "babylonjs/types";
  47642. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47644. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47645. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47646. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47647. /** @hidden */
  47648. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47649. private _useDeltaForWorldStep;
  47650. world: any;
  47651. name: string;
  47652. private _physicsMaterials;
  47653. private _fixedTimeStep;
  47654. BJSCANNON: any;
  47655. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47656. setGravity(gravity: Vector3): void;
  47657. setTimeStep(timeStep: number): void;
  47658. getTimeStep(): number;
  47659. executeStep(delta: number): void;
  47660. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47661. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47662. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47663. private _processChildMeshes;
  47664. removePhysicsBody(impostor: PhysicsImpostor): void;
  47665. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47666. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47667. private _addMaterial;
  47668. private _checkWithEpsilon;
  47669. private _createShape;
  47670. private _createHeightmap;
  47671. private _minus90X;
  47672. private _plus90X;
  47673. private _tmpPosition;
  47674. private _tmpDeltaPosition;
  47675. private _tmpUnityRotation;
  47676. private _updatePhysicsBodyTransformation;
  47677. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47678. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47679. isSupported(): boolean;
  47680. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47681. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47682. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47683. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47684. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47685. getBodyMass(impostor: PhysicsImpostor): number;
  47686. getBodyFriction(impostor: PhysicsImpostor): number;
  47687. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47688. getBodyRestitution(impostor: PhysicsImpostor): number;
  47689. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47690. sleepBody(impostor: PhysicsImpostor): void;
  47691. wakeUpBody(impostor: PhysicsImpostor): void;
  47692. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47693. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47694. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47695. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47696. getRadius(impostor: PhysicsImpostor): number;
  47697. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47698. dispose(): void;
  47699. private _extendNamespace;
  47700. }
  47701. }
  47702. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47703. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47704. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47705. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47707. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47708. import { Nullable } from "babylonjs/types";
  47709. /** @hidden */
  47710. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47711. world: any;
  47712. name: string;
  47713. BJSOIMO: any;
  47714. constructor(iterations?: number, oimoInjection?: any);
  47715. setGravity(gravity: Vector3): void;
  47716. setTimeStep(timeStep: number): void;
  47717. getTimeStep(): number;
  47718. private _tmpImpostorsArray;
  47719. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47720. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47721. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47722. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47723. private _tmpPositionVector;
  47724. removePhysicsBody(impostor: PhysicsImpostor): void;
  47725. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47726. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47727. isSupported(): boolean;
  47728. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47729. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47730. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47731. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47732. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47733. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47734. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47735. getBodyMass(impostor: PhysicsImpostor): number;
  47736. getBodyFriction(impostor: PhysicsImpostor): number;
  47737. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47738. getBodyRestitution(impostor: PhysicsImpostor): number;
  47739. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47740. sleepBody(impostor: PhysicsImpostor): void;
  47741. wakeUpBody(impostor: PhysicsImpostor): void;
  47742. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47743. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47744. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47745. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47746. getRadius(impostor: PhysicsImpostor): number;
  47747. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47748. dispose(): void;
  47749. }
  47750. }
  47751. declare module "babylonjs/Probes/reflectionProbe" {
  47752. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47753. import { Vector3 } from "babylonjs/Maths/math";
  47754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47755. import { Nullable } from "babylonjs/types";
  47756. import { Scene } from "babylonjs/scene";
  47757. module "babylonjs/abstractScene" {
  47758. interface AbstractScene {
  47759. /**
  47760. * The list of reflection probes added to the scene
  47761. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47762. */
  47763. reflectionProbes: Array<ReflectionProbe>;
  47764. /**
  47765. * Removes the given reflection probe from this scene.
  47766. * @param toRemove The reflection probe to remove
  47767. * @returns The index of the removed reflection probe
  47768. */
  47769. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47770. /**
  47771. * Adds the given reflection probe to this scene.
  47772. * @param newReflectionProbe The reflection probe to add
  47773. */
  47774. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47775. }
  47776. }
  47777. /**
  47778. * Class used to generate realtime reflection / refraction cube textures
  47779. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47780. */
  47781. export class ReflectionProbe {
  47782. /** defines the name of the probe */
  47783. name: string;
  47784. private _scene;
  47785. private _renderTargetTexture;
  47786. private _projectionMatrix;
  47787. private _viewMatrix;
  47788. private _target;
  47789. private _add;
  47790. private _attachedMesh;
  47791. private _invertYAxis;
  47792. /** Gets or sets probe position (center of the cube map) */
  47793. position: Vector3;
  47794. /**
  47795. * Creates a new reflection probe
  47796. * @param name defines the name of the probe
  47797. * @param size defines the texture resolution (for each face)
  47798. * @param scene defines the hosting scene
  47799. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47800. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47801. */
  47802. constructor(
  47803. /** defines the name of the probe */
  47804. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47805. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47806. samples: number;
  47807. /** Gets or sets the refresh rate to use (on every frame by default) */
  47808. refreshRate: number;
  47809. /**
  47810. * Gets the hosting scene
  47811. * @returns a Scene
  47812. */
  47813. getScene(): Scene;
  47814. /** Gets the internal CubeTexture used to render to */
  47815. readonly cubeTexture: RenderTargetTexture;
  47816. /** Gets the list of meshes to render */
  47817. readonly renderList: Nullable<AbstractMesh[]>;
  47818. /**
  47819. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47820. * @param mesh defines the mesh to attach to
  47821. */
  47822. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47823. /**
  47824. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47825. * @param renderingGroupId The rendering group id corresponding to its index
  47826. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47827. */
  47828. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47829. /**
  47830. * Clean all associated resources
  47831. */
  47832. dispose(): void;
  47833. /**
  47834. * Converts the reflection probe information to a readable string for debug purpose.
  47835. * @param fullDetails Supports for multiple levels of logging within scene loading
  47836. * @returns the human readable reflection probe info
  47837. */
  47838. toString(fullDetails?: boolean): string;
  47839. /**
  47840. * Get the class name of the relfection probe.
  47841. * @returns "ReflectionProbe"
  47842. */
  47843. getClassName(): string;
  47844. /**
  47845. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47846. * @returns The JSON representation of the texture
  47847. */
  47848. serialize(): any;
  47849. /**
  47850. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47851. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47852. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47853. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47854. * @returns The parsed reflection probe if successful
  47855. */
  47856. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47857. }
  47858. }
  47859. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  47860. /** @hidden */
  47861. export var _BabylonLoaderRegistered: boolean;
  47862. }
  47863. declare module "babylonjs/Loading/Plugins/index" {
  47864. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  47865. }
  47866. declare module "babylonjs/Loading/index" {
  47867. export * from "babylonjs/Loading/loadingScreen";
  47868. export * from "babylonjs/Loading/Plugins/index";
  47869. export * from "babylonjs/Loading/sceneLoader";
  47870. export * from "babylonjs/Loading/sceneLoaderFlags";
  47871. }
  47872. declare module "babylonjs/Materials/Background/index" {
  47873. export * from "babylonjs/Materials/Background/backgroundMaterial";
  47874. }
  47875. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  47876. import { Scene } from "babylonjs/scene";
  47877. import { Color3 } from "babylonjs/Maths/math";
  47878. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47880. /**
  47881. * The Physically based simple base material of BJS.
  47882. *
  47883. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47884. * It is used as the base class for both the specGloss and metalRough conventions.
  47885. */
  47886. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47887. /**
  47888. * Number of Simultaneous lights allowed on the material.
  47889. */
  47890. maxSimultaneousLights: number;
  47891. /**
  47892. * If sets to true, disables all the lights affecting the material.
  47893. */
  47894. disableLighting: boolean;
  47895. /**
  47896. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47897. */
  47898. environmentTexture: BaseTexture;
  47899. /**
  47900. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47901. */
  47902. invertNormalMapX: boolean;
  47903. /**
  47904. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47905. */
  47906. invertNormalMapY: boolean;
  47907. /**
  47908. * Normal map used in the model.
  47909. */
  47910. normalTexture: BaseTexture;
  47911. /**
  47912. * Emissivie color used to self-illuminate the model.
  47913. */
  47914. emissiveColor: Color3;
  47915. /**
  47916. * Emissivie texture used to self-illuminate the model.
  47917. */
  47918. emissiveTexture: BaseTexture;
  47919. /**
  47920. * Occlusion Channel Strenght.
  47921. */
  47922. occlusionStrength: number;
  47923. /**
  47924. * Occlusion Texture of the material (adding extra occlusion effects).
  47925. */
  47926. occlusionTexture: BaseTexture;
  47927. /**
  47928. * Defines the alpha limits in alpha test mode.
  47929. */
  47930. alphaCutOff: number;
  47931. /**
  47932. * Gets the current double sided mode.
  47933. */
  47934. /**
  47935. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47936. */
  47937. doubleSided: boolean;
  47938. /**
  47939. * Stores the pre-calculated light information of a mesh in a texture.
  47940. */
  47941. lightmapTexture: BaseTexture;
  47942. /**
  47943. * If true, the light map contains occlusion information instead of lighting info.
  47944. */
  47945. useLightmapAsShadowmap: boolean;
  47946. /**
  47947. * Return the active textures of the material.
  47948. */
  47949. getActiveTextures(): BaseTexture[];
  47950. hasTexture(texture: BaseTexture): boolean;
  47951. /**
  47952. * Instantiates a new PBRMaterial instance.
  47953. *
  47954. * @param name The material name
  47955. * @param scene The scene the material will be use in.
  47956. */
  47957. constructor(name: string, scene: Scene);
  47958. getClassName(): string;
  47959. }
  47960. }
  47961. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  47962. import { Scene } from "babylonjs/scene";
  47963. import { Color3 } from "babylonjs/Maths/math";
  47964. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47965. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47966. /**
  47967. * The PBR material of BJS following the metal roughness convention.
  47968. *
  47969. * This fits to the PBR convention in the GLTF definition:
  47970. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47971. */
  47972. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47973. /**
  47974. * The base color has two different interpretations depending on the value of metalness.
  47975. * When the material is a metal, the base color is the specific measured reflectance value
  47976. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47977. * of the material.
  47978. */
  47979. baseColor: Color3;
  47980. /**
  47981. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47982. * well as opacity information in the alpha channel.
  47983. */
  47984. baseTexture: BaseTexture;
  47985. /**
  47986. * Specifies the metallic scalar value of the material.
  47987. * Can also be used to scale the metalness values of the metallic texture.
  47988. */
  47989. metallic: number;
  47990. /**
  47991. * Specifies the roughness scalar value of the material.
  47992. * Can also be used to scale the roughness values of the metallic texture.
  47993. */
  47994. roughness: number;
  47995. /**
  47996. * Texture containing both the metallic value in the B channel and the
  47997. * roughness value in the G channel to keep better precision.
  47998. */
  47999. metallicRoughnessTexture: BaseTexture;
  48000. /**
  48001. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48002. *
  48003. * @param name The material name
  48004. * @param scene The scene the material will be use in.
  48005. */
  48006. constructor(name: string, scene: Scene);
  48007. /**
  48008. * Return the currrent class name of the material.
  48009. */
  48010. getClassName(): string;
  48011. /**
  48012. * Return the active textures of the material.
  48013. */
  48014. getActiveTextures(): BaseTexture[];
  48015. /**
  48016. * Checks to see if a texture is used in the material.
  48017. * @param texture - Base texture to use.
  48018. * @returns - Boolean specifying if a texture is used in the material.
  48019. */
  48020. hasTexture(texture: BaseTexture): boolean;
  48021. /**
  48022. * Makes a duplicate of the current material.
  48023. * @param name - name to use for the new material.
  48024. */
  48025. clone(name: string): PBRMetallicRoughnessMaterial;
  48026. /**
  48027. * Serialize the material to a parsable JSON object.
  48028. */
  48029. serialize(): any;
  48030. /**
  48031. * Parses a JSON object correponding to the serialize function.
  48032. */
  48033. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48034. }
  48035. }
  48036. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  48037. import { Scene } from "babylonjs/scene";
  48038. import { Color3 } from "babylonjs/Maths/math";
  48039. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48040. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48041. /**
  48042. * The PBR material of BJS following the specular glossiness convention.
  48043. *
  48044. * This fits to the PBR convention in the GLTF definition:
  48045. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48046. */
  48047. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48048. /**
  48049. * Specifies the diffuse color of the material.
  48050. */
  48051. diffuseColor: Color3;
  48052. /**
  48053. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48054. * channel.
  48055. */
  48056. diffuseTexture: BaseTexture;
  48057. /**
  48058. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48059. */
  48060. specularColor: Color3;
  48061. /**
  48062. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48063. */
  48064. glossiness: number;
  48065. /**
  48066. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48067. */
  48068. specularGlossinessTexture: BaseTexture;
  48069. /**
  48070. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48071. *
  48072. * @param name The material name
  48073. * @param scene The scene the material will be use in.
  48074. */
  48075. constructor(name: string, scene: Scene);
  48076. /**
  48077. * Return the currrent class name of the material.
  48078. */
  48079. getClassName(): string;
  48080. /**
  48081. * Return the active textures of the material.
  48082. */
  48083. getActiveTextures(): BaseTexture[];
  48084. /**
  48085. * Checks to see if a texture is used in the material.
  48086. * @param texture - Base texture to use.
  48087. * @returns - Boolean specifying if a texture is used in the material.
  48088. */
  48089. hasTexture(texture: BaseTexture): boolean;
  48090. /**
  48091. * Makes a duplicate of the current material.
  48092. * @param name - name to use for the new material.
  48093. */
  48094. clone(name: string): PBRSpecularGlossinessMaterial;
  48095. /**
  48096. * Serialize the material to a parsable JSON object.
  48097. */
  48098. serialize(): any;
  48099. /**
  48100. * Parses a JSON object correponding to the serialize function.
  48101. */
  48102. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48103. }
  48104. }
  48105. declare module "babylonjs/Materials/PBR/index" {
  48106. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48107. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48108. export * from "babylonjs/Materials/PBR/pbrMaterial";
  48109. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  48110. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  48111. }
  48112. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  48113. import { Nullable } from "babylonjs/types";
  48114. import { Scene } from "babylonjs/scene";
  48115. import { Matrix } from "babylonjs/Maths/math";
  48116. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48117. /**
  48118. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48119. * It can help converting any input color in a desired output one. This can then be used to create effects
  48120. * from sepia, black and white to sixties or futuristic rendering...
  48121. *
  48122. * The only supported format is currently 3dl.
  48123. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48124. */
  48125. export class ColorGradingTexture extends BaseTexture {
  48126. /**
  48127. * The current texture matrix. (will always be identity in color grading texture)
  48128. */
  48129. private _textureMatrix;
  48130. /**
  48131. * The texture URL.
  48132. */
  48133. url: string;
  48134. /**
  48135. * Empty line regex stored for GC.
  48136. */
  48137. private static _noneEmptyLineRegex;
  48138. private _engine;
  48139. /**
  48140. * Instantiates a ColorGradingTexture from the following parameters.
  48141. *
  48142. * @param url The location of the color gradind data (currently only supporting 3dl)
  48143. * @param scene The scene the texture will be used in
  48144. */
  48145. constructor(url: string, scene: Scene);
  48146. /**
  48147. * Returns the texture matrix used in most of the material.
  48148. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48149. */
  48150. getTextureMatrix(): Matrix;
  48151. /**
  48152. * Occurs when the file being loaded is a .3dl LUT file.
  48153. */
  48154. private load3dlTexture;
  48155. /**
  48156. * Starts the loading process of the texture.
  48157. */
  48158. private loadTexture;
  48159. /**
  48160. * Clones the color gradind texture.
  48161. */
  48162. clone(): ColorGradingTexture;
  48163. /**
  48164. * Called during delayed load for textures.
  48165. */
  48166. delayLoad(): void;
  48167. /**
  48168. * Parses a color grading texture serialized by Babylon.
  48169. * @param parsedTexture The texture information being parsedTexture
  48170. * @param scene The scene to load the texture in
  48171. * @param rootUrl The root url of the data assets to load
  48172. * @return A color gradind texture
  48173. */
  48174. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48175. /**
  48176. * Serializes the LUT texture to json format.
  48177. */
  48178. serialize(): any;
  48179. }
  48180. }
  48181. declare module "babylonjs/Misc/dds" {
  48182. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48183. import { Engine } from "babylonjs/Engines/engine";
  48184. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48185. import { Nullable } from "babylonjs/types";
  48186. import { Scene } from "babylonjs/scene";
  48187. /**
  48188. * Direct draw surface info
  48189. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48190. */
  48191. export interface DDSInfo {
  48192. /**
  48193. * Width of the texture
  48194. */
  48195. width: number;
  48196. /**
  48197. * Width of the texture
  48198. */
  48199. height: number;
  48200. /**
  48201. * Number of Mipmaps for the texture
  48202. * @see https://en.wikipedia.org/wiki/Mipmap
  48203. */
  48204. mipmapCount: number;
  48205. /**
  48206. * If the textures format is a known fourCC format
  48207. * @see https://www.fourcc.org/
  48208. */
  48209. isFourCC: boolean;
  48210. /**
  48211. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48212. */
  48213. isRGB: boolean;
  48214. /**
  48215. * If the texture is a lumincance format
  48216. */
  48217. isLuminance: boolean;
  48218. /**
  48219. * If this is a cube texture
  48220. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48221. */
  48222. isCube: boolean;
  48223. /**
  48224. * If the texture is a compressed format eg. FOURCC_DXT1
  48225. */
  48226. isCompressed: boolean;
  48227. /**
  48228. * The dxgiFormat of the texture
  48229. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48230. */
  48231. dxgiFormat: number;
  48232. /**
  48233. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48234. */
  48235. textureType: number;
  48236. /**
  48237. * Sphericle polynomial created for the dds texture
  48238. */
  48239. sphericalPolynomial?: SphericalPolynomial;
  48240. }
  48241. /**
  48242. * Class used to provide DDS decompression tools
  48243. */
  48244. export class DDSTools {
  48245. /**
  48246. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48247. */
  48248. static StoreLODInAlphaChannel: boolean;
  48249. /**
  48250. * Gets DDS information from an array buffer
  48251. * @param arrayBuffer defines the array buffer to read data from
  48252. * @returns the DDS information
  48253. */
  48254. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48255. private static _FloatView;
  48256. private static _Int32View;
  48257. private static _ToHalfFloat;
  48258. private static _FromHalfFloat;
  48259. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48260. private static _GetHalfFloatRGBAArrayBuffer;
  48261. private static _GetFloatRGBAArrayBuffer;
  48262. private static _GetFloatAsUIntRGBAArrayBuffer;
  48263. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48264. private static _GetRGBAArrayBuffer;
  48265. private static _ExtractLongWordOrder;
  48266. private static _GetRGBArrayBuffer;
  48267. private static _GetLuminanceArrayBuffer;
  48268. /**
  48269. * Uploads DDS Levels to a Babylon Texture
  48270. * @hidden
  48271. */
  48272. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48273. }
  48274. module "babylonjs/Engines/engine" {
  48275. interface Engine {
  48276. /**
  48277. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48278. * @param rootUrl defines the url where the file to load is located
  48279. * @param scene defines the current scene
  48280. * @param lodScale defines scale to apply to the mip map selection
  48281. * @param lodOffset defines offset to apply to the mip map selection
  48282. * @param onLoad defines an optional callback raised when the texture is loaded
  48283. * @param onError defines an optional callback raised if there is an issue to load the texture
  48284. * @param format defines the format of the data
  48285. * @param forcedExtension defines the extension to use to pick the right loader
  48286. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48287. * @returns the cube texture as an InternalTexture
  48288. */
  48289. 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;
  48290. }
  48291. }
  48292. }
  48293. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48294. import { Nullable } from "babylonjs/types";
  48295. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48296. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48297. /**
  48298. * Implementation of the DDS Texture Loader.
  48299. * @hidden
  48300. */
  48301. export class _DDSTextureLoader implements IInternalTextureLoader {
  48302. /**
  48303. * Defines wether the loader supports cascade loading the different faces.
  48304. */
  48305. readonly supportCascades: boolean;
  48306. /**
  48307. * This returns if the loader support the current file information.
  48308. * @param extension defines the file extension of the file being loaded
  48309. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48310. * @param fallback defines the fallback internal texture if any
  48311. * @param isBase64 defines whether the texture is encoded as a base64
  48312. * @param isBuffer defines whether the texture data are stored as a buffer
  48313. * @returns true if the loader can load the specified file
  48314. */
  48315. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48316. /**
  48317. * Transform the url before loading if required.
  48318. * @param rootUrl the url of the texture
  48319. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48320. * @returns the transformed texture
  48321. */
  48322. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48323. /**
  48324. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48325. * @param rootUrl the url of the texture
  48326. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48327. * @returns the fallback texture
  48328. */
  48329. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48330. /**
  48331. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48332. * @param data contains the texture data
  48333. * @param texture defines the BabylonJS internal texture
  48334. * @param createPolynomials will be true if polynomials have been requested
  48335. * @param onLoad defines the callback to trigger once the texture is ready
  48336. * @param onError defines the callback to trigger in case of error
  48337. */
  48338. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48339. /**
  48340. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48341. * @param data contains the texture data
  48342. * @param texture defines the BabylonJS internal texture
  48343. * @param callback defines the method to call once ready to upload
  48344. */
  48345. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48346. }
  48347. }
  48348. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48349. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48350. /** @hidden */
  48351. export var rgbdEncodePixelShader: {
  48352. name: string;
  48353. shader: string;
  48354. };
  48355. }
  48356. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48357. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48358. /** @hidden */
  48359. export var rgbdDecodePixelShader: {
  48360. name: string;
  48361. shader: string;
  48362. };
  48363. }
  48364. declare module "babylonjs/Misc/environmentTextureTools" {
  48365. import { Nullable } from "babylonjs/types";
  48366. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48367. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48368. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48369. import "babylonjs/Shaders/rgbdEncode.fragment";
  48370. import "babylonjs/Shaders/rgbdDecode.fragment";
  48371. /**
  48372. * Raw texture data and descriptor sufficient for WebGL texture upload
  48373. */
  48374. export interface EnvironmentTextureInfo {
  48375. /**
  48376. * Version of the environment map
  48377. */
  48378. version: number;
  48379. /**
  48380. * Width of image
  48381. */
  48382. width: number;
  48383. /**
  48384. * Irradiance information stored in the file.
  48385. */
  48386. irradiance: any;
  48387. /**
  48388. * Specular information stored in the file.
  48389. */
  48390. specular: any;
  48391. }
  48392. /**
  48393. * Sets of helpers addressing the serialization and deserialization of environment texture
  48394. * stored in a BabylonJS env file.
  48395. * Those files are usually stored as .env files.
  48396. */
  48397. export class EnvironmentTextureTools {
  48398. /**
  48399. * Magic number identifying the env file.
  48400. */
  48401. private static _MagicBytes;
  48402. /**
  48403. * Gets the environment info from an env file.
  48404. * @param data The array buffer containing the .env bytes.
  48405. * @returns the environment file info (the json header) if successfully parsed.
  48406. */
  48407. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48408. /**
  48409. * Creates an environment texture from a loaded cube texture.
  48410. * @param texture defines the cube texture to convert in env file
  48411. * @return a promise containing the environment data if succesfull.
  48412. */
  48413. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48414. /**
  48415. * Creates a JSON representation of the spherical data.
  48416. * @param texture defines the texture containing the polynomials
  48417. * @return the JSON representation of the spherical info
  48418. */
  48419. private static _CreateEnvTextureIrradiance;
  48420. /**
  48421. * Uploads the texture info contained in the env file to the GPU.
  48422. * @param texture defines the internal texture to upload to
  48423. * @param arrayBuffer defines the buffer cotaining the data to load
  48424. * @param info defines the texture info retrieved through the GetEnvInfo method
  48425. * @returns a promise
  48426. */
  48427. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48428. /**
  48429. * Uploads the levels of image data to the GPU.
  48430. * @param texture defines the internal texture to upload to
  48431. * @param imageData defines the array buffer views of image data [mipmap][face]
  48432. * @returns a promise
  48433. */
  48434. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48435. /**
  48436. * Uploads spherical polynomials information to the texture.
  48437. * @param texture defines the texture we are trying to upload the information to
  48438. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48439. */
  48440. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48441. /** @hidden */
  48442. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48443. }
  48444. }
  48445. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48446. import { Nullable } from "babylonjs/types";
  48447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48448. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48449. /**
  48450. * Implementation of the ENV Texture Loader.
  48451. * @hidden
  48452. */
  48453. export class _ENVTextureLoader implements IInternalTextureLoader {
  48454. /**
  48455. * Defines wether the loader supports cascade loading the different faces.
  48456. */
  48457. readonly supportCascades: boolean;
  48458. /**
  48459. * This returns if the loader support the current file information.
  48460. * @param extension defines the file extension of the file being loaded
  48461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48462. * @param fallback defines the fallback internal texture if any
  48463. * @param isBase64 defines whether the texture is encoded as a base64
  48464. * @param isBuffer defines whether the texture data are stored as a buffer
  48465. * @returns true if the loader can load the specified file
  48466. */
  48467. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48468. /**
  48469. * Transform the url before loading if required.
  48470. * @param rootUrl the url of the texture
  48471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48472. * @returns the transformed texture
  48473. */
  48474. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48475. /**
  48476. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48477. * @param rootUrl the url of the texture
  48478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48479. * @returns the fallback texture
  48480. */
  48481. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48482. /**
  48483. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48484. * @param data contains the texture data
  48485. * @param texture defines the BabylonJS internal texture
  48486. * @param createPolynomials will be true if polynomials have been requested
  48487. * @param onLoad defines the callback to trigger once the texture is ready
  48488. * @param onError defines the callback to trigger in case of error
  48489. */
  48490. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48491. /**
  48492. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48493. * @param data contains the texture data
  48494. * @param texture defines the BabylonJS internal texture
  48495. * @param callback defines the method to call once ready to upload
  48496. */
  48497. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48498. }
  48499. }
  48500. declare module "babylonjs/Misc/khronosTextureContainer" {
  48501. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48502. /**
  48503. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48504. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48505. */
  48506. export class KhronosTextureContainer {
  48507. /** contents of the KTX container file */
  48508. arrayBuffer: any;
  48509. private static HEADER_LEN;
  48510. private static COMPRESSED_2D;
  48511. private static COMPRESSED_3D;
  48512. private static TEX_2D;
  48513. private static TEX_3D;
  48514. /**
  48515. * Gets the openGL type
  48516. */
  48517. glType: number;
  48518. /**
  48519. * Gets the openGL type size
  48520. */
  48521. glTypeSize: number;
  48522. /**
  48523. * Gets the openGL format
  48524. */
  48525. glFormat: number;
  48526. /**
  48527. * Gets the openGL internal format
  48528. */
  48529. glInternalFormat: number;
  48530. /**
  48531. * Gets the base internal format
  48532. */
  48533. glBaseInternalFormat: number;
  48534. /**
  48535. * Gets image width in pixel
  48536. */
  48537. pixelWidth: number;
  48538. /**
  48539. * Gets image height in pixel
  48540. */
  48541. pixelHeight: number;
  48542. /**
  48543. * Gets image depth in pixels
  48544. */
  48545. pixelDepth: number;
  48546. /**
  48547. * Gets the number of array elements
  48548. */
  48549. numberOfArrayElements: number;
  48550. /**
  48551. * Gets the number of faces
  48552. */
  48553. numberOfFaces: number;
  48554. /**
  48555. * Gets the number of mipmap levels
  48556. */
  48557. numberOfMipmapLevels: number;
  48558. /**
  48559. * Gets the bytes of key value data
  48560. */
  48561. bytesOfKeyValueData: number;
  48562. /**
  48563. * Gets the load type
  48564. */
  48565. loadType: number;
  48566. /**
  48567. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48568. */
  48569. isInvalid: boolean;
  48570. /**
  48571. * Creates a new KhronosTextureContainer
  48572. * @param arrayBuffer contents of the KTX container file
  48573. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48574. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48575. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48576. */
  48577. constructor(
  48578. /** contents of the KTX container file */
  48579. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48580. /**
  48581. * Uploads KTX content to a Babylon Texture.
  48582. * It is assumed that the texture has already been created & is currently bound
  48583. * @hidden
  48584. */
  48585. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48586. private _upload2DCompressedLevels;
  48587. }
  48588. }
  48589. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48590. import { Nullable } from "babylonjs/types";
  48591. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48592. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48593. /**
  48594. * Implementation of the KTX Texture Loader.
  48595. * @hidden
  48596. */
  48597. export class _KTXTextureLoader implements IInternalTextureLoader {
  48598. /**
  48599. * Defines wether the loader supports cascade loading the different faces.
  48600. */
  48601. readonly supportCascades: boolean;
  48602. /**
  48603. * This returns if the loader support the current file information.
  48604. * @param extension defines the file extension of the file being loaded
  48605. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48606. * @param fallback defines the fallback internal texture if any
  48607. * @param isBase64 defines whether the texture is encoded as a base64
  48608. * @param isBuffer defines whether the texture data are stored as a buffer
  48609. * @returns true if the loader can load the specified file
  48610. */
  48611. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48612. /**
  48613. * Transform the url before loading if required.
  48614. * @param rootUrl the url of the texture
  48615. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48616. * @returns the transformed texture
  48617. */
  48618. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48619. /**
  48620. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48621. * @param rootUrl the url of the texture
  48622. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48623. * @returns the fallback texture
  48624. */
  48625. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48626. /**
  48627. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48628. * @param data contains the texture data
  48629. * @param texture defines the BabylonJS internal texture
  48630. * @param createPolynomials will be true if polynomials have been requested
  48631. * @param onLoad defines the callback to trigger once the texture is ready
  48632. * @param onError defines the callback to trigger in case of error
  48633. */
  48634. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48635. /**
  48636. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48637. * @param data contains the texture data
  48638. * @param texture defines the BabylonJS internal texture
  48639. * @param callback defines the method to call once ready to upload
  48640. */
  48641. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48642. }
  48643. }
  48644. declare module "babylonjs/Misc/tga" {
  48645. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48646. /**
  48647. * Based on jsTGALoader - Javascript loader for TGA file
  48648. * By Vincent Thibault
  48649. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48650. */
  48651. export class TGATools {
  48652. private static _TYPE_INDEXED;
  48653. private static _TYPE_RGB;
  48654. private static _TYPE_GREY;
  48655. private static _TYPE_RLE_INDEXED;
  48656. private static _TYPE_RLE_RGB;
  48657. private static _TYPE_RLE_GREY;
  48658. private static _ORIGIN_MASK;
  48659. private static _ORIGIN_SHIFT;
  48660. private static _ORIGIN_BL;
  48661. private static _ORIGIN_BR;
  48662. private static _ORIGIN_UL;
  48663. private static _ORIGIN_UR;
  48664. /**
  48665. * Gets the header of a TGA file
  48666. * @param data defines the TGA data
  48667. * @returns the header
  48668. */
  48669. static GetTGAHeader(data: Uint8Array): any;
  48670. /**
  48671. * Uploads TGA content to a Babylon Texture
  48672. * @hidden
  48673. */
  48674. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48675. /** @hidden */
  48676. 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;
  48677. /** @hidden */
  48678. 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;
  48679. /** @hidden */
  48680. 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;
  48681. /** @hidden */
  48682. 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;
  48683. /** @hidden */
  48684. 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;
  48685. /** @hidden */
  48686. 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;
  48687. }
  48688. }
  48689. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48690. import { Nullable } from "babylonjs/types";
  48691. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48692. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48693. /**
  48694. * Implementation of the TGA Texture Loader.
  48695. * @hidden
  48696. */
  48697. export class _TGATextureLoader implements IInternalTextureLoader {
  48698. /**
  48699. * Defines wether the loader supports cascade loading the different faces.
  48700. */
  48701. readonly supportCascades: boolean;
  48702. /**
  48703. * This returns if the loader support the current file information.
  48704. * @param extension defines the file extension of the file being loaded
  48705. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48706. * @param fallback defines the fallback internal texture if any
  48707. * @param isBase64 defines whether the texture is encoded as a base64
  48708. * @param isBuffer defines whether the texture data are stored as a buffer
  48709. * @returns true if the loader can load the specified file
  48710. */
  48711. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48712. /**
  48713. * Transform the url before loading if required.
  48714. * @param rootUrl the url of the texture
  48715. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48716. * @returns the transformed texture
  48717. */
  48718. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48719. /**
  48720. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48721. * @param rootUrl the url of the texture
  48722. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48723. * @returns the fallback texture
  48724. */
  48725. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48726. /**
  48727. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48728. * @param data contains the texture data
  48729. * @param texture defines the BabylonJS internal texture
  48730. * @param createPolynomials will be true if polynomials have been requested
  48731. * @param onLoad defines the callback to trigger once the texture is ready
  48732. * @param onError defines the callback to trigger in case of error
  48733. */
  48734. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48735. /**
  48736. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48737. * @param data contains the texture data
  48738. * @param texture defines the BabylonJS internal texture
  48739. * @param callback defines the method to call once ready to upload
  48740. */
  48741. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48742. }
  48743. }
  48744. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48745. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48746. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48747. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48748. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48749. }
  48750. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48751. import { Scene } from "babylonjs/scene";
  48752. import { Texture } from "babylonjs/Materials/Textures/texture";
  48753. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48754. /**
  48755. * 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.
  48756. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48757. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48758. */
  48759. export class CustomProceduralTexture extends ProceduralTexture {
  48760. private _animate;
  48761. private _time;
  48762. private _config;
  48763. private _texturePath;
  48764. /**
  48765. * Instantiates a new Custom Procedural Texture.
  48766. * 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.
  48767. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48768. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48769. * @param name Define the name of the texture
  48770. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48771. * @param size Define the size of the texture to create
  48772. * @param scene Define the scene the texture belongs to
  48773. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48774. * @param generateMipMaps Define if the texture should creates mip maps or not
  48775. */
  48776. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48777. private _loadJson;
  48778. /**
  48779. * Is the texture ready to be used ? (rendered at least once)
  48780. * @returns true if ready, otherwise, false.
  48781. */
  48782. isReady(): boolean;
  48783. /**
  48784. * Render the texture to its associated render target.
  48785. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48786. */
  48787. render(useCameraPostProcess?: boolean): void;
  48788. /**
  48789. * Update the list of dependant textures samplers in the shader.
  48790. */
  48791. updateTextures(): void;
  48792. /**
  48793. * Update the uniform values of the procedural texture in the shader.
  48794. */
  48795. updateShaderUniforms(): void;
  48796. /**
  48797. * Define if the texture animates or not.
  48798. */
  48799. animate: boolean;
  48800. }
  48801. }
  48802. declare module "babylonjs/Shaders/noise.fragment" {
  48803. /** @hidden */
  48804. export var noisePixelShader: {
  48805. name: string;
  48806. shader: string;
  48807. };
  48808. }
  48809. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48810. import { Nullable } from "babylonjs/types";
  48811. import { Scene } from "babylonjs/scene";
  48812. import { Texture } from "babylonjs/Materials/Textures/texture";
  48813. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48814. import "babylonjs/Shaders/noise.fragment";
  48815. /**
  48816. * Class used to generate noise procedural textures
  48817. */
  48818. export class NoiseProceduralTexture extends ProceduralTexture {
  48819. private _time;
  48820. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48821. brightness: number;
  48822. /** Defines the number of octaves to process */
  48823. octaves: number;
  48824. /** Defines the level of persistence (0.8 by default) */
  48825. persistence: number;
  48826. /** Gets or sets animation speed factor (default is 1) */
  48827. animationSpeedFactor: number;
  48828. /**
  48829. * Creates a new NoiseProceduralTexture
  48830. * @param name defines the name fo the texture
  48831. * @param size defines the size of the texture (default is 256)
  48832. * @param scene defines the hosting scene
  48833. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48834. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48835. */
  48836. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48837. private _updateShaderUniforms;
  48838. protected _getDefines(): string;
  48839. /** Generate the current state of the procedural texture */
  48840. render(useCameraPostProcess?: boolean): void;
  48841. /**
  48842. * Serializes this noise procedural texture
  48843. * @returns a serialized noise procedural texture object
  48844. */
  48845. serialize(): any;
  48846. /**
  48847. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48848. * @param parsedTexture defines parsed texture data
  48849. * @param scene defines the current scene
  48850. * @param rootUrl defines the root URL containing noise procedural texture information
  48851. * @returns a parsed NoiseProceduralTexture
  48852. */
  48853. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48854. }
  48855. }
  48856. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  48857. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  48858. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  48859. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48860. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  48861. }
  48862. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  48863. import { Nullable } from "babylonjs/types";
  48864. import { Scene } from "babylonjs/scene";
  48865. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48866. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48867. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48868. /**
  48869. * Raw cube texture where the raw buffers are passed in
  48870. */
  48871. export class RawCubeTexture extends CubeTexture {
  48872. /**
  48873. * Creates a cube texture where the raw buffers are passed in.
  48874. * @param scene defines the scene the texture is attached to
  48875. * @param data defines the array of data to use to create each face
  48876. * @param size defines the size of the textures
  48877. * @param format defines the format of the data
  48878. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48879. * @param generateMipMaps defines if the engine should generate the mip levels
  48880. * @param invertY defines if data must be stored with Y axis inverted
  48881. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48882. * @param compression defines the compression used (null by default)
  48883. */
  48884. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48885. /**
  48886. * Updates the raw cube texture.
  48887. * @param data defines the data to store
  48888. * @param format defines the data format
  48889. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48890. * @param invertY defines if data must be stored with Y axis inverted
  48891. * @param compression defines the compression used (null by default)
  48892. * @param level defines which level of the texture to update
  48893. */
  48894. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48895. /**
  48896. * Updates a raw cube texture with RGBD encoded data.
  48897. * @param data defines the array of data [mipmap][face] to use to create each face
  48898. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48899. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48900. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48901. * @returns a promsie that resolves when the operation is complete
  48902. */
  48903. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48904. /**
  48905. * Clones the raw cube texture.
  48906. * @return a new cube texture
  48907. */
  48908. clone(): CubeTexture;
  48909. /** @hidden */
  48910. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48911. }
  48912. }
  48913. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  48914. import { Scene } from "babylonjs/scene";
  48915. import { Texture } from "babylonjs/Materials/Textures/texture";
  48916. /**
  48917. * Class used to store 3D textures containing user data
  48918. */
  48919. export class RawTexture3D extends Texture {
  48920. /** Gets or sets the texture format to use */
  48921. format: number;
  48922. private _engine;
  48923. /**
  48924. * Create a new RawTexture3D
  48925. * @param data defines the data of the texture
  48926. * @param width defines the width of the texture
  48927. * @param height defines the height of the texture
  48928. * @param depth defines the depth of the texture
  48929. * @param format defines the texture format to use
  48930. * @param scene defines the hosting scene
  48931. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48932. * @param invertY defines if texture must be stored with Y axis inverted
  48933. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48934. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48935. */
  48936. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48937. /** Gets or sets the texture format to use */
  48938. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48939. /**
  48940. * Update the texture with new data
  48941. * @param data defines the data to store in the texture
  48942. */
  48943. update(data: ArrayBufferView): void;
  48944. }
  48945. }
  48946. declare module "babylonjs/Materials/Textures/refractionTexture" {
  48947. import { Scene } from "babylonjs/scene";
  48948. import { Plane } from "babylonjs/Maths/math";
  48949. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48950. /**
  48951. * Creates a refraction texture used by refraction channel of the standard material.
  48952. * It is like a mirror but to see through a material.
  48953. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48954. */
  48955. export class RefractionTexture extends RenderTargetTexture {
  48956. /**
  48957. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48958. * 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.
  48959. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48960. */
  48961. refractionPlane: Plane;
  48962. /**
  48963. * Define how deep under the surface we should see.
  48964. */
  48965. depth: number;
  48966. /**
  48967. * Creates a refraction texture used by refraction channel of the standard material.
  48968. * It is like a mirror but to see through a material.
  48969. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48970. * @param name Define the texture name
  48971. * @param size Define the size of the underlying texture
  48972. * @param scene Define the scene the refraction belongs to
  48973. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48974. */
  48975. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48976. /**
  48977. * Clone the refraction texture.
  48978. * @returns the cloned texture
  48979. */
  48980. clone(): RefractionTexture;
  48981. /**
  48982. * Serialize the texture to a JSON representation you could use in Parse later on
  48983. * @returns the serialized JSON representation
  48984. */
  48985. serialize(): any;
  48986. }
  48987. }
  48988. declare module "babylonjs/Materials/Textures/index" {
  48989. export * from "babylonjs/Materials/Textures/baseTexture";
  48990. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  48991. export * from "babylonjs/Materials/Textures/cubeTexture";
  48992. export * from "babylonjs/Materials/Textures/dynamicTexture";
  48993. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  48994. export * from "babylonjs/Materials/Textures/internalTexture";
  48995. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  48996. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  48997. export * from "babylonjs/Materials/Textures/Loaders/index";
  48998. export * from "babylonjs/Materials/Textures/mirrorTexture";
  48999. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49000. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49001. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49002. export * from "babylonjs/Materials/Textures/rawTexture";
  49003. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49004. export * from "babylonjs/Materials/Textures/refractionTexture";
  49005. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49006. export * from "babylonjs/Materials/Textures/texture";
  49007. export * from "babylonjs/Materials/Textures/videoTexture";
  49008. }
  49009. declare module "babylonjs/Materials/index" {
  49010. export * from "babylonjs/Materials/Background/index";
  49011. export * from "babylonjs/Materials/colorCurves";
  49012. export * from "babylonjs/Materials/effect";
  49013. export * from "babylonjs/Materials/fresnelParameters";
  49014. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49015. export * from "babylonjs/Materials/material";
  49016. export * from "babylonjs/Materials/materialDefines";
  49017. export * from "babylonjs/Materials/materialHelper";
  49018. export * from "babylonjs/Materials/multiMaterial";
  49019. export * from "babylonjs/Materials/PBR/index";
  49020. export * from "babylonjs/Materials/pushMaterial";
  49021. export * from "babylonjs/Materials/shaderMaterial";
  49022. export * from "babylonjs/Materials/standardMaterial";
  49023. export * from "babylonjs/Materials/Textures/index";
  49024. export * from "babylonjs/Materials/uniformBuffer";
  49025. export * from "babylonjs/Materials/materialFlags";
  49026. }
  49027. declare module "babylonjs/Maths/index" {
  49028. export * from "babylonjs/Maths/math.scalar";
  49029. export * from "babylonjs/Maths/math";
  49030. export * from "babylonjs/Maths/sphericalPolynomial";
  49031. }
  49032. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49033. import { IDisposable } from "babylonjs/scene";
  49034. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49035. /**
  49036. * Configuration for Draco compression
  49037. */
  49038. export interface IDracoCompressionConfiguration {
  49039. /**
  49040. * Configuration for the decoder.
  49041. */
  49042. decoder?: {
  49043. /**
  49044. * The url to the WebAssembly module.
  49045. */
  49046. wasmUrl?: string;
  49047. /**
  49048. * The url to the WebAssembly binary.
  49049. */
  49050. wasmBinaryUrl?: string;
  49051. /**
  49052. * The url to the fallback JavaScript module.
  49053. */
  49054. fallbackUrl?: string;
  49055. };
  49056. }
  49057. /**
  49058. * Draco compression (https://google.github.io/draco/)
  49059. *
  49060. * This class wraps the Draco module.
  49061. *
  49062. * **Encoder**
  49063. *
  49064. * The encoder is not currently implemented.
  49065. *
  49066. * **Decoder**
  49067. *
  49068. * 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.
  49069. *
  49070. * To update the configuration, use the following code:
  49071. * ```javascript
  49072. * DracoCompression.Configuration = {
  49073. * decoder: {
  49074. * wasmUrl: "<url to the WebAssembly library>",
  49075. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49076. * fallbackUrl: "<url to the fallback JavaScript library>",
  49077. * }
  49078. * };
  49079. * ```
  49080. *
  49081. * 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.
  49082. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49083. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49084. *
  49085. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49086. * ```javascript
  49087. * var dracoCompression = new DracoCompression();
  49088. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49089. * [VertexBuffer.PositionKind]: 0
  49090. * });
  49091. * ```
  49092. *
  49093. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49094. */
  49095. export class DracoCompression implements IDisposable {
  49096. private static _DecoderModulePromise;
  49097. /**
  49098. * The configuration. Defaults to the following urls:
  49099. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49100. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49101. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49102. */
  49103. static Configuration: IDracoCompressionConfiguration;
  49104. /**
  49105. * Returns true if the decoder is available.
  49106. */
  49107. static readonly DecoderAvailable: boolean;
  49108. /**
  49109. * Constructor
  49110. */
  49111. constructor();
  49112. /**
  49113. * Stop all async operations and release resources.
  49114. */
  49115. dispose(): void;
  49116. /**
  49117. * Decode Draco compressed mesh data to vertex data.
  49118. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49119. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49120. * @returns A promise that resolves with the decoded vertex data
  49121. */
  49122. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49123. [kind: string]: number;
  49124. }): Promise<VertexData>;
  49125. private static _GetDecoderModule;
  49126. private static _LoadScriptAsync;
  49127. private static _LoadFileAsync;
  49128. }
  49129. }
  49130. declare module "babylonjs/Meshes/Compression/index" {
  49131. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49132. }
  49133. declare module "babylonjs/Meshes/csg" {
  49134. import { Nullable } from "babylonjs/types";
  49135. import { Scene } from "babylonjs/scene";
  49136. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49137. import { Mesh } from "babylonjs/Meshes/mesh";
  49138. import { Material } from "babylonjs/Materials/material";
  49139. /**
  49140. * Class for building Constructive Solid Geometry
  49141. */
  49142. export class CSG {
  49143. private polygons;
  49144. /**
  49145. * The world matrix
  49146. */
  49147. matrix: Matrix;
  49148. /**
  49149. * Stores the position
  49150. */
  49151. position: Vector3;
  49152. /**
  49153. * Stores the rotation
  49154. */
  49155. rotation: Vector3;
  49156. /**
  49157. * Stores the rotation quaternion
  49158. */
  49159. rotationQuaternion: Nullable<Quaternion>;
  49160. /**
  49161. * Stores the scaling vector
  49162. */
  49163. scaling: Vector3;
  49164. /**
  49165. * Convert the Mesh to CSG
  49166. * @param mesh The Mesh to convert to CSG
  49167. * @returns A new CSG from the Mesh
  49168. */
  49169. static FromMesh(mesh: Mesh): CSG;
  49170. /**
  49171. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49172. * @param polygons Polygons used to construct a CSG solid
  49173. */
  49174. private static FromPolygons;
  49175. /**
  49176. * Clones, or makes a deep copy, of the CSG
  49177. * @returns A new CSG
  49178. */
  49179. clone(): CSG;
  49180. /**
  49181. * Unions this CSG with another CSG
  49182. * @param csg The CSG to union against this CSG
  49183. * @returns The unioned CSG
  49184. */
  49185. union(csg: CSG): CSG;
  49186. /**
  49187. * Unions this CSG with another CSG in place
  49188. * @param csg The CSG to union against this CSG
  49189. */
  49190. unionInPlace(csg: CSG): void;
  49191. /**
  49192. * Subtracts this CSG with another CSG
  49193. * @param csg The CSG to subtract against this CSG
  49194. * @returns A new CSG
  49195. */
  49196. subtract(csg: CSG): CSG;
  49197. /**
  49198. * Subtracts this CSG with another CSG in place
  49199. * @param csg The CSG to subtact against this CSG
  49200. */
  49201. subtractInPlace(csg: CSG): void;
  49202. /**
  49203. * Intersect this CSG with another CSG
  49204. * @param csg The CSG to intersect against this CSG
  49205. * @returns A new CSG
  49206. */
  49207. intersect(csg: CSG): CSG;
  49208. /**
  49209. * Intersects this CSG with another CSG in place
  49210. * @param csg The CSG to intersect against this CSG
  49211. */
  49212. intersectInPlace(csg: CSG): void;
  49213. /**
  49214. * Return a new CSG solid with solid and empty space switched. This solid is
  49215. * not modified.
  49216. * @returns A new CSG solid with solid and empty space switched
  49217. */
  49218. inverse(): CSG;
  49219. /**
  49220. * Inverses the CSG in place
  49221. */
  49222. inverseInPlace(): void;
  49223. /**
  49224. * This is used to keep meshes transformations so they can be restored
  49225. * when we build back a Babylon Mesh
  49226. * NB : All CSG operations are performed in world coordinates
  49227. * @param csg The CSG to copy the transform attributes from
  49228. * @returns This CSG
  49229. */
  49230. copyTransformAttributes(csg: CSG): CSG;
  49231. /**
  49232. * Build Raw mesh from CSG
  49233. * Coordinates here are in world space
  49234. * @param name The name of the mesh geometry
  49235. * @param scene The Scene
  49236. * @param keepSubMeshes Specifies if the submeshes should be kept
  49237. * @returns A new Mesh
  49238. */
  49239. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49240. /**
  49241. * Build Mesh from CSG taking material and transforms into account
  49242. * @param name The name of the Mesh
  49243. * @param material The material of the Mesh
  49244. * @param scene The Scene
  49245. * @param keepSubMeshes Specifies if submeshes should be kept
  49246. * @returns The new Mesh
  49247. */
  49248. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49249. }
  49250. }
  49251. declare module "babylonjs/Meshes/meshSimplification" {
  49252. import { Mesh } from "babylonjs/Meshes/mesh";
  49253. /**
  49254. * A simplifier interface for future simplification implementations
  49255. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49256. */
  49257. export interface ISimplifier {
  49258. /**
  49259. * Simplification of a given mesh according to the given settings.
  49260. * Since this requires computation, it is assumed that the function runs async.
  49261. * @param settings The settings of the simplification, including quality and distance
  49262. * @param successCallback A callback that will be called after the mesh was simplified.
  49263. * @param errorCallback in case of an error, this callback will be called. optional.
  49264. */
  49265. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49266. }
  49267. /**
  49268. * Expected simplification settings.
  49269. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49270. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49271. */
  49272. export interface ISimplificationSettings {
  49273. /**
  49274. * Gets or sets the expected quality
  49275. */
  49276. quality: number;
  49277. /**
  49278. * Gets or sets the distance when this optimized version should be used
  49279. */
  49280. distance: number;
  49281. /**
  49282. * Gets an already optimized mesh
  49283. */
  49284. optimizeMesh?: boolean;
  49285. }
  49286. /**
  49287. * Class used to specify simplification options
  49288. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49289. */
  49290. export class SimplificationSettings implements ISimplificationSettings {
  49291. /** expected quality */
  49292. quality: number;
  49293. /** distance when this optimized version should be used */
  49294. distance: number;
  49295. /** already optimized mesh */
  49296. optimizeMesh?: boolean | undefined;
  49297. /**
  49298. * Creates a SimplificationSettings
  49299. * @param quality expected quality
  49300. * @param distance distance when this optimized version should be used
  49301. * @param optimizeMesh already optimized mesh
  49302. */
  49303. constructor(
  49304. /** expected quality */
  49305. quality: number,
  49306. /** distance when this optimized version should be used */
  49307. distance: number,
  49308. /** already optimized mesh */
  49309. optimizeMesh?: boolean | undefined);
  49310. }
  49311. /**
  49312. * Interface used to define a simplification task
  49313. */
  49314. export interface ISimplificationTask {
  49315. /**
  49316. * Array of settings
  49317. */
  49318. settings: Array<ISimplificationSettings>;
  49319. /**
  49320. * Simplification type
  49321. */
  49322. simplificationType: SimplificationType;
  49323. /**
  49324. * Mesh to simplify
  49325. */
  49326. mesh: Mesh;
  49327. /**
  49328. * Callback called on success
  49329. */
  49330. successCallback?: () => void;
  49331. /**
  49332. * Defines if parallel processing can be used
  49333. */
  49334. parallelProcessing: boolean;
  49335. }
  49336. /**
  49337. * Queue used to order the simplification tasks
  49338. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49339. */
  49340. export class SimplificationQueue {
  49341. private _simplificationArray;
  49342. /**
  49343. * Gets a boolean indicating that the process is still running
  49344. */
  49345. running: boolean;
  49346. /**
  49347. * Creates a new queue
  49348. */
  49349. constructor();
  49350. /**
  49351. * Adds a new simplification task
  49352. * @param task defines a task to add
  49353. */
  49354. addTask(task: ISimplificationTask): void;
  49355. /**
  49356. * Execute next task
  49357. */
  49358. executeNext(): void;
  49359. /**
  49360. * Execute a simplification task
  49361. * @param task defines the task to run
  49362. */
  49363. runSimplification(task: ISimplificationTask): void;
  49364. private getSimplifier;
  49365. }
  49366. /**
  49367. * The implemented types of simplification
  49368. * At the moment only Quadratic Error Decimation is implemented
  49369. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49370. */
  49371. export enum SimplificationType {
  49372. /** Quadratic error decimation */
  49373. QUADRATIC = 0
  49374. }
  49375. }
  49376. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  49377. import { Scene } from "babylonjs/scene";
  49378. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  49379. import { ISceneComponent } from "babylonjs/sceneComponent";
  49380. module "babylonjs/scene" {
  49381. interface Scene {
  49382. /** @hidden (Backing field) */
  49383. _simplificationQueue: SimplificationQueue;
  49384. /**
  49385. * Gets or sets the simplification queue attached to the scene
  49386. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49387. */
  49388. simplificationQueue: SimplificationQueue;
  49389. }
  49390. }
  49391. module "babylonjs/Meshes/mesh" {
  49392. interface Mesh {
  49393. /**
  49394. * Simplify the mesh according to the given array of settings.
  49395. * Function will return immediately and will simplify async
  49396. * @param settings a collection of simplification settings
  49397. * @param parallelProcessing should all levels calculate parallel or one after the other
  49398. * @param simplificationType the type of simplification to run
  49399. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  49400. * @returns the current mesh
  49401. */
  49402. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  49403. }
  49404. }
  49405. /**
  49406. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  49407. * created in a scene
  49408. */
  49409. export class SimplicationQueueSceneComponent implements ISceneComponent {
  49410. /**
  49411. * The component name helpfull to identify the component in the list of scene components.
  49412. */
  49413. readonly name: string;
  49414. /**
  49415. * The scene the component belongs to.
  49416. */
  49417. scene: Scene;
  49418. /**
  49419. * Creates a new instance of the component for the given scene
  49420. * @param scene Defines the scene to register the component in
  49421. */
  49422. constructor(scene: Scene);
  49423. /**
  49424. * Registers the component in a given scene
  49425. */
  49426. register(): void;
  49427. /**
  49428. * Rebuilds the elements related to this component in case of
  49429. * context lost for instance.
  49430. */
  49431. rebuild(): void;
  49432. /**
  49433. * Disposes the component and the associated ressources
  49434. */
  49435. dispose(): void;
  49436. private _beforeCameraUpdate;
  49437. }
  49438. }
  49439. declare module "babylonjs/Meshes/index" {
  49440. export * from "babylonjs/Meshes/abstractMesh";
  49441. export * from "babylonjs/Meshes/buffer";
  49442. export * from "babylonjs/Meshes/Compression/index";
  49443. export * from "babylonjs/Meshes/csg";
  49444. export * from "babylonjs/Meshes/geometry";
  49445. export * from "babylonjs/Meshes/groundMesh";
  49446. export * from "babylonjs/Meshes/instancedMesh";
  49447. export * from "babylonjs/Meshes/linesMesh";
  49448. export * from "babylonjs/Meshes/mesh";
  49449. export * from "babylonjs/Meshes/mesh.vertexData";
  49450. export * from "babylonjs/Meshes/meshBuilder";
  49451. export * from "babylonjs/Meshes/meshSimplification";
  49452. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  49453. export * from "babylonjs/Meshes/polygonMesh";
  49454. export * from "babylonjs/Meshes/subMesh";
  49455. export * from "babylonjs/Meshes/transformNode";
  49456. }
  49457. declare module "babylonjs/Morph/index" {
  49458. export * from "babylonjs/Morph/morphTarget";
  49459. export * from "babylonjs/Morph/morphTargetManager";
  49460. }
  49461. declare module "babylonjs/Offline/database" {
  49462. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  49463. /**
  49464. * Class used to enable access to IndexedDB
  49465. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  49466. */
  49467. export class Database implements IOfflineProvider {
  49468. private _callbackManifestChecked;
  49469. private _currentSceneUrl;
  49470. private _db;
  49471. private _enableSceneOffline;
  49472. private _enableTexturesOffline;
  49473. private _manifestVersionFound;
  49474. private _mustUpdateRessources;
  49475. private _hasReachedQuota;
  49476. private _isSupported;
  49477. private _idbFactory;
  49478. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  49479. private static IsUASupportingBlobStorage;
  49480. /**
  49481. * Gets a boolean indicating if Database storate is enabled (off by default)
  49482. */
  49483. static IDBStorageEnabled: boolean;
  49484. /**
  49485. * Gets a boolean indicating if scene must be saved in the database
  49486. */
  49487. readonly enableSceneOffline: boolean;
  49488. /**
  49489. * Gets a boolean indicating if textures must be saved in the database
  49490. */
  49491. readonly enableTexturesOffline: boolean;
  49492. /**
  49493. * Creates a new Database
  49494. * @param urlToScene defines the url to load the scene
  49495. * @param callbackManifestChecked defines the callback to use when manifest is checked
  49496. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  49497. */
  49498. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  49499. private static _ParseURL;
  49500. private static _ReturnFullUrlLocation;
  49501. private _checkManifestFile;
  49502. /**
  49503. * Open the database and make it available
  49504. * @param successCallback defines the callback to call on success
  49505. * @param errorCallback defines the callback to call on error
  49506. */
  49507. open(successCallback: () => void, errorCallback: () => void): void;
  49508. /**
  49509. * Loads an image from the database
  49510. * @param url defines the url to load from
  49511. * @param image defines the target DOM image
  49512. */
  49513. loadImage(url: string, image: HTMLImageElement): void;
  49514. private _loadImageFromDBAsync;
  49515. private _saveImageIntoDBAsync;
  49516. private _checkVersionFromDB;
  49517. private _loadVersionFromDBAsync;
  49518. private _saveVersionIntoDBAsync;
  49519. /**
  49520. * Loads a file from database
  49521. * @param url defines the URL to load from
  49522. * @param sceneLoaded defines a callback to call on success
  49523. * @param progressCallBack defines a callback to call when progress changed
  49524. * @param errorCallback defines a callback to call on error
  49525. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  49526. */
  49527. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  49528. private _loadFileAsync;
  49529. private _saveFileAsync;
  49530. /**
  49531. * Validates if xhr data is correct
  49532. * @param xhr defines the request to validate
  49533. * @param dataType defines the expected data type
  49534. * @returns true if data is correct
  49535. */
  49536. private static _ValidateXHRData;
  49537. }
  49538. }
  49539. declare module "babylonjs/Offline/index" {
  49540. export * from "babylonjs/Offline/database";
  49541. export * from "babylonjs/Offline/IOfflineProvider";
  49542. }
  49543. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  49544. /** @hidden */
  49545. export var gpuUpdateParticlesPixelShader: {
  49546. name: string;
  49547. shader: string;
  49548. };
  49549. }
  49550. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  49551. /** @hidden */
  49552. export var gpuUpdateParticlesVertexShader: {
  49553. name: string;
  49554. shader: string;
  49555. };
  49556. }
  49557. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  49558. /** @hidden */
  49559. export var clipPlaneFragmentDeclaration2: {
  49560. name: string;
  49561. shader: string;
  49562. };
  49563. }
  49564. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  49565. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  49566. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49567. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49568. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49569. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49570. /** @hidden */
  49571. export var gpuRenderParticlesPixelShader: {
  49572. name: string;
  49573. shader: string;
  49574. };
  49575. }
  49576. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  49577. /** @hidden */
  49578. export var clipPlaneVertexDeclaration2: {
  49579. name: string;
  49580. shader: string;
  49581. };
  49582. }
  49583. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  49584. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  49585. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49586. /** @hidden */
  49587. export var gpuRenderParticlesVertexShader: {
  49588. name: string;
  49589. shader: string;
  49590. };
  49591. }
  49592. declare module "babylonjs/Particles/gpuParticleSystem" {
  49593. import { Nullable } from "babylonjs/types";
  49594. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  49595. import { Observable } from "babylonjs/Misc/observable";
  49596. import { Color4, Color3 } from "babylonjs/Maths/math";
  49597. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49598. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  49599. import { Scene, IDisposable } from "babylonjs/scene";
  49600. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  49601. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  49602. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  49603. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  49604. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  49605. /**
  49606. * This represents a GPU particle system in Babylon
  49607. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  49608. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  49609. */
  49610. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  49611. /**
  49612. * The layer mask we are rendering the particles through.
  49613. */
  49614. layerMask: number;
  49615. private _capacity;
  49616. private _activeCount;
  49617. private _currentActiveCount;
  49618. private _accumulatedCount;
  49619. private _renderEffect;
  49620. private _updateEffect;
  49621. private _buffer0;
  49622. private _buffer1;
  49623. private _spriteBuffer;
  49624. private _updateVAO;
  49625. private _renderVAO;
  49626. private _targetIndex;
  49627. private _sourceBuffer;
  49628. private _targetBuffer;
  49629. private _engine;
  49630. private _currentRenderId;
  49631. private _started;
  49632. private _stopped;
  49633. private _timeDelta;
  49634. private _randomTexture;
  49635. private _randomTexture2;
  49636. private _attributesStrideSize;
  49637. private _updateEffectOptions;
  49638. private _randomTextureSize;
  49639. private _actualFrame;
  49640. private readonly _rawTextureWidth;
  49641. /**
  49642. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  49643. */
  49644. static readonly IsSupported: boolean;
  49645. /**
  49646. * An event triggered when the system is disposed.
  49647. */
  49648. onDisposeObservable: Observable<GPUParticleSystem>;
  49649. /**
  49650. * Gets the maximum number of particles active at the same time.
  49651. * @returns The max number of active particles.
  49652. */
  49653. getCapacity(): number;
  49654. /**
  49655. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  49656. * to override the particles.
  49657. */
  49658. forceDepthWrite: boolean;
  49659. /**
  49660. * Gets or set the number of active particles
  49661. */
  49662. activeParticleCount: number;
  49663. private _preWarmDone;
  49664. /**
  49665. * Is this system ready to be used/rendered
  49666. * @return true if the system is ready
  49667. */
  49668. isReady(): boolean;
  49669. /**
  49670. * Gets if the system has been started. (Note: this will still be true after stop is called)
  49671. * @returns True if it has been started, otherwise false.
  49672. */
  49673. isStarted(): boolean;
  49674. /**
  49675. * Starts the particle system and begins to emit
  49676. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  49677. */
  49678. start(delay?: number): void;
  49679. /**
  49680. * Stops the particle system.
  49681. */
  49682. stop(): void;
  49683. /**
  49684. * Remove all active particles
  49685. */
  49686. reset(): void;
  49687. /**
  49688. * Returns the string "GPUParticleSystem"
  49689. * @returns a string containing the class name
  49690. */
  49691. getClassName(): string;
  49692. private _colorGradientsTexture;
  49693. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  49694. /**
  49695. * Adds a new color gradient
  49696. * @param gradient defines the gradient to use (between 0 and 1)
  49697. * @param color1 defines the color to affect to the specified gradient
  49698. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  49699. * @returns the current particle system
  49700. */
  49701. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  49702. /**
  49703. * Remove a specific color gradient
  49704. * @param gradient defines the gradient to remove
  49705. * @returns the current particle system
  49706. */
  49707. removeColorGradient(gradient: number): GPUParticleSystem;
  49708. private _angularSpeedGradientsTexture;
  49709. private _sizeGradientsTexture;
  49710. private _velocityGradientsTexture;
  49711. private _limitVelocityGradientsTexture;
  49712. private _dragGradientsTexture;
  49713. private _addFactorGradient;
  49714. /**
  49715. * Adds a new size gradient
  49716. * @param gradient defines the gradient to use (between 0 and 1)
  49717. * @param factor defines the size factor to affect to the specified gradient
  49718. * @returns the current particle system
  49719. */
  49720. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  49721. /**
  49722. * Remove a specific size gradient
  49723. * @param gradient defines the gradient to remove
  49724. * @returns the current particle system
  49725. */
  49726. removeSizeGradient(gradient: number): GPUParticleSystem;
  49727. /**
  49728. * Adds a new angular speed gradient
  49729. * @param gradient defines the gradient to use (between 0 and 1)
  49730. * @param factor defines the angular speed to affect to the specified gradient
  49731. * @returns the current particle system
  49732. */
  49733. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  49734. /**
  49735. * Remove a specific angular speed gradient
  49736. * @param gradient defines the gradient to remove
  49737. * @returns the current particle system
  49738. */
  49739. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  49740. /**
  49741. * Adds a new velocity gradient
  49742. * @param gradient defines the gradient to use (between 0 and 1)
  49743. * @param factor defines the velocity to affect to the specified gradient
  49744. * @returns the current particle system
  49745. */
  49746. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  49747. /**
  49748. * Remove a specific velocity gradient
  49749. * @param gradient defines the gradient to remove
  49750. * @returns the current particle system
  49751. */
  49752. removeVelocityGradient(gradient: number): GPUParticleSystem;
  49753. /**
  49754. * Adds a new limit velocity gradient
  49755. * @param gradient defines the gradient to use (between 0 and 1)
  49756. * @param factor defines the limit velocity value to affect to the specified gradient
  49757. * @returns the current particle system
  49758. */
  49759. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  49760. /**
  49761. * Remove a specific limit velocity gradient
  49762. * @param gradient defines the gradient to remove
  49763. * @returns the current particle system
  49764. */
  49765. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  49766. /**
  49767. * Adds a new drag gradient
  49768. * @param gradient defines the gradient to use (between 0 and 1)
  49769. * @param factor defines the drag value to affect to the specified gradient
  49770. * @returns the current particle system
  49771. */
  49772. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  49773. /**
  49774. * Remove a specific drag gradient
  49775. * @param gradient defines the gradient to remove
  49776. * @returns the current particle system
  49777. */
  49778. removeDragGradient(gradient: number): GPUParticleSystem;
  49779. /**
  49780. * Not supported by GPUParticleSystem
  49781. * @param gradient defines the gradient to use (between 0 and 1)
  49782. * @param factor defines the emit rate value to affect to the specified gradient
  49783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49784. * @returns the current particle system
  49785. */
  49786. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49787. /**
  49788. * Not supported by GPUParticleSystem
  49789. * @param gradient defines the gradient to remove
  49790. * @returns the current particle system
  49791. */
  49792. removeEmitRateGradient(gradient: number): IParticleSystem;
  49793. /**
  49794. * Not supported by GPUParticleSystem
  49795. * @param gradient defines the gradient to use (between 0 and 1)
  49796. * @param factor defines the start size value to affect to the specified gradient
  49797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49798. * @returns the current particle system
  49799. */
  49800. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49801. /**
  49802. * Not supported by GPUParticleSystem
  49803. * @param gradient defines the gradient to remove
  49804. * @returns the current particle system
  49805. */
  49806. removeStartSizeGradient(gradient: number): IParticleSystem;
  49807. /**
  49808. * Not supported by GPUParticleSystem
  49809. * @param gradient defines the gradient to use (between 0 and 1)
  49810. * @param min defines the color remap minimal range
  49811. * @param max defines the color remap maximal range
  49812. * @returns the current particle system
  49813. */
  49814. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  49815. /**
  49816. * Not supported by GPUParticleSystem
  49817. * @param gradient defines the gradient to remove
  49818. * @returns the current particle system
  49819. */
  49820. removeColorRemapGradient(): IParticleSystem;
  49821. /**
  49822. * Not supported by GPUParticleSystem
  49823. * @param gradient defines the gradient to use (between 0 and 1)
  49824. * @param min defines the alpha remap minimal range
  49825. * @param max defines the alpha remap maximal range
  49826. * @returns the current particle system
  49827. */
  49828. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  49829. /**
  49830. * Not supported by GPUParticleSystem
  49831. * @param gradient defines the gradient to remove
  49832. * @returns the current particle system
  49833. */
  49834. removeAlphaRemapGradient(): IParticleSystem;
  49835. /**
  49836. * Not supported by GPUParticleSystem
  49837. * @param gradient defines the gradient to use (between 0 and 1)
  49838. * @param color defines the color to affect to the specified gradient
  49839. * @returns the current particle system
  49840. */
  49841. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  49842. /**
  49843. * Not supported by GPUParticleSystem
  49844. * @param gradient defines the gradient to remove
  49845. * @returns the current particle system
  49846. */
  49847. removeRampGradient(): IParticleSystem;
  49848. /**
  49849. * Not supported by GPUParticleSystem
  49850. * @returns the list of ramp gradients
  49851. */
  49852. getRampGradients(): Nullable<Array<Color3Gradient>>;
  49853. /**
  49854. * Not supported by GPUParticleSystem
  49855. * Gets or sets a boolean indicating that ramp gradients must be used
  49856. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  49857. */
  49858. useRampGradients: boolean;
  49859. /**
  49860. * Not supported by GPUParticleSystem
  49861. * @param gradient defines the gradient to use (between 0 and 1)
  49862. * @param factor defines the life time factor to affect to the specified gradient
  49863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49864. * @returns the current particle system
  49865. */
  49866. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49867. /**
  49868. * Not supported by GPUParticleSystem
  49869. * @param gradient defines the gradient to remove
  49870. * @returns the current particle system
  49871. */
  49872. removeLifeTimeGradient(gradient: number): IParticleSystem;
  49873. /**
  49874. * Instantiates a GPU particle system.
  49875. * 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.
  49876. * @param name The name of the particle system
  49877. * @param options The options used to create the system
  49878. * @param scene The scene the particle system belongs to
  49879. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  49880. */
  49881. constructor(name: string, options: Partial<{
  49882. capacity: number;
  49883. randomTextureSize: number;
  49884. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  49885. protected _reset(): void;
  49886. private _createUpdateVAO;
  49887. private _createRenderVAO;
  49888. private _initialize;
  49889. /** @hidden */
  49890. _recreateUpdateEffect(): void;
  49891. /** @hidden */
  49892. _recreateRenderEffect(): void;
  49893. /**
  49894. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  49895. * @param preWarm defines if we are in the pre-warmimg phase
  49896. */
  49897. animate(preWarm?: boolean): void;
  49898. private _createFactorGradientTexture;
  49899. private _createSizeGradientTexture;
  49900. private _createAngularSpeedGradientTexture;
  49901. private _createVelocityGradientTexture;
  49902. private _createLimitVelocityGradientTexture;
  49903. private _createDragGradientTexture;
  49904. private _createColorGradientTexture;
  49905. /**
  49906. * Renders the particle system in its current state
  49907. * @param preWarm defines if the system should only update the particles but not render them
  49908. * @returns the current number of particles
  49909. */
  49910. render(preWarm?: boolean): number;
  49911. /**
  49912. * Rebuilds the particle system
  49913. */
  49914. rebuild(): void;
  49915. private _releaseBuffers;
  49916. private _releaseVAOs;
  49917. /**
  49918. * Disposes the particle system and free the associated resources
  49919. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  49920. */
  49921. dispose(disposeTexture?: boolean): void;
  49922. /**
  49923. * Clones the particle system.
  49924. * @param name The name of the cloned object
  49925. * @param newEmitter The new emitter to use
  49926. * @returns the cloned particle system
  49927. */
  49928. clone(name: string, newEmitter: any): GPUParticleSystem;
  49929. /**
  49930. * Serializes the particle system to a JSON object.
  49931. * @returns the JSON object
  49932. */
  49933. serialize(): any;
  49934. /**
  49935. * Parses a JSON object to create a GPU particle system.
  49936. * @param parsedParticleSystem The JSON object to parse
  49937. * @param scene The scene to create the particle system in
  49938. * @param rootUrl The root url to use to load external dependencies like texture
  49939. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  49940. * @returns the parsed GPU particle system
  49941. */
  49942. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  49943. }
  49944. }
  49945. declare module "babylonjs/Particles/particleSystemSet" {
  49946. import { Nullable } from "babylonjs/types";
  49947. import { Color3 } from "babylonjs/Maths/math";
  49948. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49950. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49951. import { Scene, IDisposable } from "babylonjs/scene";
  49952. /**
  49953. * Represents a set of particle systems working together to create a specific effect
  49954. */
  49955. export class ParticleSystemSet implements IDisposable {
  49956. private _emitterCreationOptions;
  49957. private _emitterNode;
  49958. /**
  49959. * Gets the particle system list
  49960. */
  49961. systems: IParticleSystem[];
  49962. /**
  49963. * Gets the emitter node used with this set
  49964. */
  49965. readonly emitterNode: Nullable<TransformNode>;
  49966. /**
  49967. * Creates a new emitter mesh as a sphere
  49968. * @param options defines the options used to create the sphere
  49969. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  49970. * @param scene defines the hosting scene
  49971. */
  49972. setEmitterAsSphere(options: {
  49973. diameter: number;
  49974. segments: number;
  49975. color: Color3;
  49976. }, renderingGroupId: number, scene: Scene): void;
  49977. /**
  49978. * Starts all particle systems of the set
  49979. * @param emitter defines an optional mesh to use as emitter for the particle systems
  49980. */
  49981. start(emitter?: AbstractMesh): void;
  49982. /**
  49983. * Release all associated resources
  49984. */
  49985. dispose(): void;
  49986. /**
  49987. * Serialize the set into a JSON compatible object
  49988. * @returns a JSON compatible representation of the set
  49989. */
  49990. serialize(): any;
  49991. /**
  49992. * Parse a new ParticleSystemSet from a serialized source
  49993. * @param data defines a JSON compatible representation of the set
  49994. * @param scene defines the hosting scene
  49995. * @param gpu defines if we want GPU particles or CPU particles
  49996. * @returns a new ParticleSystemSet
  49997. */
  49998. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  49999. }
  50000. }
  50001. declare module "babylonjs/Particles/particleHelper" {
  50002. import { Nullable } from "babylonjs/types";
  50003. import { Scene } from "babylonjs/scene";
  50004. import { Vector3 } from "babylonjs/Maths/math";
  50005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50006. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50007. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  50008. /**
  50009. * This class is made for on one-liner static method to help creating particle system set.
  50010. */
  50011. export class ParticleHelper {
  50012. /**
  50013. * Gets or sets base Assets URL
  50014. */
  50015. static BaseAssetsUrl: string;
  50016. /**
  50017. * Create a default particle system that you can tweak
  50018. * @param emitter defines the emitter to use
  50019. * @param capacity defines the system capacity (default is 500 particles)
  50020. * @param scene defines the hosting scene
  50021. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50022. * @returns the new Particle system
  50023. */
  50024. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50025. /**
  50026. * This is the main static method (one-liner) of this helper to create different particle systems
  50027. * @param type This string represents the type to the particle system to create
  50028. * @param scene The scene where the particle system should live
  50029. * @param gpu If the system will use gpu
  50030. * @returns the ParticleSystemSet created
  50031. */
  50032. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50033. /**
  50034. * Static function used to export a particle system to a ParticleSystemSet variable.
  50035. * Please note that the emitter shape is not exported
  50036. * @param systems defines the particle systems to export
  50037. * @returns the created particle system set
  50038. */
  50039. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50040. }
  50041. }
  50042. declare module "babylonjs/Particles/particleSystemComponent" {
  50043. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50044. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  50045. import "babylonjs/Shaders/particles.vertex";
  50046. module "babylonjs/Engines/engine" {
  50047. interface Engine {
  50048. /**
  50049. * Create an effect to use with particle systems.
  50050. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50051. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50052. * @param uniformsNames defines a list of attribute names
  50053. * @param samplers defines an array of string used to represent textures
  50054. * @param defines defines the string containing the defines to use to compile the shaders
  50055. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50056. * @param onCompiled defines a function to call when the effect creation is successful
  50057. * @param onError defines a function to call when the effect creation has failed
  50058. * @returns the new Effect
  50059. */
  50060. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50061. }
  50062. }
  50063. module "babylonjs/Meshes/mesh" {
  50064. interface Mesh {
  50065. /**
  50066. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50067. * @returns an array of IParticleSystem
  50068. */
  50069. getEmittedParticleSystems(): IParticleSystem[];
  50070. /**
  50071. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50072. * @returns an array of IParticleSystem
  50073. */
  50074. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50075. }
  50076. }
  50077. /**
  50078. * @hidden
  50079. */
  50080. export var _IDoNeedToBeInTheBuild: number;
  50081. }
  50082. declare module "babylonjs/Particles/index" {
  50083. export * from "babylonjs/Particles/baseParticleSystem";
  50084. export * from "babylonjs/Particles/EmitterTypes/index";
  50085. export * from "babylonjs/Particles/gpuParticleSystem";
  50086. export * from "babylonjs/Particles/IParticleSystem";
  50087. export * from "babylonjs/Particles/particle";
  50088. export * from "babylonjs/Particles/particleHelper";
  50089. export * from "babylonjs/Particles/particleSystem";
  50090. export * from "babylonjs/Particles/particleSystemComponent";
  50091. export * from "babylonjs/Particles/particleSystemSet";
  50092. export * from "babylonjs/Particles/solidParticle";
  50093. export * from "babylonjs/Particles/solidParticleSystem";
  50094. export * from "babylonjs/Particles/subEmitter";
  50095. }
  50096. declare module "babylonjs/Physics/physicsEngineComponent" {
  50097. import { Nullable } from "babylonjs/types";
  50098. import { Observable, Observer } from "babylonjs/Misc/observable";
  50099. import { Vector3 } from "babylonjs/Maths/math";
  50100. import { Mesh } from "babylonjs/Meshes/mesh";
  50101. import { ISceneComponent } from "babylonjs/sceneComponent";
  50102. import { Scene } from "babylonjs/scene";
  50103. import { Node } from "babylonjs/node";
  50104. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50105. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50106. module "babylonjs/scene" {
  50107. interface Scene {
  50108. /** @hidden (Backing field) */
  50109. _physicsEngine: Nullable<IPhysicsEngine>;
  50110. /**
  50111. * Gets the current physics engine
  50112. * @returns a IPhysicsEngine or null if none attached
  50113. */
  50114. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50115. /**
  50116. * Enables physics to the current scene
  50117. * @param gravity defines the scene's gravity for the physics engine
  50118. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50119. * @return a boolean indicating if the physics engine was initialized
  50120. */
  50121. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50122. /**
  50123. * Disables and disposes the physics engine associated with the scene
  50124. */
  50125. disablePhysicsEngine(): void;
  50126. /**
  50127. * Gets a boolean indicating if there is an active physics engine
  50128. * @returns a boolean indicating if there is an active physics engine
  50129. */
  50130. isPhysicsEnabled(): boolean;
  50131. /**
  50132. * Deletes a physics compound impostor
  50133. * @param compound defines the compound to delete
  50134. */
  50135. deleteCompoundImpostor(compound: any): void;
  50136. /**
  50137. * An event triggered when physic simulation is about to be run
  50138. */
  50139. onBeforePhysicsObservable: Observable<Scene>;
  50140. /**
  50141. * An event triggered when physic simulation has been done
  50142. */
  50143. onAfterPhysicsObservable: Observable<Scene>;
  50144. }
  50145. }
  50146. module "babylonjs/Meshes/abstractMesh" {
  50147. interface AbstractMesh {
  50148. /** @hidden */
  50149. _physicsImpostor: Nullable<PhysicsImpostor>;
  50150. /**
  50151. * Gets or sets impostor used for physic simulation
  50152. * @see http://doc.babylonjs.com/features/physics_engine
  50153. */
  50154. physicsImpostor: Nullable<PhysicsImpostor>;
  50155. /**
  50156. * Gets the current physics impostor
  50157. * @see http://doc.babylonjs.com/features/physics_engine
  50158. * @returns a physics impostor or null
  50159. */
  50160. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50161. /** Apply a physic impulse to the mesh
  50162. * @param force defines the force to apply
  50163. * @param contactPoint defines where to apply the force
  50164. * @returns the current mesh
  50165. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50166. */
  50167. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50168. /**
  50169. * Creates a physic joint between two meshes
  50170. * @param otherMesh defines the other mesh to use
  50171. * @param pivot1 defines the pivot to use on this mesh
  50172. * @param pivot2 defines the pivot to use on the other mesh
  50173. * @param options defines additional options (can be plugin dependent)
  50174. * @returns the current mesh
  50175. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50176. */
  50177. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50178. /** @hidden */
  50179. _disposePhysicsObserver: Nullable<Observer<Node>>;
  50180. }
  50181. }
  50182. /**
  50183. * Defines the physics engine scene component responsible to manage a physics engine
  50184. */
  50185. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50186. /**
  50187. * The component name helpful to identify the component in the list of scene components.
  50188. */
  50189. readonly name: string;
  50190. /**
  50191. * The scene the component belongs to.
  50192. */
  50193. scene: Scene;
  50194. /**
  50195. * Creates a new instance of the component for the given scene
  50196. * @param scene Defines the scene to register the component in
  50197. */
  50198. constructor(scene: Scene);
  50199. /**
  50200. * Registers the component in a given scene
  50201. */
  50202. register(): void;
  50203. /**
  50204. * Rebuilds the elements related to this component in case of
  50205. * context lost for instance.
  50206. */
  50207. rebuild(): void;
  50208. /**
  50209. * Disposes the component and the associated ressources
  50210. */
  50211. dispose(): void;
  50212. }
  50213. }
  50214. declare module "babylonjs/Physics/physicsHelper" {
  50215. import { Nullable } from "babylonjs/types";
  50216. import { Vector3 } from "babylonjs/Maths/math";
  50217. import { Mesh } from "babylonjs/Meshes/mesh";
  50218. import { Ray } from "babylonjs/Culling/ray";
  50219. import { Scene } from "babylonjs/scene";
  50220. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50221. /**
  50222. * A helper for physics simulations
  50223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50224. */
  50225. export class PhysicsHelper {
  50226. private _scene;
  50227. private _physicsEngine;
  50228. /**
  50229. * Initializes the Physics helper
  50230. * @param scene Babylon.js scene
  50231. */
  50232. constructor(scene: Scene);
  50233. /**
  50234. * Applies a radial explosion impulse
  50235. * @param origin the origin of the explosion
  50236. * @param radius the explosion radius
  50237. * @param strength the explosion strength
  50238. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50239. * @returns A physics radial explosion event, or null
  50240. */
  50241. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50242. /**
  50243. * Applies a radial explosion force
  50244. * @param origin the origin of the explosion
  50245. * @param radius the explosion radius
  50246. * @param strength the explosion strength
  50247. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50248. * @returns A physics radial explosion event, or null
  50249. */
  50250. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50251. /**
  50252. * Creates a gravitational field
  50253. * @param origin the origin of the explosion
  50254. * @param radius the explosion radius
  50255. * @param strength the explosion strength
  50256. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50257. * @returns A physics gravitational field event, or null
  50258. */
  50259. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50260. /**
  50261. * Creates a physics updraft event
  50262. * @param origin the origin of the updraft
  50263. * @param radius the radius of the updraft
  50264. * @param strength the strength of the updraft
  50265. * @param height the height of the updraft
  50266. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50267. * @returns A physics updraft event, or null
  50268. */
  50269. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50270. /**
  50271. * Creates a physics vortex event
  50272. * @param origin the of the vortex
  50273. * @param radius the radius of the vortex
  50274. * @param strength the strength of the vortex
  50275. * @param height the height of the vortex
  50276. * @returns a Physics vortex event, or null
  50277. * A physics vortex event or null
  50278. */
  50279. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  50280. }
  50281. /**
  50282. * Represents a physics radial explosion event
  50283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50284. */
  50285. export class PhysicsRadialExplosionEvent {
  50286. private _scene;
  50287. private _sphere;
  50288. private _sphereOptions;
  50289. private _rays;
  50290. private _dataFetched;
  50291. /**
  50292. * Initializes a radial explosioin event
  50293. * @param scene BabylonJS scene
  50294. */
  50295. constructor(scene: Scene);
  50296. /**
  50297. * Returns the data related to the radial explosion event (sphere & rays).
  50298. * @returns The radial explosion event data
  50299. */
  50300. getData(): PhysicsRadialExplosionEventData;
  50301. /**
  50302. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50303. * @param impostor A physics imposter
  50304. * @param origin the origin of the explosion
  50305. * @param radius the explosion radius
  50306. * @param strength the explosion strength
  50307. * @param falloff possible options: Constant & Linear
  50308. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  50309. */
  50310. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  50311. /**
  50312. * Disposes the sphere.
  50313. * @param force Specifies if the sphere should be disposed by force
  50314. */
  50315. dispose(force?: boolean): void;
  50316. /*** Helpers ***/
  50317. private _prepareSphere;
  50318. private _intersectsWithSphere;
  50319. }
  50320. /**
  50321. * Represents a gravitational field event
  50322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50323. */
  50324. export class PhysicsGravitationalFieldEvent {
  50325. private _physicsHelper;
  50326. private _scene;
  50327. private _origin;
  50328. private _radius;
  50329. private _strength;
  50330. private _falloff;
  50331. private _tickCallback;
  50332. private _sphere;
  50333. private _dataFetched;
  50334. /**
  50335. * Initializes the physics gravitational field event
  50336. * @param physicsHelper A physics helper
  50337. * @param scene BabylonJS scene
  50338. * @param origin The origin position of the gravitational field event
  50339. * @param radius The radius of the gravitational field event
  50340. * @param strength The strength of the gravitational field event
  50341. * @param falloff The falloff for the gravitational field event
  50342. */
  50343. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  50344. /**
  50345. * Returns the data related to the gravitational field event (sphere).
  50346. * @returns A gravitational field event
  50347. */
  50348. getData(): PhysicsGravitationalFieldEventData;
  50349. /**
  50350. * Enables the gravitational field.
  50351. */
  50352. enable(): void;
  50353. /**
  50354. * Disables the gravitational field.
  50355. */
  50356. disable(): void;
  50357. /**
  50358. * Disposes the sphere.
  50359. * @param force The force to dispose from the gravitational field event
  50360. */
  50361. dispose(force?: boolean): void;
  50362. private _tick;
  50363. }
  50364. /**
  50365. * Represents a physics updraft event
  50366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50367. */
  50368. export class PhysicsUpdraftEvent {
  50369. private _scene;
  50370. private _origin;
  50371. private _radius;
  50372. private _strength;
  50373. private _height;
  50374. private _updraftMode;
  50375. private _physicsEngine;
  50376. private _originTop;
  50377. private _originDirection;
  50378. private _tickCallback;
  50379. private _cylinder;
  50380. private _cylinderPosition;
  50381. private _dataFetched;
  50382. /**
  50383. * Initializes the physics updraft event
  50384. * @param _scene BabylonJS scene
  50385. * @param _origin The origin position of the updraft
  50386. * @param _radius The radius of the updraft
  50387. * @param _strength The strength of the updraft
  50388. * @param _height The height of the updraft
  50389. * @param _updraftMode The mode of the updraft
  50390. */
  50391. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  50392. /**
  50393. * Returns the data related to the updraft event (cylinder).
  50394. * @returns A physics updraft event
  50395. */
  50396. getData(): PhysicsUpdraftEventData;
  50397. /**
  50398. * Enables the updraft.
  50399. */
  50400. enable(): void;
  50401. /**
  50402. * Disables the cortex.
  50403. */
  50404. disable(): void;
  50405. /**
  50406. * Disposes the sphere.
  50407. * @param force Specifies if the updraft should be disposed by force
  50408. */
  50409. dispose(force?: boolean): void;
  50410. private getImpostorForceAndContactPoint;
  50411. private _tick;
  50412. /*** Helpers ***/
  50413. private _prepareCylinder;
  50414. private _intersectsWithCylinder;
  50415. }
  50416. /**
  50417. * Represents a physics vortex event
  50418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50419. */
  50420. export class PhysicsVortexEvent {
  50421. private _scene;
  50422. private _origin;
  50423. private _radius;
  50424. private _strength;
  50425. private _height;
  50426. private _physicsEngine;
  50427. private _originTop;
  50428. private _centripetalForceThreshold;
  50429. private _updraftMultiplier;
  50430. private _tickCallback;
  50431. private _cylinder;
  50432. private _cylinderPosition;
  50433. private _dataFetched;
  50434. /**
  50435. * Initializes the physics vortex event
  50436. * @param _scene The BabylonJS scene
  50437. * @param _origin The origin position of the vortex
  50438. * @param _radius The radius of the vortex
  50439. * @param _strength The strength of the vortex
  50440. * @param _height The height of the vortex
  50441. */
  50442. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  50443. /**
  50444. * Returns the data related to the vortex event (cylinder).
  50445. * @returns The physics vortex event data
  50446. */
  50447. getData(): PhysicsVortexEventData;
  50448. /**
  50449. * Enables the vortex.
  50450. */
  50451. enable(): void;
  50452. /**
  50453. * Disables the cortex.
  50454. */
  50455. disable(): void;
  50456. /**
  50457. * Disposes the sphere.
  50458. * @param force
  50459. */
  50460. dispose(force?: boolean): void;
  50461. private getImpostorForceAndContactPoint;
  50462. private _tick;
  50463. /*** Helpers ***/
  50464. private _prepareCylinder;
  50465. private _intersectsWithCylinder;
  50466. }
  50467. /**
  50468. * The strenght of the force in correspondence to the distance of the affected object
  50469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50470. */
  50471. export enum PhysicsRadialImpulseFalloff {
  50472. /** Defines that impulse is constant in strength across it's whole radius */
  50473. Constant = 0,
  50474. /** DEfines that impulse gets weaker if it's further from the origin */
  50475. Linear = 1
  50476. }
  50477. /**
  50478. * The strength of the force in correspondence to the distance of the affected object
  50479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50480. */
  50481. export enum PhysicsUpdraftMode {
  50482. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  50483. Center = 0,
  50484. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  50485. Perpendicular = 1
  50486. }
  50487. /**
  50488. * Interface for a physics force and contact point
  50489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50490. */
  50491. export interface PhysicsForceAndContactPoint {
  50492. /**
  50493. * The force applied at the contact point
  50494. */
  50495. force: Vector3;
  50496. /**
  50497. * The contact point
  50498. */
  50499. contactPoint: Vector3;
  50500. }
  50501. /**
  50502. * Interface for radial explosion event data
  50503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50504. */
  50505. export interface PhysicsRadialExplosionEventData {
  50506. /**
  50507. * A sphere used for the radial explosion event
  50508. */
  50509. sphere: Mesh;
  50510. /**
  50511. * An array of rays for the radial explosion event
  50512. */
  50513. rays: Array<Ray>;
  50514. }
  50515. /**
  50516. * Interface for gravitational field event data
  50517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50518. */
  50519. export interface PhysicsGravitationalFieldEventData {
  50520. /**
  50521. * A sphere mesh used for the gravitational field event
  50522. */
  50523. sphere: Mesh;
  50524. }
  50525. /**
  50526. * Interface for updraft event data
  50527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50528. */
  50529. export interface PhysicsUpdraftEventData {
  50530. /**
  50531. * A cylinder used for the updraft event
  50532. */
  50533. cylinder: Mesh;
  50534. }
  50535. /**
  50536. * Interface for vortex event data
  50537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50538. */
  50539. export interface PhysicsVortexEventData {
  50540. /**
  50541. * A cylinder used for the vortex event
  50542. */
  50543. cylinder: Mesh;
  50544. }
  50545. }
  50546. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50547. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50548. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50549. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50550. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50551. import { Nullable } from "babylonjs/types";
  50552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50553. /**
  50554. * AmmoJS Physics plugin
  50555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50556. * @see https://github.com/kripken/ammo.js/
  50557. */
  50558. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50559. private _useDeltaForWorldStep;
  50560. /**
  50561. * Reference to the Ammo library
  50562. */
  50563. bjsAMMO: any;
  50564. /**
  50565. * Created ammoJS world which physics bodies are added to
  50566. */
  50567. world: any;
  50568. /**
  50569. * Name of the plugin
  50570. */
  50571. name: string;
  50572. private _timeStep;
  50573. private _fixedTimeStep;
  50574. private _maxSteps;
  50575. private _tmpQuaternion;
  50576. private _tmpAmmoTransform;
  50577. private _tmpAmmoQuaternion;
  50578. private _tmpAmmoConcreteContactResultCallback;
  50579. private _collisionConfiguration;
  50580. private _dispatcher;
  50581. private _overlappingPairCache;
  50582. private _solver;
  50583. private _tmpAmmoVectorA;
  50584. private _tmpAmmoVectorB;
  50585. private _tmpAmmoVectorC;
  50586. private _tmpContactCallbackResult;
  50587. private static readonly DISABLE_COLLISION_FLAG;
  50588. private static readonly KINEMATIC_FLAG;
  50589. private static readonly DISABLE_DEACTIVATION_FLAG;
  50590. /**
  50591. * Initializes the ammoJS plugin
  50592. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50593. * @param ammoInjection can be used to inject your own ammo reference
  50594. */
  50595. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50596. /**
  50597. * Sets the gravity of the physics world (m/(s^2))
  50598. * @param gravity Gravity to set
  50599. */
  50600. setGravity(gravity: Vector3): void;
  50601. /**
  50602. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50603. * @param timeStep timestep to use in seconds
  50604. */
  50605. setTimeStep(timeStep: number): void;
  50606. /**
  50607. * 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)
  50608. * @param fixedTimeStep fixedTimeStep to use in seconds
  50609. */
  50610. setFixedTimeStep(fixedTimeStep: number): void;
  50611. /**
  50612. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50613. * @param maxSteps the maximum number of steps by the physics engine per frame
  50614. */
  50615. setMaxSteps(maxSteps: number): void;
  50616. /**
  50617. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50618. * @returns the current timestep in seconds
  50619. */
  50620. getTimeStep(): number;
  50621. private _isImpostorInContact;
  50622. private _isImpostorPairInContact;
  50623. private _stepSimulation;
  50624. /**
  50625. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50626. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50627. * After the step the babylon meshes are set to the position of the physics imposters
  50628. * @param delta amount of time to step forward
  50629. * @param impostors array of imposters to update before/after the step
  50630. */
  50631. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50632. /**
  50633. * Applies an implulse on the imposter
  50634. * @param impostor imposter to apply impulse
  50635. * @param force amount of force to be applied to the imposter
  50636. * @param contactPoint the location to apply the impulse on the imposter
  50637. */
  50638. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50639. /**
  50640. * Applies a force on the imposter
  50641. * @param impostor imposter to apply force
  50642. * @param force amount of force to be applied to the imposter
  50643. * @param contactPoint the location to apply the force on the imposter
  50644. */
  50645. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50646. /**
  50647. * Creates a physics body using the plugin
  50648. * @param impostor the imposter to create the physics body on
  50649. */
  50650. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50651. /**
  50652. * Removes the physics body from the imposter and disposes of the body's memory
  50653. * @param impostor imposter to remove the physics body from
  50654. */
  50655. removePhysicsBody(impostor: PhysicsImpostor): void;
  50656. /**
  50657. * Generates a joint
  50658. * @param impostorJoint the imposter joint to create the joint with
  50659. */
  50660. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50661. /**
  50662. * Removes a joint
  50663. * @param impostorJoint the imposter joint to remove the joint from
  50664. */
  50665. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50666. private _addMeshVerts;
  50667. private _createShape;
  50668. /**
  50669. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50670. * @param impostor imposter containing the physics body and babylon object
  50671. */
  50672. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50673. /**
  50674. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50675. * @param impostor imposter containing the physics body and babylon object
  50676. * @param newPosition new position
  50677. * @param newRotation new rotation
  50678. */
  50679. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50680. /**
  50681. * If this plugin is supported
  50682. * @returns true if its supported
  50683. */
  50684. isSupported(): boolean;
  50685. /**
  50686. * Sets the linear velocity of the physics body
  50687. * @param impostor imposter to set the velocity on
  50688. * @param velocity velocity to set
  50689. */
  50690. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50691. /**
  50692. * Sets the angular velocity of the physics body
  50693. * @param impostor imposter to set the velocity on
  50694. * @param velocity velocity to set
  50695. */
  50696. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50697. /**
  50698. * gets the linear velocity
  50699. * @param impostor imposter to get linear velocity from
  50700. * @returns linear velocity
  50701. */
  50702. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50703. /**
  50704. * gets the angular velocity
  50705. * @param impostor imposter to get angular velocity from
  50706. * @returns angular velocity
  50707. */
  50708. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50709. /**
  50710. * Sets the mass of physics body
  50711. * @param impostor imposter to set the mass on
  50712. * @param mass mass to set
  50713. */
  50714. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50715. /**
  50716. * Gets the mass of the physics body
  50717. * @param impostor imposter to get the mass from
  50718. * @returns mass
  50719. */
  50720. getBodyMass(impostor: PhysicsImpostor): number;
  50721. /**
  50722. * Gets friction of the impostor
  50723. * @param impostor impostor to get friction from
  50724. * @returns friction value
  50725. */
  50726. getBodyFriction(impostor: PhysicsImpostor): number;
  50727. /**
  50728. * Sets friction of the impostor
  50729. * @param impostor impostor to set friction on
  50730. * @param friction friction value
  50731. */
  50732. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50733. /**
  50734. * Gets restitution of the impostor
  50735. * @param impostor impostor to get restitution from
  50736. * @returns restitution value
  50737. */
  50738. getBodyRestitution(impostor: PhysicsImpostor): number;
  50739. /**
  50740. * Sets resitution of the impostor
  50741. * @param impostor impostor to set resitution on
  50742. * @param restitution resitution value
  50743. */
  50744. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50745. /**
  50746. * Sleeps the physics body and stops it from being active
  50747. * @param impostor impostor to sleep
  50748. */
  50749. sleepBody(impostor: PhysicsImpostor): void;
  50750. /**
  50751. * Activates the physics body
  50752. * @param impostor impostor to activate
  50753. */
  50754. wakeUpBody(impostor: PhysicsImpostor): void;
  50755. /**
  50756. * Updates the distance parameters of the joint
  50757. * @param joint joint to update
  50758. * @param maxDistance maximum distance of the joint
  50759. * @param minDistance minimum distance of the joint
  50760. */
  50761. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50762. /**
  50763. * Sets a motor on the joint
  50764. * @param joint joint to set motor on
  50765. * @param speed speed of the motor
  50766. * @param maxForce maximum force of the motor
  50767. * @param motorIndex index of the motor
  50768. */
  50769. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50770. /**
  50771. * Sets the motors limit
  50772. * @param joint joint to set limit on
  50773. * @param upperLimit upper limit
  50774. * @param lowerLimit lower limit
  50775. */
  50776. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50777. /**
  50778. * Syncs the position and rotation of a mesh with the impostor
  50779. * @param mesh mesh to sync
  50780. * @param impostor impostor to update the mesh with
  50781. */
  50782. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50783. /**
  50784. * Gets the radius of the impostor
  50785. * @param impostor impostor to get radius from
  50786. * @returns the radius
  50787. */
  50788. getRadius(impostor: PhysicsImpostor): number;
  50789. /**
  50790. * Gets the box size of the impostor
  50791. * @param impostor impostor to get box size from
  50792. * @param result the resulting box size
  50793. */
  50794. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50795. /**
  50796. * Disposes of the impostor
  50797. */
  50798. dispose(): void;
  50799. }
  50800. }
  50801. declare module "babylonjs/Physics/Plugins/index" {
  50802. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  50803. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  50804. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  50805. }
  50806. declare module "babylonjs/Physics/index" {
  50807. export * from "babylonjs/Physics/IPhysicsEngine";
  50808. export * from "babylonjs/Physics/physicsEngine";
  50809. export * from "babylonjs/Physics/physicsEngineComponent";
  50810. export * from "babylonjs/Physics/physicsHelper";
  50811. export * from "babylonjs/Physics/physicsImpostor";
  50812. export * from "babylonjs/Physics/physicsJoint";
  50813. export * from "babylonjs/Physics/Plugins/index";
  50814. }
  50815. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  50816. /** @hidden */
  50817. export var blackAndWhitePixelShader: {
  50818. name: string;
  50819. shader: string;
  50820. };
  50821. }
  50822. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  50823. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50824. import { Camera } from "babylonjs/Cameras/camera";
  50825. import { Engine } from "babylonjs/Engines/engine";
  50826. import "babylonjs/Shaders/blackAndWhite.fragment";
  50827. /**
  50828. * Post process used to render in black and white
  50829. */
  50830. export class BlackAndWhitePostProcess extends PostProcess {
  50831. /**
  50832. * Linear about to convert he result to black and white (default: 1)
  50833. */
  50834. degree: number;
  50835. /**
  50836. * Creates a black and white post process
  50837. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  50838. * @param name The name of the effect.
  50839. * @param options The required width/height ratio to downsize to before computing the render pass.
  50840. * @param camera The camera to apply the render pass to.
  50841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50842. * @param engine The engine which the post process will be applied. (default: current engine)
  50843. * @param reusable If the post process can be reused on the same frame. (default: false)
  50844. */
  50845. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50846. }
  50847. }
  50848. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  50849. import { Nullable } from "babylonjs/types";
  50850. import { Camera } from "babylonjs/Cameras/camera";
  50851. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50852. import { Engine } from "babylonjs/Engines/engine";
  50853. /**
  50854. * This represents a set of one or more post processes in Babylon.
  50855. * A post process can be used to apply a shader to a texture after it is rendered.
  50856. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50857. */
  50858. export class PostProcessRenderEffect {
  50859. private _postProcesses;
  50860. private _getPostProcesses;
  50861. private _singleInstance;
  50862. private _cameras;
  50863. private _indicesForCamera;
  50864. /**
  50865. * Name of the effect
  50866. * @hidden
  50867. */
  50868. _name: string;
  50869. /**
  50870. * Instantiates a post process render effect.
  50871. * A post process can be used to apply a shader to a texture after it is rendered.
  50872. * @param engine The engine the effect is tied to
  50873. * @param name The name of the effect
  50874. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  50875. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  50876. */
  50877. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  50878. /**
  50879. * Checks if all the post processes in the effect are supported.
  50880. */
  50881. readonly isSupported: boolean;
  50882. /**
  50883. * Updates the current state of the effect
  50884. * @hidden
  50885. */
  50886. _update(): void;
  50887. /**
  50888. * Attaches the effect on cameras
  50889. * @param cameras The camera to attach to.
  50890. * @hidden
  50891. */
  50892. _attachCameras(cameras: Camera): void;
  50893. /**
  50894. * Attaches the effect on cameras
  50895. * @param cameras The camera to attach to.
  50896. * @hidden
  50897. */
  50898. _attachCameras(cameras: Camera[]): void;
  50899. /**
  50900. * Detatches the effect on cameras
  50901. * @param cameras The camera to detatch from.
  50902. * @hidden
  50903. */
  50904. _detachCameras(cameras: Camera): void;
  50905. /**
  50906. * Detatches the effect on cameras
  50907. * @param cameras The camera to detatch from.
  50908. * @hidden
  50909. */
  50910. _detachCameras(cameras: Camera[]): void;
  50911. /**
  50912. * Enables the effect on given cameras
  50913. * @param cameras The camera to enable.
  50914. * @hidden
  50915. */
  50916. _enable(cameras: Camera): void;
  50917. /**
  50918. * Enables the effect on given cameras
  50919. * @param cameras The camera to enable.
  50920. * @hidden
  50921. */
  50922. _enable(cameras: Nullable<Camera[]>): void;
  50923. /**
  50924. * Disables the effect on the given cameras
  50925. * @param cameras The camera to disable.
  50926. * @hidden
  50927. */
  50928. _disable(cameras: Camera): void;
  50929. /**
  50930. * Disables the effect on the given cameras
  50931. * @param cameras The camera to disable.
  50932. * @hidden
  50933. */
  50934. _disable(cameras: Nullable<Camera[]>): void;
  50935. /**
  50936. * Gets a list of the post processes contained in the effect.
  50937. * @param camera The camera to get the post processes on.
  50938. * @returns The list of the post processes in the effect.
  50939. */
  50940. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  50941. }
  50942. }
  50943. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  50944. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50945. /** @hidden */
  50946. export var extractHighlightsPixelShader: {
  50947. name: string;
  50948. shader: string;
  50949. };
  50950. }
  50951. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  50952. import { Nullable } from "babylonjs/types";
  50953. import { Camera } from "babylonjs/Cameras/camera";
  50954. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50955. import { Engine } from "babylonjs/Engines/engine";
  50956. import "babylonjs/Shaders/extractHighlights.fragment";
  50957. /**
  50958. * 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.
  50959. */
  50960. export class ExtractHighlightsPostProcess extends PostProcess {
  50961. /**
  50962. * The luminance threshold, pixels below this value will be set to black.
  50963. */
  50964. threshold: number;
  50965. /** @hidden */
  50966. _exposure: number;
  50967. /**
  50968. * Post process which has the input texture to be used when performing highlight extraction
  50969. * @hidden
  50970. */
  50971. _inputPostProcess: Nullable<PostProcess>;
  50972. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50973. }
  50974. }
  50975. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  50976. /** @hidden */
  50977. export var bloomMergePixelShader: {
  50978. name: string;
  50979. shader: string;
  50980. };
  50981. }
  50982. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  50983. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50984. import { Nullable } from "babylonjs/types";
  50985. import { Engine } from "babylonjs/Engines/engine";
  50986. import { Camera } from "babylonjs/Cameras/camera";
  50987. import "babylonjs/Shaders/bloomMerge.fragment";
  50988. /**
  50989. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  50990. */
  50991. export class BloomMergePostProcess extends PostProcess {
  50992. /** Weight of the bloom to be added to the original input. */
  50993. weight: number;
  50994. /**
  50995. * Creates a new instance of @see BloomMergePostProcess
  50996. * @param name The name of the effect.
  50997. * @param originalFromInput Post process which's input will be used for the merge.
  50998. * @param blurred Blurred highlights post process which's output will be used.
  50999. * @param weight Weight of the bloom to be added to the original input.
  51000. * @param options The required width/height ratio to downsize to before computing the render pass.
  51001. * @param camera The camera to apply the render pass to.
  51002. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51003. * @param engine The engine which the post process will be applied. (default: current engine)
  51004. * @param reusable If the post process can be reused on the same frame. (default: false)
  51005. * @param textureType Type of textures used when performing the post process. (default: 0)
  51006. * @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)
  51007. */
  51008. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51009. /** Weight of the bloom to be added to the original input. */
  51010. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51011. }
  51012. }
  51013. declare module "babylonjs/PostProcesses/bloomEffect" {
  51014. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51015. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51016. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  51017. import { Camera } from "babylonjs/Cameras/camera";
  51018. import { Scene } from "babylonjs/scene";
  51019. /**
  51020. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51021. */
  51022. export class BloomEffect extends PostProcessRenderEffect {
  51023. private bloomScale;
  51024. /**
  51025. * @hidden Internal
  51026. */
  51027. _effects: Array<PostProcess>;
  51028. /**
  51029. * @hidden Internal
  51030. */
  51031. _downscale: ExtractHighlightsPostProcess;
  51032. private _blurX;
  51033. private _blurY;
  51034. private _merge;
  51035. /**
  51036. * The luminance threshold to find bright areas of the image to bloom.
  51037. */
  51038. threshold: number;
  51039. /**
  51040. * The strength of the bloom.
  51041. */
  51042. weight: number;
  51043. /**
  51044. * Specifies the size of the bloom blur kernel, relative to the final output size
  51045. */
  51046. kernel: number;
  51047. /**
  51048. * Creates a new instance of @see BloomEffect
  51049. * @param scene The scene the effect belongs to.
  51050. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51051. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51052. * @param bloomWeight The the strength of bloom.
  51053. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51054. * @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)
  51055. */
  51056. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51057. /**
  51058. * Disposes each of the internal effects for a given camera.
  51059. * @param camera The camera to dispose the effect on.
  51060. */
  51061. disposeEffects(camera: Camera): void;
  51062. /**
  51063. * @hidden Internal
  51064. */
  51065. _updateEffects(): void;
  51066. /**
  51067. * Internal
  51068. * @returns if all the contained post processes are ready.
  51069. * @hidden
  51070. */
  51071. _isReady(): boolean;
  51072. }
  51073. }
  51074. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  51075. /** @hidden */
  51076. export var chromaticAberrationPixelShader: {
  51077. name: string;
  51078. shader: string;
  51079. };
  51080. }
  51081. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  51082. import { Vector2 } from "babylonjs/Maths/math";
  51083. import { Nullable } from "babylonjs/types";
  51084. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51085. import { Camera } from "babylonjs/Cameras/camera";
  51086. import { Engine } from "babylonjs/Engines/engine";
  51087. import "babylonjs/Shaders/chromaticAberration.fragment";
  51088. /**
  51089. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51090. */
  51091. export class ChromaticAberrationPostProcess extends PostProcess {
  51092. /**
  51093. * The amount of seperation of rgb channels (default: 30)
  51094. */
  51095. aberrationAmount: number;
  51096. /**
  51097. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51098. */
  51099. radialIntensity: number;
  51100. /**
  51101. * 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))
  51102. */
  51103. direction: Vector2;
  51104. /**
  51105. * 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))
  51106. */
  51107. centerPosition: Vector2;
  51108. /**
  51109. * Creates a new instance ChromaticAberrationPostProcess
  51110. * @param name The name of the effect.
  51111. * @param screenWidth The width of the screen to apply the effect on.
  51112. * @param screenHeight The height of the screen to apply the effect on.
  51113. * @param options The required width/height ratio to downsize to before computing the render pass.
  51114. * @param camera The camera to apply the render pass to.
  51115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51116. * @param engine The engine which the post process will be applied. (default: current engine)
  51117. * @param reusable If the post process can be reused on the same frame. (default: false)
  51118. * @param textureType Type of textures used when performing the post process. (default: 0)
  51119. * @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)
  51120. */
  51121. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51122. }
  51123. }
  51124. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  51125. /** @hidden */
  51126. export var circleOfConfusionPixelShader: {
  51127. name: string;
  51128. shader: string;
  51129. };
  51130. }
  51131. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  51132. import { Nullable } from "babylonjs/types";
  51133. import { Engine } from "babylonjs/Engines/engine";
  51134. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51135. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51136. import { Camera } from "babylonjs/Cameras/camera";
  51137. import "babylonjs/Shaders/circleOfConfusion.fragment";
  51138. /**
  51139. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51140. */
  51141. export class CircleOfConfusionPostProcess extends PostProcess {
  51142. /**
  51143. * 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.
  51144. */
  51145. lensSize: number;
  51146. /**
  51147. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51148. */
  51149. fStop: number;
  51150. /**
  51151. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51152. */
  51153. focusDistance: number;
  51154. /**
  51155. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51156. */
  51157. focalLength: number;
  51158. private _depthTexture;
  51159. /**
  51160. * Creates a new instance CircleOfConfusionPostProcess
  51161. * @param name The name of the effect.
  51162. * @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.
  51163. * @param options The required width/height ratio to downsize to before computing the render pass.
  51164. * @param camera The camera to apply the render pass to.
  51165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51166. * @param engine The engine which the post process will be applied. (default: current engine)
  51167. * @param reusable If the post process can be reused on the same frame. (default: false)
  51168. * @param textureType Type of textures used when performing the post process. (default: 0)
  51169. * @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)
  51170. */
  51171. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51172. /**
  51173. * 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.
  51174. */
  51175. depthTexture: RenderTargetTexture;
  51176. }
  51177. }
  51178. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  51179. /** @hidden */
  51180. export var colorCorrectionPixelShader: {
  51181. name: string;
  51182. shader: string;
  51183. };
  51184. }
  51185. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  51186. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51187. import { Engine } from "babylonjs/Engines/engine";
  51188. import { Camera } from "babylonjs/Cameras/camera";
  51189. import "babylonjs/Shaders/colorCorrection.fragment";
  51190. /**
  51191. *
  51192. * This post-process allows the modification of rendered colors by using
  51193. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51194. *
  51195. * The object needs to be provided an url to a texture containing the color
  51196. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51197. * Use an image editing software to tweak the LUT to match your needs.
  51198. *
  51199. * For an example of a color LUT, see here:
  51200. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51201. * For explanations on color grading, see here:
  51202. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51203. *
  51204. */
  51205. export class ColorCorrectionPostProcess extends PostProcess {
  51206. private _colorTableTexture;
  51207. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51208. }
  51209. }
  51210. declare module "babylonjs/Shaders/convolution.fragment" {
  51211. /** @hidden */
  51212. export var convolutionPixelShader: {
  51213. name: string;
  51214. shader: string;
  51215. };
  51216. }
  51217. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  51218. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51219. import { Nullable } from "babylonjs/types";
  51220. import { Camera } from "babylonjs/Cameras/camera";
  51221. import { Engine } from "babylonjs/Engines/engine";
  51222. import "babylonjs/Shaders/convolution.fragment";
  51223. /**
  51224. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51225. * input texture to perform effects such as edge detection or sharpening
  51226. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51227. */
  51228. export class ConvolutionPostProcess extends PostProcess {
  51229. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51230. kernel: number[];
  51231. /**
  51232. * Creates a new instance ConvolutionPostProcess
  51233. * @param name The name of the effect.
  51234. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51235. * @param options The required width/height ratio to downsize to before computing the render pass.
  51236. * @param camera The camera to apply the render pass to.
  51237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51238. * @param engine The engine which the post process will be applied. (default: current engine)
  51239. * @param reusable If the post process can be reused on the same frame. (default: false)
  51240. * @param textureType Type of textures used when performing the post process. (default: 0)
  51241. */
  51242. constructor(name: string,
  51243. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51244. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51245. /**
  51246. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51247. */
  51248. static EdgeDetect0Kernel: number[];
  51249. /**
  51250. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51251. */
  51252. static EdgeDetect1Kernel: number[];
  51253. /**
  51254. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51255. */
  51256. static EdgeDetect2Kernel: number[];
  51257. /**
  51258. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51259. */
  51260. static SharpenKernel: number[];
  51261. /**
  51262. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51263. */
  51264. static EmbossKernel: number[];
  51265. /**
  51266. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51267. */
  51268. static GaussianKernel: number[];
  51269. }
  51270. }
  51271. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  51272. import { Nullable } from "babylonjs/types";
  51273. import { Vector2 } from "babylonjs/Maths/math";
  51274. import { Camera } from "babylonjs/Cameras/camera";
  51275. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51276. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  51277. import { Engine } from "babylonjs/Engines/engine";
  51278. import { Scene } from "babylonjs/scene";
  51279. /**
  51280. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51281. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51282. * based on samples that have a large difference in distance than the center pixel.
  51283. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51284. */
  51285. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51286. direction: Vector2;
  51287. /**
  51288. * Creates a new instance CircleOfConfusionPostProcess
  51289. * @param name The name of the effect.
  51290. * @param scene The scene the effect belongs to.
  51291. * @param direction The direction the blur should be applied.
  51292. * @param kernel The size of the kernel used to blur.
  51293. * @param options The required width/height ratio to downsize to before computing the render pass.
  51294. * @param camera The camera to apply the render pass to.
  51295. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51296. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51298. * @param engine The engine which the post process will be applied. (default: current engine)
  51299. * @param reusable If the post process can be reused on the same frame. (default: false)
  51300. * @param textureType Type of textures used when performing the post process. (default: 0)
  51301. * @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)
  51302. */
  51303. 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);
  51304. }
  51305. }
  51306. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  51307. /** @hidden */
  51308. export var depthOfFieldMergePixelShader: {
  51309. name: string;
  51310. shader: string;
  51311. };
  51312. }
  51313. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  51314. import { Nullable } from "babylonjs/types";
  51315. import { Camera } from "babylonjs/Cameras/camera";
  51316. import { Effect } from "babylonjs/Materials/effect";
  51317. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51318. import { Engine } from "babylonjs/Engines/engine";
  51319. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  51320. /**
  51321. * Options to be set when merging outputs from the default pipeline.
  51322. */
  51323. export class DepthOfFieldMergePostProcessOptions {
  51324. /**
  51325. * The original image to merge on top of
  51326. */
  51327. originalFromInput: PostProcess;
  51328. /**
  51329. * Parameters to perform the merge of the depth of field effect
  51330. */
  51331. depthOfField?: {
  51332. circleOfConfusion: PostProcess;
  51333. blurSteps: Array<PostProcess>;
  51334. };
  51335. /**
  51336. * Parameters to perform the merge of bloom effect
  51337. */
  51338. bloom?: {
  51339. blurred: PostProcess;
  51340. weight: number;
  51341. };
  51342. }
  51343. /**
  51344. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51345. */
  51346. export class DepthOfFieldMergePostProcess extends PostProcess {
  51347. private blurSteps;
  51348. /**
  51349. * Creates a new instance of DepthOfFieldMergePostProcess
  51350. * @param name The name of the effect.
  51351. * @param originalFromInput Post process which's input will be used for the merge.
  51352. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51353. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51354. * @param options The required width/height ratio to downsize to before computing the render pass.
  51355. * @param camera The camera to apply the render pass to.
  51356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51357. * @param engine The engine which the post process will be applied. (default: current engine)
  51358. * @param reusable If the post process can be reused on the same frame. (default: false)
  51359. * @param textureType Type of textures used when performing the post process. (default: 0)
  51360. * @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)
  51361. */
  51362. 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);
  51363. /**
  51364. * Updates the effect with the current post process compile time values and recompiles the shader.
  51365. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51366. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51367. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51368. * @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
  51369. * @param onCompiled Called when the shader has been compiled.
  51370. * @param onError Called if there is an error when compiling a shader.
  51371. */
  51372. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51373. }
  51374. }
  51375. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  51376. import { Nullable } from "babylonjs/types";
  51377. import { Camera } from "babylonjs/Cameras/camera";
  51378. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51379. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51380. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51381. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  51382. import { Scene } from "babylonjs/scene";
  51383. /**
  51384. * Specifies the level of max blur that should be applied when using the depth of field effect
  51385. */
  51386. export enum DepthOfFieldEffectBlurLevel {
  51387. /**
  51388. * Subtle blur
  51389. */
  51390. Low = 0,
  51391. /**
  51392. * Medium blur
  51393. */
  51394. Medium = 1,
  51395. /**
  51396. * Large blur
  51397. */
  51398. High = 2
  51399. }
  51400. /**
  51401. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51402. */
  51403. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51404. private _circleOfConfusion;
  51405. /**
  51406. * @hidden Internal, blurs from high to low
  51407. */
  51408. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51409. private _depthOfFieldBlurY;
  51410. private _dofMerge;
  51411. /**
  51412. * @hidden Internal post processes in depth of field effect
  51413. */
  51414. _effects: Array<PostProcess>;
  51415. /**
  51416. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51417. */
  51418. focalLength: number;
  51419. /**
  51420. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51421. */
  51422. fStop: number;
  51423. /**
  51424. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51425. */
  51426. focusDistance: number;
  51427. /**
  51428. * 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.
  51429. */
  51430. lensSize: number;
  51431. /**
  51432. * Creates a new instance DepthOfFieldEffect
  51433. * @param scene The scene the effect belongs to.
  51434. * @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.
  51435. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51436. * @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)
  51437. */
  51438. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  51439. /**
  51440. * 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.
  51441. */
  51442. depthTexture: RenderTargetTexture;
  51443. /**
  51444. * Disposes each of the internal effects for a given camera.
  51445. * @param camera The camera to dispose the effect on.
  51446. */
  51447. disposeEffects(camera: Camera): void;
  51448. /**
  51449. * @hidden Internal
  51450. */
  51451. _updateEffects(): void;
  51452. /**
  51453. * Internal
  51454. * @returns if all the contained post processes are ready.
  51455. * @hidden
  51456. */
  51457. _isReady(): boolean;
  51458. }
  51459. }
  51460. declare module "babylonjs/Shaders/displayPass.fragment" {
  51461. /** @hidden */
  51462. export var displayPassPixelShader: {
  51463. name: string;
  51464. shader: string;
  51465. };
  51466. }
  51467. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  51468. import { Nullable } from "babylonjs/types";
  51469. import { Camera } from "babylonjs/Cameras/camera";
  51470. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51471. import { Engine } from "babylonjs/Engines/engine";
  51472. import "babylonjs/Shaders/displayPass.fragment";
  51473. /**
  51474. * DisplayPassPostProcess which produces an output the same as it's input
  51475. */
  51476. export class DisplayPassPostProcess extends PostProcess {
  51477. /**
  51478. * Creates the DisplayPassPostProcess
  51479. * @param name The name of the effect.
  51480. * @param options The required width/height ratio to downsize to before computing the render pass.
  51481. * @param camera The camera to apply the render pass to.
  51482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51483. * @param engine The engine which the post process will be applied. (default: current engine)
  51484. * @param reusable If the post process can be reused on the same frame. (default: false)
  51485. */
  51486. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51487. }
  51488. }
  51489. declare module "babylonjs/Shaders/filter.fragment" {
  51490. /** @hidden */
  51491. export var filterPixelShader: {
  51492. name: string;
  51493. shader: string;
  51494. };
  51495. }
  51496. declare module "babylonjs/PostProcesses/filterPostProcess" {
  51497. import { Nullable } from "babylonjs/types";
  51498. import { Matrix } from "babylonjs/Maths/math";
  51499. import { Camera } from "babylonjs/Cameras/camera";
  51500. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51501. import { Engine } from "babylonjs/Engines/engine";
  51502. import "babylonjs/Shaders/filter.fragment";
  51503. /**
  51504. * Applies a kernel filter to the image
  51505. */
  51506. export class FilterPostProcess extends PostProcess {
  51507. /** The matrix to be applied to the image */
  51508. kernelMatrix: Matrix;
  51509. /**
  51510. *
  51511. * @param name The name of the effect.
  51512. * @param kernelMatrix The matrix to be applied to the image
  51513. * @param options The required width/height ratio to downsize to before computing the render pass.
  51514. * @param camera The camera to apply the render pass to.
  51515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51516. * @param engine The engine which the post process will be applied. (default: current engine)
  51517. * @param reusable If the post process can be reused on the same frame. (default: false)
  51518. */
  51519. constructor(name: string,
  51520. /** The matrix to be applied to the image */
  51521. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51522. }
  51523. }
  51524. declare module "babylonjs/Shaders/fxaa.fragment" {
  51525. /** @hidden */
  51526. export var fxaaPixelShader: {
  51527. name: string;
  51528. shader: string;
  51529. };
  51530. }
  51531. declare module "babylonjs/Shaders/fxaa.vertex" {
  51532. /** @hidden */
  51533. export var fxaaVertexShader: {
  51534. name: string;
  51535. shader: string;
  51536. };
  51537. }
  51538. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  51539. import { Nullable } from "babylonjs/types";
  51540. import { Camera } from "babylonjs/Cameras/camera";
  51541. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51542. import { Engine } from "babylonjs/Engines/engine";
  51543. import "babylonjs/Shaders/fxaa.fragment";
  51544. import "babylonjs/Shaders/fxaa.vertex";
  51545. /**
  51546. * Fxaa post process
  51547. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  51548. */
  51549. export class FxaaPostProcess extends PostProcess {
  51550. /** @hidden */
  51551. texelWidth: number;
  51552. /** @hidden */
  51553. texelHeight: number;
  51554. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51555. private _getDefines;
  51556. }
  51557. }
  51558. declare module "babylonjs/Shaders/grain.fragment" {
  51559. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51560. /** @hidden */
  51561. export var grainPixelShader: {
  51562. name: string;
  51563. shader: string;
  51564. };
  51565. }
  51566. declare module "babylonjs/PostProcesses/grainPostProcess" {
  51567. import { Nullable } from "babylonjs/types";
  51568. import { Camera } from "babylonjs/Cameras/camera";
  51569. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51570. import { Engine } from "babylonjs/Engines/engine";
  51571. import "babylonjs/Shaders/grain.fragment";
  51572. /**
  51573. * The GrainPostProcess adds noise to the image at mid luminance levels
  51574. */
  51575. export class GrainPostProcess extends PostProcess {
  51576. /**
  51577. * The intensity of the grain added (default: 30)
  51578. */
  51579. intensity: number;
  51580. /**
  51581. * If the grain should be randomized on every frame
  51582. */
  51583. animated: boolean;
  51584. /**
  51585. * Creates a new instance of @see GrainPostProcess
  51586. * @param name The name of the effect.
  51587. * @param options The required width/height ratio to downsize to before computing the render pass.
  51588. * @param camera The camera to apply the render pass to.
  51589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51590. * @param engine The engine which the post process will be applied. (default: current engine)
  51591. * @param reusable If the post process can be reused on the same frame. (default: false)
  51592. * @param textureType Type of textures used when performing the post process. (default: 0)
  51593. * @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)
  51594. */
  51595. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51596. }
  51597. }
  51598. declare module "babylonjs/Shaders/highlights.fragment" {
  51599. /** @hidden */
  51600. export var highlightsPixelShader: {
  51601. name: string;
  51602. shader: string;
  51603. };
  51604. }
  51605. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  51606. import { Nullable } from "babylonjs/types";
  51607. import { Camera } from "babylonjs/Cameras/camera";
  51608. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51609. import { Engine } from "babylonjs/Engines/engine";
  51610. import "babylonjs/Shaders/highlights.fragment";
  51611. /**
  51612. * Extracts highlights from the image
  51613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51614. */
  51615. export class HighlightsPostProcess extends PostProcess {
  51616. /**
  51617. * Extracts highlights from the image
  51618. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51619. * @param name The name of the effect.
  51620. * @param options The required width/height ratio to downsize to before computing the render pass.
  51621. * @param camera The camera to apply the render pass to.
  51622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51623. * @param engine The engine which the post process will be applied. (default: current engine)
  51624. * @param reusable If the post process can be reused on the same frame. (default: false)
  51625. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  51626. */
  51627. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51628. }
  51629. }
  51630. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  51631. /** @hidden */
  51632. export var mrtFragmentDeclaration: {
  51633. name: string;
  51634. shader: string;
  51635. };
  51636. }
  51637. declare module "babylonjs/Shaders/geometry.fragment" {
  51638. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  51639. /** @hidden */
  51640. export var geometryPixelShader: {
  51641. name: string;
  51642. shader: string;
  51643. };
  51644. }
  51645. declare module "babylonjs/Shaders/geometry.vertex" {
  51646. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51647. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51648. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51649. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51650. /** @hidden */
  51651. export var geometryVertexShader: {
  51652. name: string;
  51653. shader: string;
  51654. };
  51655. }
  51656. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  51657. import { Matrix } from "babylonjs/Maths/math";
  51658. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51659. import { Mesh } from "babylonjs/Meshes/mesh";
  51660. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  51661. import { Effect } from "babylonjs/Materials/effect";
  51662. import { Scene } from "babylonjs/scene";
  51663. import "babylonjs/Shaders/geometry.fragment";
  51664. import "babylonjs/Shaders/geometry.vertex";
  51665. /**
  51666. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  51667. */
  51668. export class GeometryBufferRenderer {
  51669. /**
  51670. * Constant used to retrieve the position texture index in the G-Buffer textures array
  51671. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  51672. */
  51673. static readonly POSITION_TEXTURE_TYPE: number;
  51674. /**
  51675. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  51676. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  51677. */
  51678. static readonly VELOCITY_TEXTURE_TYPE: number;
  51679. /**
  51680. * Dictionary used to store the previous transformation matrices of each rendered mesh
  51681. * in order to compute objects velocities when enableVelocity is set to "true"
  51682. * @hidden
  51683. */
  51684. _previousTransformationMatrices: {
  51685. [index: number]: Matrix;
  51686. };
  51687. private _scene;
  51688. private _multiRenderTarget;
  51689. private _ratio;
  51690. private _enablePosition;
  51691. private _enableVelocity;
  51692. private _positionIndex;
  51693. private _velocityIndex;
  51694. protected _effect: Effect;
  51695. protected _cachedDefines: string;
  51696. /**
  51697. * Set the render list (meshes to be rendered) used in the G buffer.
  51698. */
  51699. renderList: Mesh[];
  51700. /**
  51701. * Gets wether or not G buffer are supported by the running hardware.
  51702. * This requires draw buffer supports
  51703. */
  51704. readonly isSupported: boolean;
  51705. /**
  51706. * Returns the index of the given texture type in the G-Buffer textures array
  51707. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  51708. * @returns the index of the given texture type in the G-Buffer textures array
  51709. */
  51710. getTextureIndex(textureType: number): number;
  51711. /**
  51712. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  51713. */
  51714. /**
  51715. * Sets whether or not objects positions are enabled for the G buffer.
  51716. */
  51717. enablePosition: boolean;
  51718. /**
  51719. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  51720. */
  51721. /**
  51722. * Sets wether or not objects velocities are enabled for the G buffer.
  51723. */
  51724. enableVelocity: boolean;
  51725. /**
  51726. * Gets the scene associated with the buffer.
  51727. */
  51728. readonly scene: Scene;
  51729. /**
  51730. * Gets the ratio used by the buffer during its creation.
  51731. * How big is the buffer related to the main canvas.
  51732. */
  51733. readonly ratio: number;
  51734. /** @hidden */
  51735. static _SceneComponentInitialization: (scene: Scene) => void;
  51736. /**
  51737. * Creates a new G Buffer for the scene
  51738. * @param scene The scene the buffer belongs to
  51739. * @param ratio How big is the buffer related to the main canvas.
  51740. */
  51741. constructor(scene: Scene, ratio?: number);
  51742. /**
  51743. * Checks wether everything is ready to render a submesh to the G buffer.
  51744. * @param subMesh the submesh to check readiness for
  51745. * @param useInstances is the mesh drawn using instance or not
  51746. * @returns true if ready otherwise false
  51747. */
  51748. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51749. /**
  51750. * Gets the current underlying G Buffer.
  51751. * @returns the buffer
  51752. */
  51753. getGBuffer(): MultiRenderTarget;
  51754. /**
  51755. * Gets the number of samples used to render the buffer (anti aliasing).
  51756. */
  51757. /**
  51758. * Sets the number of samples used to render the buffer (anti aliasing).
  51759. */
  51760. samples: number;
  51761. /**
  51762. * Disposes the renderer and frees up associated resources.
  51763. */
  51764. dispose(): void;
  51765. protected _createRenderTargets(): void;
  51766. }
  51767. }
  51768. declare module "babylonjs/Shaders/motionBlur.fragment" {
  51769. /** @hidden */
  51770. export var motionBlurPixelShader: {
  51771. name: string;
  51772. shader: string;
  51773. };
  51774. }
  51775. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  51776. import { Nullable } from "babylonjs/types";
  51777. import { Camera } from "babylonjs/Cameras/camera";
  51778. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51779. import { Scene } from "babylonjs/scene";
  51780. import "babylonjs/Shaders/motionBlur.fragment";
  51781. import { Engine } from "babylonjs/Engines/engine";
  51782. /**
  51783. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  51784. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  51785. * As an example, all you have to do is to create the post-process:
  51786. * var mb = new BABYLON.MotionBlurPostProcess(
  51787. * 'mb', // The name of the effect.
  51788. * scene, // The scene containing the objects to blur according to their velocity.
  51789. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  51790. * camera // The camera to apply the render pass to.
  51791. * );
  51792. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  51793. */
  51794. export class MotionBlurPostProcess extends PostProcess {
  51795. /**
  51796. * Defines how much the image is blurred by the movement. Default value is equal to 1
  51797. */
  51798. motionStrength: number;
  51799. /**
  51800. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  51801. */
  51802. /**
  51803. * Sets the number of iterations to be used for motion blur quality
  51804. */
  51805. motionBlurSamples: number;
  51806. private _motionBlurSamples;
  51807. private _geometryBufferRenderer;
  51808. /**
  51809. * Creates a new instance MotionBlurPostProcess
  51810. * @param name The name of the effect.
  51811. * @param scene The scene containing the objects to blur according to their velocity.
  51812. * @param options The required width/height ratio to downsize to before computing the render pass.
  51813. * @param camera The camera to apply the render pass to.
  51814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51815. * @param engine The engine which the post process will be applied. (default: current engine)
  51816. * @param reusable If the post process can be reused on the same frame. (default: false)
  51817. * @param textureType Type of textures used when performing the post process. (default: 0)
  51818. * @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)
  51819. */
  51820. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51821. /**
  51822. * Disposes the post process.
  51823. * @param camera The camera to dispose the post process on.
  51824. */
  51825. dispose(camera?: Camera): void;
  51826. }
  51827. }
  51828. declare module "babylonjs/Shaders/refraction.fragment" {
  51829. /** @hidden */
  51830. export var refractionPixelShader: {
  51831. name: string;
  51832. shader: string;
  51833. };
  51834. }
  51835. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  51836. import { Color3 } from "babylonjs/Maths/math";
  51837. import { Camera } from "babylonjs/Cameras/camera";
  51838. import { Texture } from "babylonjs/Materials/Textures/texture";
  51839. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51840. import { Engine } from "babylonjs/Engines/engine";
  51841. import "babylonjs/Shaders/refraction.fragment";
  51842. /**
  51843. * Post process which applies a refractin texture
  51844. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  51845. */
  51846. export class RefractionPostProcess extends PostProcess {
  51847. /** the base color of the refraction (used to taint the rendering) */
  51848. color: Color3;
  51849. /** simulated refraction depth */
  51850. depth: number;
  51851. /** the coefficient of the base color (0 to remove base color tainting) */
  51852. colorLevel: number;
  51853. private _refTexture;
  51854. private _ownRefractionTexture;
  51855. /**
  51856. * Gets or sets the refraction texture
  51857. * Please note that you are responsible for disposing the texture if you set it manually
  51858. */
  51859. refractionTexture: Texture;
  51860. /**
  51861. * Initializes the RefractionPostProcess
  51862. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  51863. * @param name The name of the effect.
  51864. * @param refractionTextureUrl Url of the refraction texture to use
  51865. * @param color the base color of the refraction (used to taint the rendering)
  51866. * @param depth simulated refraction depth
  51867. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  51868. * @param camera The camera to apply the render pass to.
  51869. * @param options The required width/height ratio to downsize to before computing the render pass.
  51870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51871. * @param engine The engine which the post process will be applied. (default: current engine)
  51872. * @param reusable If the post process can be reused on the same frame. (default: false)
  51873. */
  51874. constructor(name: string, refractionTextureUrl: string,
  51875. /** the base color of the refraction (used to taint the rendering) */
  51876. color: Color3,
  51877. /** simulated refraction depth */
  51878. depth: number,
  51879. /** the coefficient of the base color (0 to remove base color tainting) */
  51880. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51881. /**
  51882. * Disposes of the post process
  51883. * @param camera Camera to dispose post process on
  51884. */
  51885. dispose(camera: Camera): void;
  51886. }
  51887. }
  51888. declare module "babylonjs/Shaders/sharpen.fragment" {
  51889. /** @hidden */
  51890. export var sharpenPixelShader: {
  51891. name: string;
  51892. shader: string;
  51893. };
  51894. }
  51895. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  51896. import { Nullable } from "babylonjs/types";
  51897. import { Camera } from "babylonjs/Cameras/camera";
  51898. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51899. import "babylonjs/Shaders/sharpen.fragment";
  51900. import { Engine } from "babylonjs/Engines/engine";
  51901. /**
  51902. * The SharpenPostProcess applies a sharpen kernel to every pixel
  51903. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51904. */
  51905. export class SharpenPostProcess extends PostProcess {
  51906. /**
  51907. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  51908. */
  51909. colorAmount: number;
  51910. /**
  51911. * How much sharpness should be applied (default: 0.3)
  51912. */
  51913. edgeAmount: number;
  51914. /**
  51915. * Creates a new instance ConvolutionPostProcess
  51916. * @param name The name of the effect.
  51917. * @param options The required width/height ratio to downsize to before computing the render pass.
  51918. * @param camera The camera to apply the render pass to.
  51919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51920. * @param engine The engine which the post process will be applied. (default: current engine)
  51921. * @param reusable If the post process can be reused on the same frame. (default: false)
  51922. * @param textureType Type of textures used when performing the post process. (default: 0)
  51923. * @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)
  51924. */
  51925. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51926. }
  51927. }
  51928. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  51929. import { Nullable } from "babylonjs/types";
  51930. import { Camera } from "babylonjs/Cameras/camera";
  51931. import { Engine } from "babylonjs/Engines/engine";
  51932. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51933. /**
  51934. * PostProcessRenderPipeline
  51935. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51936. */
  51937. export class PostProcessRenderPipeline {
  51938. private engine;
  51939. private _renderEffects;
  51940. private _renderEffectsForIsolatedPass;
  51941. /**
  51942. * @hidden
  51943. */
  51944. protected _cameras: Camera[];
  51945. /** @hidden */
  51946. _name: string;
  51947. /**
  51948. * Initializes a PostProcessRenderPipeline
  51949. * @param engine engine to add the pipeline to
  51950. * @param name name of the pipeline
  51951. */
  51952. constructor(engine: Engine, name: string);
  51953. /**
  51954. * "PostProcessRenderPipeline"
  51955. * @returns "PostProcessRenderPipeline"
  51956. */
  51957. getClassName(): string;
  51958. /**
  51959. * If all the render effects in the pipeline are support
  51960. */
  51961. readonly isSupported: boolean;
  51962. /**
  51963. * Adds an effect to the pipeline
  51964. * @param renderEffect the effect to add
  51965. */
  51966. addEffect(renderEffect: PostProcessRenderEffect): void;
  51967. /** @hidden */
  51968. _rebuild(): void;
  51969. /** @hidden */
  51970. _enableEffect(renderEffectName: string, cameras: Camera): void;
  51971. /** @hidden */
  51972. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  51973. /** @hidden */
  51974. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  51975. /** @hidden */
  51976. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  51977. /** @hidden */
  51978. _attachCameras(cameras: Camera, unique: boolean): void;
  51979. /** @hidden */
  51980. _attachCameras(cameras: Camera[], unique: boolean): void;
  51981. /** @hidden */
  51982. _detachCameras(cameras: Camera): void;
  51983. /** @hidden */
  51984. _detachCameras(cameras: Nullable<Camera[]>): void;
  51985. /** @hidden */
  51986. _update(): void;
  51987. /** @hidden */
  51988. _reset(): void;
  51989. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  51990. /**
  51991. * Disposes of the pipeline
  51992. */
  51993. dispose(): void;
  51994. }
  51995. }
  51996. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  51997. import { IAnimatable } from "babylonjs/Misc/tools";
  51998. import { Camera } from "babylonjs/Cameras/camera";
  51999. import { IDisposable } from "babylonjs/scene";
  52000. import { Scene } from "babylonjs/scene";
  52001. import { Animation } from "babylonjs/Animations/animation";
  52002. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  52003. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  52004. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  52005. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  52006. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52007. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52008. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  52009. /**
  52010. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52011. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52012. */
  52013. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52014. private _scene;
  52015. private _camerasToBeAttached;
  52016. /**
  52017. * ID of the sharpen post process,
  52018. */
  52019. private readonly SharpenPostProcessId;
  52020. /**
  52021. * @ignore
  52022. * ID of the image processing post process;
  52023. */
  52024. readonly ImageProcessingPostProcessId: string;
  52025. /**
  52026. * @ignore
  52027. * ID of the Fast Approximate Anti-Aliasing post process;
  52028. */
  52029. readonly FxaaPostProcessId: string;
  52030. /**
  52031. * ID of the chromatic aberration post process,
  52032. */
  52033. private readonly ChromaticAberrationPostProcessId;
  52034. /**
  52035. * ID of the grain post process
  52036. */
  52037. private readonly GrainPostProcessId;
  52038. /**
  52039. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52040. */
  52041. sharpen: SharpenPostProcess;
  52042. private _sharpenEffect;
  52043. private bloom;
  52044. /**
  52045. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52046. */
  52047. depthOfField: DepthOfFieldEffect;
  52048. /**
  52049. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52050. */
  52051. fxaa: FxaaPostProcess;
  52052. /**
  52053. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52054. */
  52055. imageProcessing: ImageProcessingPostProcess;
  52056. /**
  52057. * Chromatic aberration post process which will shift rgb colors in the image
  52058. */
  52059. chromaticAberration: ChromaticAberrationPostProcess;
  52060. private _chromaticAberrationEffect;
  52061. /**
  52062. * Grain post process which add noise to the image
  52063. */
  52064. grain: GrainPostProcess;
  52065. private _grainEffect;
  52066. /**
  52067. * Glow post process which adds a glow to emmisive areas of the image
  52068. */
  52069. private _glowLayer;
  52070. /**
  52071. * Animations which can be used to tweak settings over a period of time
  52072. */
  52073. animations: Animation[];
  52074. private _imageProcessingConfigurationObserver;
  52075. private _sharpenEnabled;
  52076. private _bloomEnabled;
  52077. private _depthOfFieldEnabled;
  52078. private _depthOfFieldBlurLevel;
  52079. private _fxaaEnabled;
  52080. private _imageProcessingEnabled;
  52081. private _defaultPipelineTextureType;
  52082. private _bloomScale;
  52083. private _chromaticAberrationEnabled;
  52084. private _grainEnabled;
  52085. private _buildAllowed;
  52086. /**
  52087. * Enable or disable the sharpen process from the pipeline
  52088. */
  52089. sharpenEnabled: boolean;
  52090. private _resizeObserver;
  52091. private _hardwareScaleLevel;
  52092. private _bloomKernel;
  52093. /**
  52094. * Specifies the size of the bloom blur kernel, relative to the final output size
  52095. */
  52096. bloomKernel: number;
  52097. /**
  52098. * Specifies the weight of the bloom in the final rendering
  52099. */
  52100. private _bloomWeight;
  52101. /**
  52102. * Specifies the luma threshold for the area that will be blurred by the bloom
  52103. */
  52104. private _bloomThreshold;
  52105. private _hdr;
  52106. /**
  52107. * The strength of the bloom.
  52108. */
  52109. bloomWeight: number;
  52110. /**
  52111. * The strength of the bloom.
  52112. */
  52113. bloomThreshold: number;
  52114. /**
  52115. * The scale of the bloom, lower value will provide better performance.
  52116. */
  52117. bloomScale: number;
  52118. /**
  52119. * Enable or disable the bloom from the pipeline
  52120. */
  52121. bloomEnabled: boolean;
  52122. private _rebuildBloom;
  52123. /**
  52124. * If the depth of field is enabled.
  52125. */
  52126. depthOfFieldEnabled: boolean;
  52127. /**
  52128. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52129. */
  52130. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52131. /**
  52132. * If the anti aliasing is enabled.
  52133. */
  52134. fxaaEnabled: boolean;
  52135. private _samples;
  52136. /**
  52137. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52138. */
  52139. samples: number;
  52140. /**
  52141. * If image processing is enabled.
  52142. */
  52143. imageProcessingEnabled: boolean;
  52144. /**
  52145. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52146. */
  52147. glowLayerEnabled: boolean;
  52148. /**
  52149. * Enable or disable the chromaticAberration process from the pipeline
  52150. */
  52151. chromaticAberrationEnabled: boolean;
  52152. /**
  52153. * Enable or disable the grain process from the pipeline
  52154. */
  52155. grainEnabled: boolean;
  52156. /**
  52157. * @constructor
  52158. * @param name - The rendering pipeline name (default: "")
  52159. * @param hdr - If high dynamic range textures should be used (default: true)
  52160. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52161. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52162. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52163. */
  52164. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52165. /**
  52166. * Force the compilation of the entire pipeline.
  52167. */
  52168. prepare(): void;
  52169. private _hasCleared;
  52170. private _prevPostProcess;
  52171. private _prevPrevPostProcess;
  52172. private _setAutoClearAndTextureSharing;
  52173. private _depthOfFieldSceneObserver;
  52174. private _buildPipeline;
  52175. private _disposePostProcesses;
  52176. /**
  52177. * Adds a camera to the pipeline
  52178. * @param camera the camera to be added
  52179. */
  52180. addCamera(camera: Camera): void;
  52181. /**
  52182. * Removes a camera from the pipeline
  52183. * @param camera the camera to remove
  52184. */
  52185. removeCamera(camera: Camera): void;
  52186. /**
  52187. * Dispose of the pipeline and stop all post processes
  52188. */
  52189. dispose(): void;
  52190. /**
  52191. * Serialize the rendering pipeline (Used when exporting)
  52192. * @returns the serialized object
  52193. */
  52194. serialize(): any;
  52195. /**
  52196. * Parse the serialized pipeline
  52197. * @param source Source pipeline.
  52198. * @param scene The scene to load the pipeline to.
  52199. * @param rootUrl The URL of the serialized pipeline.
  52200. * @returns An instantiated pipeline from the serialized object.
  52201. */
  52202. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52203. }
  52204. }
  52205. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  52206. /** @hidden */
  52207. export var lensHighlightsPixelShader: {
  52208. name: string;
  52209. shader: string;
  52210. };
  52211. }
  52212. declare module "babylonjs/Shaders/depthOfField.fragment" {
  52213. /** @hidden */
  52214. export var depthOfFieldPixelShader: {
  52215. name: string;
  52216. shader: string;
  52217. };
  52218. }
  52219. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  52220. import { Camera } from "babylonjs/Cameras/camera";
  52221. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52222. import { Scene } from "babylonjs/scene";
  52223. import "babylonjs/Shaders/chromaticAberration.fragment";
  52224. import "babylonjs/Shaders/lensHighlights.fragment";
  52225. import "babylonjs/Shaders/depthOfField.fragment";
  52226. /**
  52227. * BABYLON.JS Chromatic Aberration GLSL Shader
  52228. * Author: Olivier Guyot
  52229. * Separates very slightly R, G and B colors on the edges of the screen
  52230. * Inspired by Francois Tarlier & Martins Upitis
  52231. */
  52232. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52233. /**
  52234. * @ignore
  52235. * The chromatic aberration PostProcess id in the pipeline
  52236. */
  52237. LensChromaticAberrationEffect: string;
  52238. /**
  52239. * @ignore
  52240. * The highlights enhancing PostProcess id in the pipeline
  52241. */
  52242. HighlightsEnhancingEffect: string;
  52243. /**
  52244. * @ignore
  52245. * The depth-of-field PostProcess id in the pipeline
  52246. */
  52247. LensDepthOfFieldEffect: string;
  52248. private _scene;
  52249. private _depthTexture;
  52250. private _grainTexture;
  52251. private _chromaticAberrationPostProcess;
  52252. private _highlightsPostProcess;
  52253. private _depthOfFieldPostProcess;
  52254. private _edgeBlur;
  52255. private _grainAmount;
  52256. private _chromaticAberration;
  52257. private _distortion;
  52258. private _highlightsGain;
  52259. private _highlightsThreshold;
  52260. private _dofDistance;
  52261. private _dofAperture;
  52262. private _dofDarken;
  52263. private _dofPentagon;
  52264. private _blurNoise;
  52265. /**
  52266. * @constructor
  52267. *
  52268. * Effect parameters are as follow:
  52269. * {
  52270. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52271. * edge_blur: number; // from 0 to x (1 for realism)
  52272. * distortion: number; // from 0 to x (1 for realism)
  52273. * grain_amount: number; // from 0 to 1
  52274. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52275. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52276. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52277. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52278. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52279. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52280. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52281. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52282. * }
  52283. * Note: if an effect parameter is unset, effect is disabled
  52284. *
  52285. * @param name The rendering pipeline name
  52286. * @param parameters - An object containing all parameters (see above)
  52287. * @param scene The scene linked to this pipeline
  52288. * @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)
  52289. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52290. */
  52291. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52292. /**
  52293. * Sets the amount of blur at the edges
  52294. * @param amount blur amount
  52295. */
  52296. setEdgeBlur(amount: number): void;
  52297. /**
  52298. * Sets edge blur to 0
  52299. */
  52300. disableEdgeBlur(): void;
  52301. /**
  52302. * Sets the amout of grain
  52303. * @param amount Amount of grain
  52304. */
  52305. setGrainAmount(amount: number): void;
  52306. /**
  52307. * Set grain amount to 0
  52308. */
  52309. disableGrain(): void;
  52310. /**
  52311. * Sets the chromatic aberration amount
  52312. * @param amount amount of chromatic aberration
  52313. */
  52314. setChromaticAberration(amount: number): void;
  52315. /**
  52316. * Sets chromatic aberration amount to 0
  52317. */
  52318. disableChromaticAberration(): void;
  52319. /**
  52320. * Sets the EdgeDistortion amount
  52321. * @param amount amount of EdgeDistortion
  52322. */
  52323. setEdgeDistortion(amount: number): void;
  52324. /**
  52325. * Sets edge distortion to 0
  52326. */
  52327. disableEdgeDistortion(): void;
  52328. /**
  52329. * Sets the FocusDistance amount
  52330. * @param amount amount of FocusDistance
  52331. */
  52332. setFocusDistance(amount: number): void;
  52333. /**
  52334. * Disables depth of field
  52335. */
  52336. disableDepthOfField(): void;
  52337. /**
  52338. * Sets the Aperture amount
  52339. * @param amount amount of Aperture
  52340. */
  52341. setAperture(amount: number): void;
  52342. /**
  52343. * Sets the DarkenOutOfFocus amount
  52344. * @param amount amount of DarkenOutOfFocus
  52345. */
  52346. setDarkenOutOfFocus(amount: number): void;
  52347. /**
  52348. * Creates a pentagon bokeh effect
  52349. */
  52350. enablePentagonBokeh(): void;
  52351. /**
  52352. * Disables the pentagon bokeh effect
  52353. */
  52354. disablePentagonBokeh(): void;
  52355. /**
  52356. * Enables noise blur
  52357. */
  52358. enableNoiseBlur(): void;
  52359. /**
  52360. * Disables noise blur
  52361. */
  52362. disableNoiseBlur(): void;
  52363. /**
  52364. * Sets the HighlightsGain amount
  52365. * @param amount amount of HighlightsGain
  52366. */
  52367. setHighlightsGain(amount: number): void;
  52368. /**
  52369. * Sets the HighlightsThreshold amount
  52370. * @param amount amount of HighlightsThreshold
  52371. */
  52372. setHighlightsThreshold(amount: number): void;
  52373. /**
  52374. * Disables highlights
  52375. */
  52376. disableHighlights(): void;
  52377. /**
  52378. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52379. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52380. */
  52381. dispose(disableDepthRender?: boolean): void;
  52382. private _createChromaticAberrationPostProcess;
  52383. private _createHighlightsPostProcess;
  52384. private _createDepthOfFieldPostProcess;
  52385. private _createGrainTexture;
  52386. }
  52387. }
  52388. declare module "babylonjs/Shaders/ssao2.fragment" {
  52389. /** @hidden */
  52390. export var ssao2PixelShader: {
  52391. name: string;
  52392. shader: string;
  52393. };
  52394. }
  52395. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  52396. /** @hidden */
  52397. export var ssaoCombinePixelShader: {
  52398. name: string;
  52399. shader: string;
  52400. };
  52401. }
  52402. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  52403. import { Camera } from "babylonjs/Cameras/camera";
  52404. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52405. import { Scene } from "babylonjs/scene";
  52406. import "babylonjs/Shaders/ssao2.fragment";
  52407. import "babylonjs/Shaders/ssaoCombine.fragment";
  52408. /**
  52409. * Render pipeline to produce ssao effect
  52410. */
  52411. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  52412. /**
  52413. * @ignore
  52414. * The PassPostProcess id in the pipeline that contains the original scene color
  52415. */
  52416. SSAOOriginalSceneColorEffect: string;
  52417. /**
  52418. * @ignore
  52419. * The SSAO PostProcess id in the pipeline
  52420. */
  52421. SSAORenderEffect: string;
  52422. /**
  52423. * @ignore
  52424. * The horizontal blur PostProcess id in the pipeline
  52425. */
  52426. SSAOBlurHRenderEffect: string;
  52427. /**
  52428. * @ignore
  52429. * The vertical blur PostProcess id in the pipeline
  52430. */
  52431. SSAOBlurVRenderEffect: string;
  52432. /**
  52433. * @ignore
  52434. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52435. */
  52436. SSAOCombineRenderEffect: string;
  52437. /**
  52438. * The output strength of the SSAO post-process. Default value is 1.0.
  52439. */
  52440. totalStrength: number;
  52441. /**
  52442. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  52443. */
  52444. maxZ: number;
  52445. /**
  52446. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  52447. */
  52448. minZAspect: number;
  52449. private _samples;
  52450. /**
  52451. * Number of samples used for the SSAO calculations. Default value is 8
  52452. */
  52453. samples: number;
  52454. private _textureSamples;
  52455. /**
  52456. * Number of samples to use for antialiasing
  52457. */
  52458. textureSamples: number;
  52459. /**
  52460. * Ratio object used for SSAO ratio and blur ratio
  52461. */
  52462. private _ratio;
  52463. /**
  52464. * Dynamically generated sphere sampler.
  52465. */
  52466. private _sampleSphere;
  52467. /**
  52468. * Blur filter offsets
  52469. */
  52470. private _samplerOffsets;
  52471. private _expensiveBlur;
  52472. /**
  52473. * If bilateral blur should be used
  52474. */
  52475. expensiveBlur: boolean;
  52476. /**
  52477. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  52478. */
  52479. radius: number;
  52480. /**
  52481. * The base color of the SSAO post-process
  52482. * The final result is "base + ssao" between [0, 1]
  52483. */
  52484. base: number;
  52485. /**
  52486. * Support test.
  52487. */
  52488. static readonly IsSupported: boolean;
  52489. private _scene;
  52490. private _depthTexture;
  52491. private _normalTexture;
  52492. private _randomTexture;
  52493. private _originalColorPostProcess;
  52494. private _ssaoPostProcess;
  52495. private _blurHPostProcess;
  52496. private _blurVPostProcess;
  52497. private _ssaoCombinePostProcess;
  52498. private _firstUpdate;
  52499. /**
  52500. * @constructor
  52501. * @param name The rendering pipeline name
  52502. * @param scene The scene linked to this pipeline
  52503. * @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 }
  52504. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52505. */
  52506. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52507. /**
  52508. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52509. */
  52510. dispose(disableGeometryBufferRenderer?: boolean): void;
  52511. private _createBlurPostProcess;
  52512. /** @hidden */
  52513. _rebuild(): void;
  52514. private _bits;
  52515. private _radicalInverse_VdC;
  52516. private _hammersley;
  52517. private _hemisphereSample_uniform;
  52518. private _generateHemisphere;
  52519. private _createSSAOPostProcess;
  52520. private _createSSAOCombinePostProcess;
  52521. private _createRandomTexture;
  52522. /**
  52523. * Serialize the rendering pipeline (Used when exporting)
  52524. * @returns the serialized object
  52525. */
  52526. serialize(): any;
  52527. /**
  52528. * Parse the serialized pipeline
  52529. * @param source Source pipeline.
  52530. * @param scene The scene to load the pipeline to.
  52531. * @param rootUrl The URL of the serialized pipeline.
  52532. * @returns An instantiated pipeline from the serialized object.
  52533. */
  52534. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  52535. }
  52536. }
  52537. declare module "babylonjs/Shaders/ssao.fragment" {
  52538. /** @hidden */
  52539. export var ssaoPixelShader: {
  52540. name: string;
  52541. shader: string;
  52542. };
  52543. }
  52544. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  52545. import { Camera } from "babylonjs/Cameras/camera";
  52546. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52547. import { Scene } from "babylonjs/scene";
  52548. import "babylonjs/Shaders/ssao.fragment";
  52549. import "babylonjs/Shaders/ssaoCombine.fragment";
  52550. /**
  52551. * Render pipeline to produce ssao effect
  52552. */
  52553. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  52554. /**
  52555. * @ignore
  52556. * The PassPostProcess id in the pipeline that contains the original scene color
  52557. */
  52558. SSAOOriginalSceneColorEffect: string;
  52559. /**
  52560. * @ignore
  52561. * The SSAO PostProcess id in the pipeline
  52562. */
  52563. SSAORenderEffect: string;
  52564. /**
  52565. * @ignore
  52566. * The horizontal blur PostProcess id in the pipeline
  52567. */
  52568. SSAOBlurHRenderEffect: string;
  52569. /**
  52570. * @ignore
  52571. * The vertical blur PostProcess id in the pipeline
  52572. */
  52573. SSAOBlurVRenderEffect: string;
  52574. /**
  52575. * @ignore
  52576. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52577. */
  52578. SSAOCombineRenderEffect: string;
  52579. /**
  52580. * The output strength of the SSAO post-process. Default value is 1.0.
  52581. */
  52582. totalStrength: number;
  52583. /**
  52584. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  52585. */
  52586. radius: number;
  52587. /**
  52588. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  52589. * Must not be equal to fallOff and superior to fallOff.
  52590. * Default value is 0.975
  52591. */
  52592. area: number;
  52593. /**
  52594. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  52595. * Must not be equal to area and inferior to area.
  52596. * Default value is 0.0
  52597. */
  52598. fallOff: number;
  52599. /**
  52600. * The base color of the SSAO post-process
  52601. * The final result is "base + ssao" between [0, 1]
  52602. */
  52603. base: number;
  52604. private _scene;
  52605. private _depthTexture;
  52606. private _randomTexture;
  52607. private _originalColorPostProcess;
  52608. private _ssaoPostProcess;
  52609. private _blurHPostProcess;
  52610. private _blurVPostProcess;
  52611. private _ssaoCombinePostProcess;
  52612. private _firstUpdate;
  52613. /**
  52614. * @constructor
  52615. * @param name - The rendering pipeline name
  52616. * @param scene - The scene linked to this pipeline
  52617. * @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 }
  52618. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  52619. */
  52620. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52621. /**
  52622. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52623. */
  52624. dispose(disableDepthRender?: boolean): void;
  52625. private _createBlurPostProcess;
  52626. /** @hidden */
  52627. _rebuild(): void;
  52628. private _createSSAOPostProcess;
  52629. private _createSSAOCombinePostProcess;
  52630. private _createRandomTexture;
  52631. }
  52632. }
  52633. declare module "babylonjs/Shaders/standard.fragment" {
  52634. /** @hidden */
  52635. export var standardPixelShader: {
  52636. name: string;
  52637. shader: string;
  52638. };
  52639. }
  52640. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  52641. import { Nullable } from "babylonjs/types";
  52642. import { IAnimatable } from "babylonjs/Misc/tools";
  52643. import { Camera } from "babylonjs/Cameras/camera";
  52644. import { Texture } from "babylonjs/Materials/Textures/texture";
  52645. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52646. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52647. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  52648. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52649. import { IDisposable } from "babylonjs/scene";
  52650. import { SpotLight } from "babylonjs/Lights/spotLight";
  52651. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  52652. import { Scene } from "babylonjs/scene";
  52653. import { Animation } from "babylonjs/Animations/animation";
  52654. import "babylonjs/Shaders/standard.fragment";
  52655. /**
  52656. * Standard rendering pipeline
  52657. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  52658. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  52659. */
  52660. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52661. /**
  52662. * Public members
  52663. */
  52664. /**
  52665. * Post-process which contains the original scene color before the pipeline applies all the effects
  52666. */
  52667. originalPostProcess: Nullable<PostProcess>;
  52668. /**
  52669. * Post-process used to down scale an image x4
  52670. */
  52671. downSampleX4PostProcess: Nullable<PostProcess>;
  52672. /**
  52673. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  52674. */
  52675. brightPassPostProcess: Nullable<PostProcess>;
  52676. /**
  52677. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  52678. */
  52679. blurHPostProcesses: PostProcess[];
  52680. /**
  52681. * Post-process array storing all the vertical blur post-processes used by the pipeline
  52682. */
  52683. blurVPostProcesses: PostProcess[];
  52684. /**
  52685. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  52686. */
  52687. textureAdderPostProcess: Nullable<PostProcess>;
  52688. /**
  52689. * Post-process used to create volumetric lighting effect
  52690. */
  52691. volumetricLightPostProcess: Nullable<PostProcess>;
  52692. /**
  52693. * Post-process used to smooth the previous volumetric light post-process on the X axis
  52694. */
  52695. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  52696. /**
  52697. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  52698. */
  52699. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  52700. /**
  52701. * Post-process used to merge the volumetric light effect and the real scene color
  52702. */
  52703. volumetricLightMergePostProces: Nullable<PostProcess>;
  52704. /**
  52705. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  52706. */
  52707. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  52708. /**
  52709. * Base post-process used to calculate the average luminance of the final image for HDR
  52710. */
  52711. luminancePostProcess: Nullable<PostProcess>;
  52712. /**
  52713. * Post-processes used to create down sample post-processes in order to get
  52714. * the average luminance of the final image for HDR
  52715. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  52716. */
  52717. luminanceDownSamplePostProcesses: PostProcess[];
  52718. /**
  52719. * Post-process used to create a HDR effect (light adaptation)
  52720. */
  52721. hdrPostProcess: Nullable<PostProcess>;
  52722. /**
  52723. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  52724. */
  52725. textureAdderFinalPostProcess: Nullable<PostProcess>;
  52726. /**
  52727. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  52728. */
  52729. lensFlareFinalPostProcess: Nullable<PostProcess>;
  52730. /**
  52731. * Post-process used to merge the final HDR post-process and the real scene color
  52732. */
  52733. hdrFinalPostProcess: Nullable<PostProcess>;
  52734. /**
  52735. * Post-process used to create a lens flare effect
  52736. */
  52737. lensFlarePostProcess: Nullable<PostProcess>;
  52738. /**
  52739. * Post-process that merges the result of the lens flare post-process and the real scene color
  52740. */
  52741. lensFlareComposePostProcess: Nullable<PostProcess>;
  52742. /**
  52743. * Post-process used to create a motion blur effect
  52744. */
  52745. motionBlurPostProcess: Nullable<PostProcess>;
  52746. /**
  52747. * Post-process used to create a depth of field effect
  52748. */
  52749. depthOfFieldPostProcess: Nullable<PostProcess>;
  52750. /**
  52751. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52752. */
  52753. fxaaPostProcess: Nullable<FxaaPostProcess>;
  52754. /**
  52755. * Represents the brightness threshold in order to configure the illuminated surfaces
  52756. */
  52757. brightThreshold: number;
  52758. /**
  52759. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  52760. */
  52761. blurWidth: number;
  52762. /**
  52763. * Sets if the blur for highlighted surfaces must be only horizontal
  52764. */
  52765. horizontalBlur: boolean;
  52766. /**
  52767. * Sets the overall exposure used by the pipeline
  52768. */
  52769. exposure: number;
  52770. /**
  52771. * Texture used typically to simulate "dirty" on camera lens
  52772. */
  52773. lensTexture: Nullable<Texture>;
  52774. /**
  52775. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  52776. */
  52777. volumetricLightCoefficient: number;
  52778. /**
  52779. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  52780. */
  52781. volumetricLightPower: number;
  52782. /**
  52783. * Used the set the blur intensity to smooth the volumetric lights
  52784. */
  52785. volumetricLightBlurScale: number;
  52786. /**
  52787. * Light (spot or directional) used to generate the volumetric lights rays
  52788. * The source light must have a shadow generate so the pipeline can get its
  52789. * depth map
  52790. */
  52791. sourceLight: Nullable<SpotLight | DirectionalLight>;
  52792. /**
  52793. * For eye adaptation, represents the minimum luminance the eye can see
  52794. */
  52795. hdrMinimumLuminance: number;
  52796. /**
  52797. * For eye adaptation, represents the decrease luminance speed
  52798. */
  52799. hdrDecreaseRate: number;
  52800. /**
  52801. * For eye adaptation, represents the increase luminance speed
  52802. */
  52803. hdrIncreaseRate: number;
  52804. /**
  52805. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  52806. */
  52807. lensColorTexture: Nullable<Texture>;
  52808. /**
  52809. * The overall strengh for the lens flare effect
  52810. */
  52811. lensFlareStrength: number;
  52812. /**
  52813. * Dispersion coefficient for lens flare ghosts
  52814. */
  52815. lensFlareGhostDispersal: number;
  52816. /**
  52817. * Main lens flare halo width
  52818. */
  52819. lensFlareHaloWidth: number;
  52820. /**
  52821. * Based on the lens distortion effect, defines how much the lens flare result
  52822. * is distorted
  52823. */
  52824. lensFlareDistortionStrength: number;
  52825. /**
  52826. * Lens star texture must be used to simulate rays on the flares and is available
  52827. * in the documentation
  52828. */
  52829. lensStarTexture: Nullable<Texture>;
  52830. /**
  52831. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  52832. * flare effect by taking account of the dirt texture
  52833. */
  52834. lensFlareDirtTexture: Nullable<Texture>;
  52835. /**
  52836. * Represents the focal length for the depth of field effect
  52837. */
  52838. depthOfFieldDistance: number;
  52839. /**
  52840. * Represents the blur intensity for the blurred part of the depth of field effect
  52841. */
  52842. depthOfFieldBlurWidth: number;
  52843. /**
  52844. * For motion blur, defines how much the image is blurred by the movement
  52845. */
  52846. motionStrength: number;
  52847. /**
  52848. * List of animations for the pipeline (IAnimatable implementation)
  52849. */
  52850. animations: Animation[];
  52851. /**
  52852. * Private members
  52853. */
  52854. private _scene;
  52855. private _currentDepthOfFieldSource;
  52856. private _basePostProcess;
  52857. private _hdrCurrentLuminance;
  52858. private _floatTextureType;
  52859. private _ratio;
  52860. private _bloomEnabled;
  52861. private _depthOfFieldEnabled;
  52862. private _vlsEnabled;
  52863. private _lensFlareEnabled;
  52864. private _hdrEnabled;
  52865. private _motionBlurEnabled;
  52866. private _fxaaEnabled;
  52867. private _motionBlurSamples;
  52868. private _volumetricLightStepsCount;
  52869. private _samples;
  52870. /**
  52871. * @ignore
  52872. * Specifies if the bloom pipeline is enabled
  52873. */
  52874. BloomEnabled: boolean;
  52875. /**
  52876. * @ignore
  52877. * Specifies if the depth of field pipeline is enabed
  52878. */
  52879. DepthOfFieldEnabled: boolean;
  52880. /**
  52881. * @ignore
  52882. * Specifies if the lens flare pipeline is enabed
  52883. */
  52884. LensFlareEnabled: boolean;
  52885. /**
  52886. * @ignore
  52887. * Specifies if the HDR pipeline is enabled
  52888. */
  52889. HDREnabled: boolean;
  52890. /**
  52891. * @ignore
  52892. * Specifies if the volumetric lights scattering effect is enabled
  52893. */
  52894. VLSEnabled: boolean;
  52895. /**
  52896. * @ignore
  52897. * Specifies if the motion blur effect is enabled
  52898. */
  52899. MotionBlurEnabled: boolean;
  52900. /**
  52901. * Specifies if anti-aliasing is enabled
  52902. */
  52903. fxaaEnabled: boolean;
  52904. /**
  52905. * Specifies the number of steps used to calculate the volumetric lights
  52906. * Typically in interval [50, 200]
  52907. */
  52908. volumetricLightStepsCount: number;
  52909. /**
  52910. * Specifies the number of samples used for the motion blur effect
  52911. * Typically in interval [16, 64]
  52912. */
  52913. motionBlurSamples: number;
  52914. /**
  52915. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52916. */
  52917. samples: number;
  52918. /**
  52919. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  52920. * @constructor
  52921. * @param name The rendering pipeline name
  52922. * @param scene The scene linked to this pipeline
  52923. * @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)
  52924. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  52925. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52926. */
  52927. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  52928. private _buildPipeline;
  52929. private _createDownSampleX4PostProcess;
  52930. private _createBrightPassPostProcess;
  52931. private _createBlurPostProcesses;
  52932. private _createTextureAdderPostProcess;
  52933. private _createVolumetricLightPostProcess;
  52934. private _createLuminancePostProcesses;
  52935. private _createHdrPostProcess;
  52936. private _createLensFlarePostProcess;
  52937. private _createDepthOfFieldPostProcess;
  52938. private _createMotionBlurPostProcess;
  52939. private _getDepthTexture;
  52940. private _disposePostProcesses;
  52941. /**
  52942. * Dispose of the pipeline and stop all post processes
  52943. */
  52944. dispose(): void;
  52945. /**
  52946. * Serialize the rendering pipeline (Used when exporting)
  52947. * @returns the serialized object
  52948. */
  52949. serialize(): any;
  52950. /**
  52951. * Parse the serialized pipeline
  52952. * @param source Source pipeline.
  52953. * @param scene The scene to load the pipeline to.
  52954. * @param rootUrl The URL of the serialized pipeline.
  52955. * @returns An instantiated pipeline from the serialized object.
  52956. */
  52957. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  52958. /**
  52959. * Luminance steps
  52960. */
  52961. static LuminanceSteps: number;
  52962. }
  52963. }
  52964. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  52965. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  52966. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  52967. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  52968. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  52969. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  52970. }
  52971. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  52972. import { Camera } from "babylonjs/Cameras/camera";
  52973. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52974. /**
  52975. * PostProcessRenderPipelineManager class
  52976. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52977. */
  52978. export class PostProcessRenderPipelineManager {
  52979. private _renderPipelines;
  52980. /**
  52981. * Initializes a PostProcessRenderPipelineManager
  52982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52983. */
  52984. constructor();
  52985. /**
  52986. * Adds a pipeline to the manager
  52987. * @param renderPipeline The pipeline to add
  52988. */
  52989. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52990. /**
  52991. * Attaches a camera to the pipeline
  52992. * @param renderPipelineName The name of the pipeline to attach to
  52993. * @param cameras the camera to attach
  52994. * @param unique if the camera can be attached multiple times to the pipeline
  52995. */
  52996. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52997. /**
  52998. * Detaches a camera from the pipeline
  52999. * @param renderPipelineName The name of the pipeline to detach from
  53000. * @param cameras the camera to detach
  53001. */
  53002. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53003. /**
  53004. * Enables an effect by name on a pipeline
  53005. * @param renderPipelineName the name of the pipeline to enable the effect in
  53006. * @param renderEffectName the name of the effect to enable
  53007. * @param cameras the cameras that the effect should be enabled on
  53008. */
  53009. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53010. /**
  53011. * Disables an effect by name on a pipeline
  53012. * @param renderPipelineName the name of the pipeline to disable the effect in
  53013. * @param renderEffectName the name of the effect to disable
  53014. * @param cameras the cameras that the effect should be disabled on
  53015. */
  53016. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53017. /**
  53018. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53019. */
  53020. update(): void;
  53021. /** @hidden */
  53022. _rebuild(): void;
  53023. /**
  53024. * Disposes of the manager and pipelines
  53025. */
  53026. dispose(): void;
  53027. }
  53028. }
  53029. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53030. import { ISceneComponent } from "babylonjs/sceneComponent";
  53031. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53032. import { Scene } from "babylonjs/scene";
  53033. module "babylonjs/scene" {
  53034. interface Scene {
  53035. /** @hidden (Backing field) */
  53036. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53037. /**
  53038. * Gets the postprocess render pipeline manager
  53039. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53040. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53041. */
  53042. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53043. }
  53044. }
  53045. /**
  53046. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53047. */
  53048. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53049. /**
  53050. * The component name helpfull to identify the component in the list of scene components.
  53051. */
  53052. readonly name: string;
  53053. /**
  53054. * The scene the component belongs to.
  53055. */
  53056. scene: Scene;
  53057. /**
  53058. * Creates a new instance of the component for the given scene
  53059. * @param scene Defines the scene to register the component in
  53060. */
  53061. constructor(scene: Scene);
  53062. /**
  53063. * Registers the component in a given scene
  53064. */
  53065. register(): void;
  53066. /**
  53067. * Rebuilds the elements related to this component in case of
  53068. * context lost for instance.
  53069. */
  53070. rebuild(): void;
  53071. /**
  53072. * Disposes the component and the associated ressources
  53073. */
  53074. dispose(): void;
  53075. private _gatherRenderTargets;
  53076. }
  53077. }
  53078. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  53079. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  53080. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53081. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53082. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53083. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53084. }
  53085. declare module "babylonjs/Shaders/tonemap.fragment" {
  53086. /** @hidden */
  53087. export var tonemapPixelShader: {
  53088. name: string;
  53089. shader: string;
  53090. };
  53091. }
  53092. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  53093. import { Camera } from "babylonjs/Cameras/camera";
  53094. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53095. import "babylonjs/Shaders/tonemap.fragment";
  53096. import { Engine } from "babylonjs/Engines/engine";
  53097. /** Defines operator used for tonemapping */
  53098. export enum TonemappingOperator {
  53099. /** Hable */
  53100. Hable = 0,
  53101. /** Reinhard */
  53102. Reinhard = 1,
  53103. /** HejiDawson */
  53104. HejiDawson = 2,
  53105. /** Photographic */
  53106. Photographic = 3
  53107. }
  53108. /**
  53109. * Defines a post process to apply tone mapping
  53110. */
  53111. export class TonemapPostProcess extends PostProcess {
  53112. private _operator;
  53113. /** Defines the required exposure adjustement */
  53114. exposureAdjustment: number;
  53115. /**
  53116. * Creates a new TonemapPostProcess
  53117. * @param name defines the name of the postprocess
  53118. * @param _operator defines the operator to use
  53119. * @param exposureAdjustment defines the required exposure adjustement
  53120. * @param camera defines the camera to use (can be null)
  53121. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53122. * @param engine defines the hosting engine (can be ignore if camera is set)
  53123. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53124. */
  53125. constructor(name: string, _operator: TonemappingOperator,
  53126. /** Defines the required exposure adjustement */
  53127. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53128. }
  53129. }
  53130. declare module "babylonjs/Shaders/depth.vertex" {
  53131. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53132. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53133. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53134. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53135. /** @hidden */
  53136. export var depthVertexShader: {
  53137. name: string;
  53138. shader: string;
  53139. };
  53140. }
  53141. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  53142. /** @hidden */
  53143. export var volumetricLightScatteringPixelShader: {
  53144. name: string;
  53145. shader: string;
  53146. };
  53147. }
  53148. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  53149. /** @hidden */
  53150. export var volumetricLightScatteringPassPixelShader: {
  53151. name: string;
  53152. shader: string;
  53153. };
  53154. }
  53155. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  53156. import { Vector3 } from "babylonjs/Maths/math";
  53157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53158. import { Mesh } from "babylonjs/Meshes/mesh";
  53159. import { Camera } from "babylonjs/Cameras/camera";
  53160. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53161. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53162. import { Scene } from "babylonjs/scene";
  53163. import "babylonjs/Shaders/depth.vertex";
  53164. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  53165. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  53166. import { Engine } from "babylonjs/Engines/engine";
  53167. /**
  53168. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53169. */
  53170. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53171. private _volumetricLightScatteringPass;
  53172. private _volumetricLightScatteringRTT;
  53173. private _viewPort;
  53174. private _screenCoordinates;
  53175. private _cachedDefines;
  53176. /**
  53177. * If not undefined, the mesh position is computed from the attached node position
  53178. */
  53179. attachedNode: {
  53180. position: Vector3;
  53181. };
  53182. /**
  53183. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53184. */
  53185. customMeshPosition: Vector3;
  53186. /**
  53187. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53188. */
  53189. useCustomMeshPosition: boolean;
  53190. /**
  53191. * If the post-process should inverse the light scattering direction
  53192. */
  53193. invert: boolean;
  53194. /**
  53195. * The internal mesh used by the post-process
  53196. */
  53197. mesh: Mesh;
  53198. /**
  53199. * @hidden
  53200. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53201. */
  53202. useDiffuseColor: boolean;
  53203. /**
  53204. * Array containing the excluded meshes not rendered in the internal pass
  53205. */
  53206. excludedMeshes: AbstractMesh[];
  53207. /**
  53208. * Controls the overall intensity of the post-process
  53209. */
  53210. exposure: number;
  53211. /**
  53212. * Dissipates each sample's contribution in range [0, 1]
  53213. */
  53214. decay: number;
  53215. /**
  53216. * Controls the overall intensity of each sample
  53217. */
  53218. weight: number;
  53219. /**
  53220. * Controls the density of each sample
  53221. */
  53222. density: number;
  53223. /**
  53224. * @constructor
  53225. * @param name The post-process name
  53226. * @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)
  53227. * @param camera The camera that the post-process will be attached to
  53228. * @param mesh The mesh used to create the light scattering
  53229. * @param samples The post-process quality, default 100
  53230. * @param samplingModeThe post-process filtering mode
  53231. * @param engine The babylon engine
  53232. * @param reusable If the post-process is reusable
  53233. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53234. */
  53235. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53236. /**
  53237. * Returns the string "VolumetricLightScatteringPostProcess"
  53238. * @returns "VolumetricLightScatteringPostProcess"
  53239. */
  53240. getClassName(): string;
  53241. private _isReady;
  53242. /**
  53243. * Sets the new light position for light scattering effect
  53244. * @param position The new custom light position
  53245. */
  53246. setCustomMeshPosition(position: Vector3): void;
  53247. /**
  53248. * Returns the light position for light scattering effect
  53249. * @return Vector3 The custom light position
  53250. */
  53251. getCustomMeshPosition(): Vector3;
  53252. /**
  53253. * Disposes the internal assets and detaches the post-process from the camera
  53254. */
  53255. dispose(camera: Camera): void;
  53256. /**
  53257. * Returns the render target texture used by the post-process
  53258. * @return the render target texture used by the post-process
  53259. */
  53260. getPass(): RenderTargetTexture;
  53261. private _meshExcluded;
  53262. private _createPass;
  53263. private _updateMeshScreenCoordinates;
  53264. /**
  53265. * Creates a default mesh for the Volumeric Light Scattering post-process
  53266. * @param name The mesh name
  53267. * @param scene The scene where to create the mesh
  53268. * @return the default mesh
  53269. */
  53270. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53271. }
  53272. }
  53273. declare module "babylonjs/PostProcesses/index" {
  53274. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  53275. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  53276. export * from "babylonjs/PostProcesses/bloomEffect";
  53277. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  53278. export * from "babylonjs/PostProcesses/blurPostProcess";
  53279. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53280. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  53281. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  53282. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  53283. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53284. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  53285. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  53286. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  53287. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53288. export * from "babylonjs/PostProcesses/filterPostProcess";
  53289. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  53290. export * from "babylonjs/PostProcesses/grainPostProcess";
  53291. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  53292. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53293. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  53294. export * from "babylonjs/PostProcesses/passPostProcess";
  53295. export * from "babylonjs/PostProcesses/postProcess";
  53296. export * from "babylonjs/PostProcesses/postProcessManager";
  53297. export * from "babylonjs/PostProcesses/refractionPostProcess";
  53298. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  53299. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  53300. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  53301. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  53302. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  53303. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  53304. }
  53305. declare module "babylonjs/Probes/index" {
  53306. export * from "babylonjs/Probes/reflectionProbe";
  53307. }
  53308. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  53309. import { Scene } from "babylonjs/scene";
  53310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53311. import { Color3 } from "babylonjs/Maths/math";
  53312. import { SmartArray } from "babylonjs/Misc/smartArray";
  53313. import { ISceneComponent } from "babylonjs/sceneComponent";
  53314. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  53315. import "babylonjs/Shaders/color.fragment";
  53316. import "babylonjs/Shaders/color.vertex";
  53317. module "babylonjs/scene" {
  53318. interface Scene {
  53319. /** @hidden (Backing field) */
  53320. _boundingBoxRenderer: BoundingBoxRenderer;
  53321. /** @hidden (Backing field) */
  53322. _forceShowBoundingBoxes: boolean;
  53323. /**
  53324. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53325. */
  53326. forceShowBoundingBoxes: boolean;
  53327. /**
  53328. * Gets the bounding box renderer associated with the scene
  53329. * @returns a BoundingBoxRenderer
  53330. */
  53331. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53332. }
  53333. }
  53334. module "babylonjs/Meshes/abstractMesh" {
  53335. interface AbstractMesh {
  53336. /** @hidden (Backing field) */
  53337. _showBoundingBox: boolean;
  53338. /**
  53339. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53340. */
  53341. showBoundingBox: boolean;
  53342. }
  53343. }
  53344. /**
  53345. * Component responsible of rendering the bounding box of the meshes in a scene.
  53346. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53347. */
  53348. export class BoundingBoxRenderer implements ISceneComponent {
  53349. /**
  53350. * The component name helpfull to identify the component in the list of scene components.
  53351. */
  53352. readonly name: string;
  53353. /**
  53354. * The scene the component belongs to.
  53355. */
  53356. scene: Scene;
  53357. /**
  53358. * Color of the bounding box lines placed in front of an object
  53359. */
  53360. frontColor: Color3;
  53361. /**
  53362. * Color of the bounding box lines placed behind an object
  53363. */
  53364. backColor: Color3;
  53365. /**
  53366. * Defines if the renderer should show the back lines or not
  53367. */
  53368. showBackLines: boolean;
  53369. /**
  53370. * @hidden
  53371. */
  53372. renderList: SmartArray<BoundingBox>;
  53373. private _colorShader;
  53374. private _vertexBuffers;
  53375. private _indexBuffer;
  53376. /**
  53377. * Instantiates a new bounding box renderer in a scene.
  53378. * @param scene the scene the renderer renders in
  53379. */
  53380. constructor(scene: Scene);
  53381. /**
  53382. * Registers the component in a given scene
  53383. */
  53384. register(): void;
  53385. private _evaluateSubMesh;
  53386. private _activeMesh;
  53387. private _prepareRessources;
  53388. private _createIndexBuffer;
  53389. /**
  53390. * Rebuilds the elements related to this component in case of
  53391. * context lost for instance.
  53392. */
  53393. rebuild(): void;
  53394. /**
  53395. * @hidden
  53396. */
  53397. reset(): void;
  53398. /**
  53399. * Render the bounding boxes of a specific rendering group
  53400. * @param renderingGroupId defines the rendering group to render
  53401. */
  53402. render(renderingGroupId: number): void;
  53403. /**
  53404. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53405. * @param mesh Define the mesh to render the occlusion bounding box for
  53406. */
  53407. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53408. /**
  53409. * Dispose and release the resources attached to this renderer.
  53410. */
  53411. dispose(): void;
  53412. }
  53413. }
  53414. declare module "babylonjs/Shaders/depth.fragment" {
  53415. /** @hidden */
  53416. export var depthPixelShader: {
  53417. name: string;
  53418. shader: string;
  53419. };
  53420. }
  53421. declare module "babylonjs/Rendering/depthRenderer" {
  53422. import { Nullable } from "babylonjs/types";
  53423. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53424. import { Scene } from "babylonjs/scene";
  53425. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53426. import { Camera } from "babylonjs/Cameras/camera";
  53427. import "babylonjs/Shaders/depth.fragment";
  53428. import "babylonjs/Shaders/depth.vertex";
  53429. /**
  53430. * This represents a depth renderer in Babylon.
  53431. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53432. */
  53433. export class DepthRenderer {
  53434. private _scene;
  53435. private _depthMap;
  53436. private _effect;
  53437. private _cachedDefines;
  53438. private _camera;
  53439. /**
  53440. * Specifiess that the depth renderer will only be used within
  53441. * the camera it is created for.
  53442. * This can help forcing its rendering during the camera processing.
  53443. */
  53444. useOnlyInActiveCamera: boolean;
  53445. /** @hidden */
  53446. static _SceneComponentInitialization: (scene: Scene) => void;
  53447. /**
  53448. * Instantiates a depth renderer
  53449. * @param scene The scene the renderer belongs to
  53450. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53451. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53452. */
  53453. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53454. /**
  53455. * Creates the depth rendering effect and checks if the effect is ready.
  53456. * @param subMesh The submesh to be used to render the depth map of
  53457. * @param useInstances If multiple world instances should be used
  53458. * @returns if the depth renderer is ready to render the depth map
  53459. */
  53460. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53461. /**
  53462. * Gets the texture which the depth map will be written to.
  53463. * @returns The depth map texture
  53464. */
  53465. getDepthMap(): RenderTargetTexture;
  53466. /**
  53467. * Disposes of the depth renderer.
  53468. */
  53469. dispose(): void;
  53470. }
  53471. }
  53472. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  53473. import { Nullable } from "babylonjs/types";
  53474. import { Scene } from "babylonjs/scene";
  53475. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  53476. import { Camera } from "babylonjs/Cameras/camera";
  53477. import { ISceneComponent } from "babylonjs/sceneComponent";
  53478. module "babylonjs/scene" {
  53479. interface Scene {
  53480. /** @hidden (Backing field) */
  53481. _depthRenderer: {
  53482. [id: string]: DepthRenderer;
  53483. };
  53484. /**
  53485. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53486. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53487. * @returns the created depth renderer
  53488. */
  53489. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53490. /**
  53491. * Disables a depth renderer for a given camera
  53492. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53493. */
  53494. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53495. }
  53496. }
  53497. /**
  53498. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  53499. * in several rendering techniques.
  53500. */
  53501. export class DepthRendererSceneComponent implements ISceneComponent {
  53502. /**
  53503. * The component name helpfull to identify the component in the list of scene components.
  53504. */
  53505. readonly name: string;
  53506. /**
  53507. * The scene the component belongs to.
  53508. */
  53509. scene: Scene;
  53510. /**
  53511. * Creates a new instance of the component for the given scene
  53512. * @param scene Defines the scene to register the component in
  53513. */
  53514. constructor(scene: Scene);
  53515. /**
  53516. * Registers the component in a given scene
  53517. */
  53518. register(): void;
  53519. /**
  53520. * Rebuilds the elements related to this component in case of
  53521. * context lost for instance.
  53522. */
  53523. rebuild(): void;
  53524. /**
  53525. * Disposes the component and the associated ressources
  53526. */
  53527. dispose(): void;
  53528. private _gatherRenderTargets;
  53529. private _gatherActiveCameraRenderTargets;
  53530. }
  53531. }
  53532. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53533. import { Nullable } from "babylonjs/types";
  53534. import { Scene } from "babylonjs/scene";
  53535. import { ISceneComponent } from "babylonjs/sceneComponent";
  53536. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53537. module "babylonjs/scene" {
  53538. interface Scene {
  53539. /** @hidden (Backing field) */
  53540. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53541. /**
  53542. * Gets or Sets the current geometry buffer associated to the scene.
  53543. */
  53544. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53545. /**
  53546. * Enables a GeometryBufferRender and associates it with the scene
  53547. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53548. * @returns the GeometryBufferRenderer
  53549. */
  53550. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53551. /**
  53552. * Disables the GeometryBufferRender associated with the scene
  53553. */
  53554. disableGeometryBufferRenderer(): void;
  53555. }
  53556. }
  53557. /**
  53558. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53559. * in several rendering techniques.
  53560. */
  53561. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53562. /**
  53563. * The component name helpful to identify the component in the list of scene components.
  53564. */
  53565. readonly name: string;
  53566. /**
  53567. * The scene the component belongs to.
  53568. */
  53569. scene: Scene;
  53570. /**
  53571. * Creates a new instance of the component for the given scene
  53572. * @param scene Defines the scene to register the component in
  53573. */
  53574. constructor(scene: Scene);
  53575. /**
  53576. * Registers the component in a given scene
  53577. */
  53578. register(): void;
  53579. /**
  53580. * Rebuilds the elements related to this component in case of
  53581. * context lost for instance.
  53582. */
  53583. rebuild(): void;
  53584. /**
  53585. * Disposes the component and the associated ressources
  53586. */
  53587. dispose(): void;
  53588. private _gatherRenderTargets;
  53589. }
  53590. }
  53591. declare module "babylonjs/Shaders/outline.fragment" {
  53592. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53593. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53594. /** @hidden */
  53595. export var outlinePixelShader: {
  53596. name: string;
  53597. shader: string;
  53598. };
  53599. }
  53600. declare module "babylonjs/Shaders/outline.vertex" {
  53601. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53602. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53603. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53604. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53605. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53606. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53607. /** @hidden */
  53608. export var outlineVertexShader: {
  53609. name: string;
  53610. shader: string;
  53611. };
  53612. }
  53613. declare module "babylonjs/Rendering/outlineRenderer" {
  53614. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53615. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  53616. import { Scene } from "babylonjs/scene";
  53617. import { ISceneComponent } from "babylonjs/sceneComponent";
  53618. import "babylonjs/Shaders/outline.fragment";
  53619. import "babylonjs/Shaders/outline.vertex";
  53620. module "babylonjs/scene" {
  53621. interface Scene {
  53622. /** @hidden */
  53623. _outlineRenderer: OutlineRenderer;
  53624. /**
  53625. * Gets the outline renderer associated with the scene
  53626. * @returns a OutlineRenderer
  53627. */
  53628. getOutlineRenderer(): OutlineRenderer;
  53629. }
  53630. }
  53631. module "babylonjs/Meshes/abstractMesh" {
  53632. interface AbstractMesh {
  53633. /** @hidden (Backing field) */
  53634. _renderOutline: boolean;
  53635. /**
  53636. * Gets or sets a boolean indicating if the outline must be rendered as well
  53637. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  53638. */
  53639. renderOutline: boolean;
  53640. /** @hidden (Backing field) */
  53641. _renderOverlay: boolean;
  53642. /**
  53643. * Gets or sets a boolean indicating if the overlay must be rendered as well
  53644. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  53645. */
  53646. renderOverlay: boolean;
  53647. }
  53648. }
  53649. /**
  53650. * This class is responsible to draw bothe outline/overlay of meshes.
  53651. * It should not be used directly but through the available method on mesh.
  53652. */
  53653. export class OutlineRenderer implements ISceneComponent {
  53654. /**
  53655. * The name of the component. Each component must have a unique name.
  53656. */
  53657. name: string;
  53658. /**
  53659. * The scene the component belongs to.
  53660. */
  53661. scene: Scene;
  53662. /**
  53663. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  53664. */
  53665. zOffset: number;
  53666. private _engine;
  53667. private _effect;
  53668. private _cachedDefines;
  53669. private _savedDepthWrite;
  53670. /**
  53671. * Instantiates a new outline renderer. (There could be only one per scene).
  53672. * @param scene Defines the scene it belongs to
  53673. */
  53674. constructor(scene: Scene);
  53675. /**
  53676. * Register the component to one instance of a scene.
  53677. */
  53678. register(): void;
  53679. /**
  53680. * Rebuilds the elements related to this component in case of
  53681. * context lost for instance.
  53682. */
  53683. rebuild(): void;
  53684. /**
  53685. * Disposes the component and the associated ressources.
  53686. */
  53687. dispose(): void;
  53688. /**
  53689. * Renders the outline in the canvas.
  53690. * @param subMesh Defines the sumesh to render
  53691. * @param batch Defines the batch of meshes in case of instances
  53692. * @param useOverlay Defines if the rendering is for the overlay or the outline
  53693. */
  53694. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  53695. /**
  53696. * Returns whether or not the outline renderer is ready for a given submesh.
  53697. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  53698. * @param subMesh Defines the submesh to check readyness for
  53699. * @param useInstances Defines wheter wee are trying to render instances or not
  53700. * @returns true if ready otherwise false
  53701. */
  53702. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53703. private _beforeRenderingMesh;
  53704. private _afterRenderingMesh;
  53705. }
  53706. }
  53707. declare module "babylonjs/Rendering/index" {
  53708. export * from "babylonjs/Rendering/boundingBoxRenderer";
  53709. export * from "babylonjs/Rendering/depthRenderer";
  53710. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  53711. export * from "babylonjs/Rendering/edgesRenderer";
  53712. export * from "babylonjs/Rendering/geometryBufferRenderer";
  53713. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53714. export * from "babylonjs/Rendering/outlineRenderer";
  53715. export * from "babylonjs/Rendering/renderingGroup";
  53716. export * from "babylonjs/Rendering/renderingManager";
  53717. export * from "babylonjs/Rendering/utilityLayerRenderer";
  53718. }
  53719. declare module "babylonjs/Sprites/index" {
  53720. export * from "babylonjs/Sprites/sprite";
  53721. export * from "babylonjs/Sprites/spriteManager";
  53722. export * from "babylonjs/Sprites/spriteSceneComponent";
  53723. }
  53724. declare module "babylonjs/Misc/assetsManager" {
  53725. import { Scene } from "babylonjs/scene";
  53726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53727. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53728. import { Skeleton } from "babylonjs/Bones/skeleton";
  53729. import { Observable } from "babylonjs/Misc/observable";
  53730. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53731. import { Texture } from "babylonjs/Materials/Textures/texture";
  53732. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53733. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  53734. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  53735. /**
  53736. * Defines the list of states available for a task inside a AssetsManager
  53737. */
  53738. export enum AssetTaskState {
  53739. /**
  53740. * Initialization
  53741. */
  53742. INIT = 0,
  53743. /**
  53744. * Running
  53745. */
  53746. RUNNING = 1,
  53747. /**
  53748. * Done
  53749. */
  53750. DONE = 2,
  53751. /**
  53752. * Error
  53753. */
  53754. ERROR = 3
  53755. }
  53756. /**
  53757. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  53758. */
  53759. export abstract class AbstractAssetTask {
  53760. /**
  53761. * Task name
  53762. */ name: string;
  53763. /**
  53764. * Callback called when the task is successful
  53765. */
  53766. onSuccess: (task: any) => void;
  53767. /**
  53768. * Callback called when the task is not successful
  53769. */
  53770. onError: (task: any, message?: string, exception?: any) => void;
  53771. /**
  53772. * Creates a new AssetsManager
  53773. * @param name defines the name of the task
  53774. */
  53775. constructor(
  53776. /**
  53777. * Task name
  53778. */ name: string);
  53779. private _isCompleted;
  53780. private _taskState;
  53781. private _errorObject;
  53782. /**
  53783. * Get if the task is completed
  53784. */
  53785. readonly isCompleted: boolean;
  53786. /**
  53787. * Gets the current state of the task
  53788. */
  53789. readonly taskState: AssetTaskState;
  53790. /**
  53791. * Gets the current error object (if task is in error)
  53792. */
  53793. readonly errorObject: {
  53794. message?: string;
  53795. exception?: any;
  53796. };
  53797. /**
  53798. * Internal only
  53799. * @hidden
  53800. */
  53801. _setErrorObject(message?: string, exception?: any): void;
  53802. /**
  53803. * Execute the current task
  53804. * @param scene defines the scene where you want your assets to be loaded
  53805. * @param onSuccess is a callback called when the task is successfully executed
  53806. * @param onError is a callback called if an error occurs
  53807. */
  53808. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53809. /**
  53810. * Execute the current task
  53811. * @param scene defines the scene where you want your assets to be loaded
  53812. * @param onSuccess is a callback called when the task is successfully executed
  53813. * @param onError is a callback called if an error occurs
  53814. */
  53815. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53816. /**
  53817. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  53818. * This can be used with failed tasks that have the reason for failure fixed.
  53819. */
  53820. reset(): void;
  53821. private onErrorCallback;
  53822. private onDoneCallback;
  53823. }
  53824. /**
  53825. * Define the interface used by progress events raised during assets loading
  53826. */
  53827. export interface IAssetsProgressEvent {
  53828. /**
  53829. * Defines the number of remaining tasks to process
  53830. */
  53831. remainingCount: number;
  53832. /**
  53833. * Defines the total number of tasks
  53834. */
  53835. totalCount: number;
  53836. /**
  53837. * Defines the task that was just processed
  53838. */
  53839. task: AbstractAssetTask;
  53840. }
  53841. /**
  53842. * Class used to share progress information about assets loading
  53843. */
  53844. export class AssetsProgressEvent implements IAssetsProgressEvent {
  53845. /**
  53846. * Defines the number of remaining tasks to process
  53847. */
  53848. remainingCount: number;
  53849. /**
  53850. * Defines the total number of tasks
  53851. */
  53852. totalCount: number;
  53853. /**
  53854. * Defines the task that was just processed
  53855. */
  53856. task: AbstractAssetTask;
  53857. /**
  53858. * Creates a AssetsProgressEvent
  53859. * @param remainingCount defines the number of remaining tasks to process
  53860. * @param totalCount defines the total number of tasks
  53861. * @param task defines the task that was just processed
  53862. */
  53863. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  53864. }
  53865. /**
  53866. * Define a task used by AssetsManager to load meshes
  53867. */
  53868. export class MeshAssetTask extends AbstractAssetTask {
  53869. /**
  53870. * Defines the name of the task
  53871. */
  53872. name: string;
  53873. /**
  53874. * Defines the list of mesh's names you want to load
  53875. */
  53876. meshesNames: any;
  53877. /**
  53878. * Defines the root url to use as a base to load your meshes and associated resources
  53879. */
  53880. rootUrl: string;
  53881. /**
  53882. * Defines the filename of the scene to load from
  53883. */
  53884. sceneFilename: string;
  53885. /**
  53886. * Gets the list of loaded meshes
  53887. */
  53888. loadedMeshes: Array<AbstractMesh>;
  53889. /**
  53890. * Gets the list of loaded particle systems
  53891. */
  53892. loadedParticleSystems: Array<IParticleSystem>;
  53893. /**
  53894. * Gets the list of loaded skeletons
  53895. */
  53896. loadedSkeletons: Array<Skeleton>;
  53897. /**
  53898. * Gets the list of loaded animation groups
  53899. */
  53900. loadedAnimationGroups: Array<AnimationGroup>;
  53901. /**
  53902. * Callback called when the task is successful
  53903. */
  53904. onSuccess: (task: MeshAssetTask) => void;
  53905. /**
  53906. * Callback called when the task is successful
  53907. */
  53908. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  53909. /**
  53910. * Creates a new MeshAssetTask
  53911. * @param name defines the name of the task
  53912. * @param meshesNames defines the list of mesh's names you want to load
  53913. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  53914. * @param sceneFilename defines the filename of the scene to load from
  53915. */
  53916. constructor(
  53917. /**
  53918. * Defines the name of the task
  53919. */
  53920. name: string,
  53921. /**
  53922. * Defines the list of mesh's names you want to load
  53923. */
  53924. meshesNames: any,
  53925. /**
  53926. * Defines the root url to use as a base to load your meshes and associated resources
  53927. */
  53928. rootUrl: string,
  53929. /**
  53930. * Defines the filename of the scene to load from
  53931. */
  53932. sceneFilename: string);
  53933. /**
  53934. * Execute the current task
  53935. * @param scene defines the scene where you want your assets to be loaded
  53936. * @param onSuccess is a callback called when the task is successfully executed
  53937. * @param onError is a callback called if an error occurs
  53938. */
  53939. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53940. }
  53941. /**
  53942. * Define a task used by AssetsManager to load text content
  53943. */
  53944. export class TextFileAssetTask extends AbstractAssetTask {
  53945. /**
  53946. * Defines the name of the task
  53947. */
  53948. name: string;
  53949. /**
  53950. * Defines the location of the file to load
  53951. */
  53952. url: string;
  53953. /**
  53954. * Gets the loaded text string
  53955. */
  53956. text: string;
  53957. /**
  53958. * Callback called when the task is successful
  53959. */
  53960. onSuccess: (task: TextFileAssetTask) => void;
  53961. /**
  53962. * Callback called when the task is successful
  53963. */
  53964. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  53965. /**
  53966. * Creates a new TextFileAssetTask object
  53967. * @param name defines the name of the task
  53968. * @param url defines the location of the file to load
  53969. */
  53970. constructor(
  53971. /**
  53972. * Defines the name of the task
  53973. */
  53974. name: string,
  53975. /**
  53976. * Defines the location of the file to load
  53977. */
  53978. url: string);
  53979. /**
  53980. * Execute the current task
  53981. * @param scene defines the scene where you want your assets to be loaded
  53982. * @param onSuccess is a callback called when the task is successfully executed
  53983. * @param onError is a callback called if an error occurs
  53984. */
  53985. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53986. }
  53987. /**
  53988. * Define a task used by AssetsManager to load binary data
  53989. */
  53990. export class BinaryFileAssetTask extends AbstractAssetTask {
  53991. /**
  53992. * Defines the name of the task
  53993. */
  53994. name: string;
  53995. /**
  53996. * Defines the location of the file to load
  53997. */
  53998. url: string;
  53999. /**
  54000. * Gets the lodaded data (as an array buffer)
  54001. */
  54002. data: ArrayBuffer;
  54003. /**
  54004. * Callback called when the task is successful
  54005. */
  54006. onSuccess: (task: BinaryFileAssetTask) => void;
  54007. /**
  54008. * Callback called when the task is successful
  54009. */
  54010. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54011. /**
  54012. * Creates a new BinaryFileAssetTask object
  54013. * @param name defines the name of the new task
  54014. * @param url defines the location of the file to load
  54015. */
  54016. constructor(
  54017. /**
  54018. * Defines the name of the task
  54019. */
  54020. name: string,
  54021. /**
  54022. * Defines the location of the file to load
  54023. */
  54024. url: string);
  54025. /**
  54026. * Execute the current task
  54027. * @param scene defines the scene where you want your assets to be loaded
  54028. * @param onSuccess is a callback called when the task is successfully executed
  54029. * @param onError is a callback called if an error occurs
  54030. */
  54031. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54032. }
  54033. /**
  54034. * Define a task used by AssetsManager to load images
  54035. */
  54036. export class ImageAssetTask extends AbstractAssetTask {
  54037. /**
  54038. * Defines the name of the task
  54039. */
  54040. name: string;
  54041. /**
  54042. * Defines the location of the image to load
  54043. */
  54044. url: string;
  54045. /**
  54046. * Gets the loaded images
  54047. */
  54048. image: HTMLImageElement;
  54049. /**
  54050. * Callback called when the task is successful
  54051. */
  54052. onSuccess: (task: ImageAssetTask) => void;
  54053. /**
  54054. * Callback called when the task is successful
  54055. */
  54056. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54057. /**
  54058. * Creates a new ImageAssetTask
  54059. * @param name defines the name of the task
  54060. * @param url defines the location of the image to load
  54061. */
  54062. constructor(
  54063. /**
  54064. * Defines the name of the task
  54065. */
  54066. name: string,
  54067. /**
  54068. * Defines the location of the image to load
  54069. */
  54070. url: string);
  54071. /**
  54072. * Execute the current task
  54073. * @param scene defines the scene where you want your assets to be loaded
  54074. * @param onSuccess is a callback called when the task is successfully executed
  54075. * @param onError is a callback called if an error occurs
  54076. */
  54077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54078. }
  54079. /**
  54080. * Defines the interface used by texture loading tasks
  54081. */
  54082. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54083. /**
  54084. * Gets the loaded texture
  54085. */
  54086. texture: TEX;
  54087. }
  54088. /**
  54089. * Define a task used by AssetsManager to load 2D textures
  54090. */
  54091. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54092. /**
  54093. * Defines the name of the task
  54094. */
  54095. name: string;
  54096. /**
  54097. * Defines the location of the file to load
  54098. */
  54099. url: string;
  54100. /**
  54101. * Defines if mipmap should not be generated (default is false)
  54102. */
  54103. noMipmap?: boolean | undefined;
  54104. /**
  54105. * Defines if texture must be inverted on Y axis (default is false)
  54106. */
  54107. invertY?: boolean | undefined;
  54108. /**
  54109. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54110. */
  54111. samplingMode: number;
  54112. /**
  54113. * Gets the loaded texture
  54114. */
  54115. texture: Texture;
  54116. /**
  54117. * Callback called when the task is successful
  54118. */
  54119. onSuccess: (task: TextureAssetTask) => void;
  54120. /**
  54121. * Callback called when the task is successful
  54122. */
  54123. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54124. /**
  54125. * Creates a new TextureAssetTask object
  54126. * @param name defines the name of the task
  54127. * @param url defines the location of the file to load
  54128. * @param noMipmap defines if mipmap should not be generated (default is false)
  54129. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54130. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54131. */
  54132. constructor(
  54133. /**
  54134. * Defines the name of the task
  54135. */
  54136. name: string,
  54137. /**
  54138. * Defines the location of the file to load
  54139. */
  54140. url: string,
  54141. /**
  54142. * Defines if mipmap should not be generated (default is false)
  54143. */
  54144. noMipmap?: boolean | undefined,
  54145. /**
  54146. * Defines if texture must be inverted on Y axis (default is false)
  54147. */
  54148. invertY?: boolean | undefined,
  54149. /**
  54150. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54151. */
  54152. samplingMode?: number);
  54153. /**
  54154. * Execute the current task
  54155. * @param scene defines the scene where you want your assets to be loaded
  54156. * @param onSuccess is a callback called when the task is successfully executed
  54157. * @param onError is a callback called if an error occurs
  54158. */
  54159. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54160. }
  54161. /**
  54162. * Define a task used by AssetsManager to load cube textures
  54163. */
  54164. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54165. /**
  54166. * Defines the name of the task
  54167. */
  54168. name: string;
  54169. /**
  54170. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54171. */
  54172. url: string;
  54173. /**
  54174. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54175. */
  54176. extensions?: string[] | undefined;
  54177. /**
  54178. * Defines if mipmaps should not be generated (default is false)
  54179. */
  54180. noMipmap?: boolean | undefined;
  54181. /**
  54182. * Defines the explicit list of files (undefined by default)
  54183. */
  54184. files?: string[] | undefined;
  54185. /**
  54186. * Gets the loaded texture
  54187. */
  54188. texture: CubeTexture;
  54189. /**
  54190. * Callback called when the task is successful
  54191. */
  54192. onSuccess: (task: CubeTextureAssetTask) => void;
  54193. /**
  54194. * Callback called when the task is successful
  54195. */
  54196. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54197. /**
  54198. * Creates a new CubeTextureAssetTask
  54199. * @param name defines the name of the task
  54200. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54201. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54202. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54203. * @param files defines the explicit list of files (undefined by default)
  54204. */
  54205. constructor(
  54206. /**
  54207. * Defines the name of the task
  54208. */
  54209. name: string,
  54210. /**
  54211. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54212. */
  54213. url: string,
  54214. /**
  54215. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54216. */
  54217. extensions?: string[] | undefined,
  54218. /**
  54219. * Defines if mipmaps should not be generated (default is false)
  54220. */
  54221. noMipmap?: boolean | undefined,
  54222. /**
  54223. * Defines the explicit list of files (undefined by default)
  54224. */
  54225. files?: string[] | undefined);
  54226. /**
  54227. * Execute the current task
  54228. * @param scene defines the scene where you want your assets to be loaded
  54229. * @param onSuccess is a callback called when the task is successfully executed
  54230. * @param onError is a callback called if an error occurs
  54231. */
  54232. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54233. }
  54234. /**
  54235. * Define a task used by AssetsManager to load HDR cube textures
  54236. */
  54237. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54238. /**
  54239. * Defines the name of the task
  54240. */
  54241. name: string;
  54242. /**
  54243. * Defines the location of the file to load
  54244. */
  54245. url: string;
  54246. /**
  54247. * Defines the desired size (the more it increases the longer the generation will be)
  54248. */
  54249. size: number;
  54250. /**
  54251. * Defines if mipmaps should not be generated (default is false)
  54252. */
  54253. noMipmap: boolean;
  54254. /**
  54255. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54256. */
  54257. generateHarmonics: boolean;
  54258. /**
  54259. * 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)
  54260. */
  54261. gammaSpace: boolean;
  54262. /**
  54263. * Internal Use Only
  54264. */
  54265. reserved: boolean;
  54266. /**
  54267. * Gets the loaded texture
  54268. */
  54269. texture: HDRCubeTexture;
  54270. /**
  54271. * Callback called when the task is successful
  54272. */
  54273. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54274. /**
  54275. * Callback called when the task is successful
  54276. */
  54277. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54278. /**
  54279. * Creates a new HDRCubeTextureAssetTask object
  54280. * @param name defines the name of the task
  54281. * @param url defines the location of the file to load
  54282. * @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.
  54283. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54284. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54285. * @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)
  54286. * @param reserved Internal use only
  54287. */
  54288. constructor(
  54289. /**
  54290. * Defines the name of the task
  54291. */
  54292. name: string,
  54293. /**
  54294. * Defines the location of the file to load
  54295. */
  54296. url: string,
  54297. /**
  54298. * Defines the desired size (the more it increases the longer the generation will be)
  54299. */
  54300. size: number,
  54301. /**
  54302. * Defines if mipmaps should not be generated (default is false)
  54303. */
  54304. noMipmap?: boolean,
  54305. /**
  54306. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54307. */
  54308. generateHarmonics?: boolean,
  54309. /**
  54310. * 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)
  54311. */
  54312. gammaSpace?: boolean,
  54313. /**
  54314. * Internal Use Only
  54315. */
  54316. reserved?: boolean);
  54317. /**
  54318. * Execute the current task
  54319. * @param scene defines the scene where you want your assets to be loaded
  54320. * @param onSuccess is a callback called when the task is successfully executed
  54321. * @param onError is a callback called if an error occurs
  54322. */
  54323. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54324. }
  54325. /**
  54326. * This class can be used to easily import assets into a scene
  54327. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54328. */
  54329. export class AssetsManager {
  54330. private _scene;
  54331. private _isLoading;
  54332. protected _tasks: AbstractAssetTask[];
  54333. protected _waitingTasksCount: number;
  54334. protected _totalTasksCount: number;
  54335. /**
  54336. * Callback called when all tasks are processed
  54337. */
  54338. onFinish: (tasks: AbstractAssetTask[]) => void;
  54339. /**
  54340. * Callback called when a task is successful
  54341. */
  54342. onTaskSuccess: (task: AbstractAssetTask) => void;
  54343. /**
  54344. * Callback called when a task had an error
  54345. */
  54346. onTaskError: (task: AbstractAssetTask) => void;
  54347. /**
  54348. * Callback called when a task is done (whatever the result is)
  54349. */
  54350. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54351. /**
  54352. * Observable called when all tasks are processed
  54353. */
  54354. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54355. /**
  54356. * Observable called when a task had an error
  54357. */
  54358. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54359. /**
  54360. * Observable called when a task is successful
  54361. */
  54362. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54363. /**
  54364. * Observable called when a task is done (whatever the result is)
  54365. */
  54366. onProgressObservable: Observable<IAssetsProgressEvent>;
  54367. /**
  54368. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54369. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54370. */
  54371. useDefaultLoadingScreen: boolean;
  54372. /**
  54373. * Creates a new AssetsManager
  54374. * @param scene defines the scene to work on
  54375. */
  54376. constructor(scene: Scene);
  54377. /**
  54378. * Add a MeshAssetTask to the list of active tasks
  54379. * @param taskName defines the name of the new task
  54380. * @param meshesNames defines the name of meshes to load
  54381. * @param rootUrl defines the root url to use to locate files
  54382. * @param sceneFilename defines the filename of the scene file
  54383. * @returns a new MeshAssetTask object
  54384. */
  54385. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54386. /**
  54387. * Add a TextFileAssetTask to the list of active tasks
  54388. * @param taskName defines the name of the new task
  54389. * @param url defines the url of the file to load
  54390. * @returns a new TextFileAssetTask object
  54391. */
  54392. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54393. /**
  54394. * Add a BinaryFileAssetTask to the list of active tasks
  54395. * @param taskName defines the name of the new task
  54396. * @param url defines the url of the file to load
  54397. * @returns a new BinaryFileAssetTask object
  54398. */
  54399. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54400. /**
  54401. * Add a ImageAssetTask to the list of active tasks
  54402. * @param taskName defines the name of the new task
  54403. * @param url defines the url of the file to load
  54404. * @returns a new ImageAssetTask object
  54405. */
  54406. addImageTask(taskName: string, url: string): ImageAssetTask;
  54407. /**
  54408. * Add a TextureAssetTask to the list of active tasks
  54409. * @param taskName defines the name of the new task
  54410. * @param url defines the url of the file to load
  54411. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54412. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54413. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54414. * @returns a new TextureAssetTask object
  54415. */
  54416. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54417. /**
  54418. * Add a CubeTextureAssetTask to the list of active tasks
  54419. * @param taskName defines the name of the new task
  54420. * @param url defines the url of the file to load
  54421. * @param extensions defines the extension to use to load the cube map (can be null)
  54422. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54423. * @param files defines the list of files to load (can be null)
  54424. * @returns a new CubeTextureAssetTask object
  54425. */
  54426. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54427. /**
  54428. *
  54429. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54430. * @param taskName defines the name of the new task
  54431. * @param url defines the url of the file to load
  54432. * @param size defines the size you want for the cubemap (can be null)
  54433. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54434. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54435. * @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)
  54436. * @param reserved Internal use only
  54437. * @returns a new HDRCubeTextureAssetTask object
  54438. */
  54439. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54440. /**
  54441. * Remove a task from the assets manager.
  54442. * @param task the task to remove
  54443. */
  54444. removeTask(task: AbstractAssetTask): void;
  54445. private _decreaseWaitingTasksCount;
  54446. private _runTask;
  54447. /**
  54448. * Reset the AssetsManager and remove all tasks
  54449. * @return the current instance of the AssetsManager
  54450. */
  54451. reset(): AssetsManager;
  54452. /**
  54453. * Start the loading process
  54454. * @return the current instance of the AssetsManager
  54455. */
  54456. load(): AssetsManager;
  54457. }
  54458. }
  54459. declare module "babylonjs/Misc/deferred" {
  54460. /**
  54461. * Wrapper class for promise with external resolve and reject.
  54462. */
  54463. export class Deferred<T> {
  54464. /**
  54465. * The promise associated with this deferred object.
  54466. */
  54467. readonly promise: Promise<T>;
  54468. private _resolve;
  54469. private _reject;
  54470. /**
  54471. * The resolve method of the promise associated with this deferred object.
  54472. */
  54473. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54474. /**
  54475. * The reject method of the promise associated with this deferred object.
  54476. */
  54477. readonly reject: (reason?: any) => void;
  54478. /**
  54479. * Constructor for this deferred object.
  54480. */
  54481. constructor();
  54482. }
  54483. }
  54484. declare module "babylonjs/Misc/filesInput" {
  54485. import { Engine } from "babylonjs/Engines/engine";
  54486. import { Scene } from "babylonjs/scene";
  54487. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  54488. /**
  54489. * Class used to help managing file picking and drag'n'drop
  54490. */
  54491. export class FilesInput {
  54492. /**
  54493. * List of files ready to be loaded
  54494. */
  54495. static readonly FilesToLoad: {
  54496. [key: string]: File;
  54497. };
  54498. /**
  54499. * Callback called when a file is processed
  54500. */
  54501. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  54502. private _engine;
  54503. private _currentScene;
  54504. private _sceneLoadedCallback;
  54505. private _progressCallback;
  54506. private _additionalRenderLoopLogicCallback;
  54507. private _textureLoadingCallback;
  54508. private _startingProcessingFilesCallback;
  54509. private _onReloadCallback;
  54510. private _errorCallback;
  54511. private _elementToMonitor;
  54512. private _sceneFileToLoad;
  54513. private _filesToLoad;
  54514. /**
  54515. * Creates a new FilesInput
  54516. * @param engine defines the rendering engine
  54517. * @param scene defines the hosting scene
  54518. * @param sceneLoadedCallback callback called when scene is loaded
  54519. * @param progressCallback callback called to track progress
  54520. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  54521. * @param textureLoadingCallback callback called when a texture is loading
  54522. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  54523. * @param onReloadCallback callback called when a reload is requested
  54524. * @param errorCallback callback call if an error occurs
  54525. */
  54526. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  54527. private _dragEnterHandler;
  54528. private _dragOverHandler;
  54529. private _dropHandler;
  54530. /**
  54531. * Calls this function to listen to drag'n'drop events on a specific DOM element
  54532. * @param elementToMonitor defines the DOM element to track
  54533. */
  54534. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  54535. /**
  54536. * Release all associated resources
  54537. */
  54538. dispose(): void;
  54539. private renderFunction;
  54540. private drag;
  54541. private drop;
  54542. private _traverseFolder;
  54543. private _processFiles;
  54544. /**
  54545. * Load files from a drop event
  54546. * @param event defines the drop event to use as source
  54547. */
  54548. loadFiles(event: any): void;
  54549. private _processReload;
  54550. /**
  54551. * Reload the current scene from the loaded files
  54552. */
  54553. reload(): void;
  54554. }
  54555. }
  54556. declare module "babylonjs/Misc/HighDynamicRange/index" {
  54557. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  54558. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  54559. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54560. }
  54561. declare module "babylonjs/Misc/sceneOptimizer" {
  54562. import { Scene, IDisposable } from "babylonjs/scene";
  54563. import { Observable } from "babylonjs/Misc/observable";
  54564. /**
  54565. * Defines the root class used to create scene optimization to use with SceneOptimizer
  54566. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54567. */
  54568. export class SceneOptimization {
  54569. /**
  54570. * Defines the priority of this optimization (0 by default which means first in the list)
  54571. */
  54572. priority: number;
  54573. /**
  54574. * Gets a string describing the action executed by the current optimization
  54575. * @returns description string
  54576. */
  54577. getDescription(): string;
  54578. /**
  54579. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54580. * @param scene defines the current scene where to apply this optimization
  54581. * @param optimizer defines the current optimizer
  54582. * @returns true if everything that can be done was applied
  54583. */
  54584. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54585. /**
  54586. * Creates the SceneOptimization object
  54587. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54588. * @param desc defines the description associated with the optimization
  54589. */
  54590. constructor(
  54591. /**
  54592. * Defines the priority of this optimization (0 by default which means first in the list)
  54593. */
  54594. priority?: number);
  54595. }
  54596. /**
  54597. * Defines an optimization used to reduce the size of render target textures
  54598. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54599. */
  54600. export class TextureOptimization extends SceneOptimization {
  54601. /**
  54602. * Defines the priority of this optimization (0 by default which means first in the list)
  54603. */
  54604. priority: number;
  54605. /**
  54606. * 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
  54607. */
  54608. maximumSize: number;
  54609. /**
  54610. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54611. */
  54612. step: number;
  54613. /**
  54614. * Gets a string describing the action executed by the current optimization
  54615. * @returns description string
  54616. */
  54617. getDescription(): string;
  54618. /**
  54619. * Creates the TextureOptimization object
  54620. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54621. * @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
  54622. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54623. */
  54624. constructor(
  54625. /**
  54626. * Defines the priority of this optimization (0 by default which means first in the list)
  54627. */
  54628. priority?: number,
  54629. /**
  54630. * 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
  54631. */
  54632. maximumSize?: number,
  54633. /**
  54634. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54635. */
  54636. step?: number);
  54637. /**
  54638. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54639. * @param scene defines the current scene where to apply this optimization
  54640. * @param optimizer defines the current optimizer
  54641. * @returns true if everything that can be done was applied
  54642. */
  54643. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54644. }
  54645. /**
  54646. * Defines an optimization used to increase or decrease the rendering resolution
  54647. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54648. */
  54649. export class HardwareScalingOptimization extends SceneOptimization {
  54650. /**
  54651. * Defines the priority of this optimization (0 by default which means first in the list)
  54652. */
  54653. priority: number;
  54654. /**
  54655. * Defines the maximum scale to use (2 by default)
  54656. */
  54657. maximumScale: number;
  54658. /**
  54659. * Defines the step to use between two passes (0.5 by default)
  54660. */
  54661. step: number;
  54662. private _currentScale;
  54663. private _directionOffset;
  54664. /**
  54665. * Gets a string describing the action executed by the current optimization
  54666. * @return description string
  54667. */
  54668. getDescription(): string;
  54669. /**
  54670. * Creates the HardwareScalingOptimization object
  54671. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54672. * @param maximumScale defines the maximum scale to use (2 by default)
  54673. * @param step defines the step to use between two passes (0.5 by default)
  54674. */
  54675. constructor(
  54676. /**
  54677. * Defines the priority of this optimization (0 by default which means first in the list)
  54678. */
  54679. priority?: number,
  54680. /**
  54681. * Defines the maximum scale to use (2 by default)
  54682. */
  54683. maximumScale?: number,
  54684. /**
  54685. * Defines the step to use between two passes (0.5 by default)
  54686. */
  54687. step?: number);
  54688. /**
  54689. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54690. * @param scene defines the current scene where to apply this optimization
  54691. * @param optimizer defines the current optimizer
  54692. * @returns true if everything that can be done was applied
  54693. */
  54694. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54695. }
  54696. /**
  54697. * Defines an optimization used to remove shadows
  54698. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54699. */
  54700. export class ShadowsOptimization extends SceneOptimization {
  54701. /**
  54702. * Gets a string describing the action executed by the current optimization
  54703. * @return description string
  54704. */
  54705. getDescription(): string;
  54706. /**
  54707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54708. * @param scene defines the current scene where to apply this optimization
  54709. * @param optimizer defines the current optimizer
  54710. * @returns true if everything that can be done was applied
  54711. */
  54712. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54713. }
  54714. /**
  54715. * Defines an optimization used to turn post-processes off
  54716. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54717. */
  54718. export class PostProcessesOptimization extends SceneOptimization {
  54719. /**
  54720. * Gets a string describing the action executed by the current optimization
  54721. * @return description string
  54722. */
  54723. getDescription(): string;
  54724. /**
  54725. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54726. * @param scene defines the current scene where to apply this optimization
  54727. * @param optimizer defines the current optimizer
  54728. * @returns true if everything that can be done was applied
  54729. */
  54730. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54731. }
  54732. /**
  54733. * Defines an optimization used to turn lens flares off
  54734. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54735. */
  54736. export class LensFlaresOptimization extends SceneOptimization {
  54737. /**
  54738. * Gets a string describing the action executed by the current optimization
  54739. * @return description string
  54740. */
  54741. getDescription(): string;
  54742. /**
  54743. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54744. * @param scene defines the current scene where to apply this optimization
  54745. * @param optimizer defines the current optimizer
  54746. * @returns true if everything that can be done was applied
  54747. */
  54748. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54749. }
  54750. /**
  54751. * Defines an optimization based on user defined callback.
  54752. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54753. */
  54754. export class CustomOptimization extends SceneOptimization {
  54755. /**
  54756. * Callback called to apply the custom optimization.
  54757. */
  54758. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  54759. /**
  54760. * Callback called to get custom description
  54761. */
  54762. onGetDescription: () => string;
  54763. /**
  54764. * Gets a string describing the action executed by the current optimization
  54765. * @returns description string
  54766. */
  54767. getDescription(): string;
  54768. /**
  54769. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54770. * @param scene defines the current scene where to apply this optimization
  54771. * @param optimizer defines the current optimizer
  54772. * @returns true if everything that can be done was applied
  54773. */
  54774. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54775. }
  54776. /**
  54777. * Defines an optimization used to turn particles off
  54778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54779. */
  54780. export class ParticlesOptimization extends SceneOptimization {
  54781. /**
  54782. * Gets a string describing the action executed by the current optimization
  54783. * @return description string
  54784. */
  54785. getDescription(): string;
  54786. /**
  54787. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54788. * @param scene defines the current scene where to apply this optimization
  54789. * @param optimizer defines the current optimizer
  54790. * @returns true if everything that can be done was applied
  54791. */
  54792. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54793. }
  54794. /**
  54795. * Defines an optimization used to turn render targets off
  54796. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54797. */
  54798. export class RenderTargetsOptimization extends SceneOptimization {
  54799. /**
  54800. * Gets a string describing the action executed by the current optimization
  54801. * @return description string
  54802. */
  54803. getDescription(): string;
  54804. /**
  54805. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54806. * @param scene defines the current scene where to apply this optimization
  54807. * @param optimizer defines the current optimizer
  54808. * @returns true if everything that can be done was applied
  54809. */
  54810. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54811. }
  54812. /**
  54813. * Defines an optimization used to merge meshes with compatible materials
  54814. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54815. */
  54816. export class MergeMeshesOptimization extends SceneOptimization {
  54817. private static _UpdateSelectionTree;
  54818. /**
  54819. * Gets or sets a boolean which defines if optimization octree has to be updated
  54820. */
  54821. /**
  54822. * Gets or sets a boolean which defines if optimization octree has to be updated
  54823. */
  54824. static UpdateSelectionTree: boolean;
  54825. /**
  54826. * Gets a string describing the action executed by the current optimization
  54827. * @return description string
  54828. */
  54829. getDescription(): string;
  54830. private _canBeMerged;
  54831. /**
  54832. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54833. * @param scene defines the current scene where to apply this optimization
  54834. * @param optimizer defines the current optimizer
  54835. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  54836. * @returns true if everything that can be done was applied
  54837. */
  54838. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  54839. }
  54840. /**
  54841. * Defines a list of options used by SceneOptimizer
  54842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54843. */
  54844. export class SceneOptimizerOptions {
  54845. /**
  54846. * Defines the target frame rate to reach (60 by default)
  54847. */
  54848. targetFrameRate: number;
  54849. /**
  54850. * Defines the interval between two checkes (2000ms by default)
  54851. */
  54852. trackerDuration: number;
  54853. /**
  54854. * Gets the list of optimizations to apply
  54855. */
  54856. optimizations: SceneOptimization[];
  54857. /**
  54858. * Creates a new list of options used by SceneOptimizer
  54859. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  54860. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  54861. */
  54862. constructor(
  54863. /**
  54864. * Defines the target frame rate to reach (60 by default)
  54865. */
  54866. targetFrameRate?: number,
  54867. /**
  54868. * Defines the interval between two checkes (2000ms by default)
  54869. */
  54870. trackerDuration?: number);
  54871. /**
  54872. * Add a new optimization
  54873. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  54874. * @returns the current SceneOptimizerOptions
  54875. */
  54876. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  54877. /**
  54878. * Add a new custom optimization
  54879. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  54880. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  54881. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54882. * @returns the current SceneOptimizerOptions
  54883. */
  54884. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  54885. /**
  54886. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  54887. * @param targetFrameRate defines the target frame rate (60 by default)
  54888. * @returns a SceneOptimizerOptions object
  54889. */
  54890. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54891. /**
  54892. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  54893. * @param targetFrameRate defines the target frame rate (60 by default)
  54894. * @returns a SceneOptimizerOptions object
  54895. */
  54896. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54897. /**
  54898. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  54899. * @param targetFrameRate defines the target frame rate (60 by default)
  54900. * @returns a SceneOptimizerOptions object
  54901. */
  54902. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54903. }
  54904. /**
  54905. * Class used to run optimizations in order to reach a target frame rate
  54906. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54907. */
  54908. export class SceneOptimizer implements IDisposable {
  54909. private _isRunning;
  54910. private _options;
  54911. private _scene;
  54912. private _currentPriorityLevel;
  54913. private _targetFrameRate;
  54914. private _trackerDuration;
  54915. private _currentFrameRate;
  54916. private _sceneDisposeObserver;
  54917. private _improvementMode;
  54918. /**
  54919. * Defines an observable called when the optimizer reaches the target frame rate
  54920. */
  54921. onSuccessObservable: Observable<SceneOptimizer>;
  54922. /**
  54923. * Defines an observable called when the optimizer enables an optimization
  54924. */
  54925. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  54926. /**
  54927. * Defines an observable called when the optimizer is not able to reach the target frame rate
  54928. */
  54929. onFailureObservable: Observable<SceneOptimizer>;
  54930. /**
  54931. * Gets a boolean indicating if the optimizer is in improvement mode
  54932. */
  54933. readonly isInImprovementMode: boolean;
  54934. /**
  54935. * Gets the current priority level (0 at start)
  54936. */
  54937. readonly currentPriorityLevel: number;
  54938. /**
  54939. * Gets the current frame rate checked by the SceneOptimizer
  54940. */
  54941. readonly currentFrameRate: number;
  54942. /**
  54943. * Gets or sets the current target frame rate (60 by default)
  54944. */
  54945. /**
  54946. * Gets or sets the current target frame rate (60 by default)
  54947. */
  54948. targetFrameRate: number;
  54949. /**
  54950. * Gets or sets the current interval between two checks (every 2000ms by default)
  54951. */
  54952. /**
  54953. * Gets or sets the current interval between two checks (every 2000ms by default)
  54954. */
  54955. trackerDuration: number;
  54956. /**
  54957. * Gets the list of active optimizations
  54958. */
  54959. readonly optimizations: SceneOptimization[];
  54960. /**
  54961. * Creates a new SceneOptimizer
  54962. * @param scene defines the scene to work on
  54963. * @param options defines the options to use with the SceneOptimizer
  54964. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  54965. * @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)
  54966. */
  54967. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  54968. /**
  54969. * Stops the current optimizer
  54970. */
  54971. stop(): void;
  54972. /**
  54973. * Reset the optimizer to initial step (current priority level = 0)
  54974. */
  54975. reset(): void;
  54976. /**
  54977. * Start the optimizer. By default it will try to reach a specific framerate
  54978. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  54979. */
  54980. start(): void;
  54981. private _checkCurrentState;
  54982. /**
  54983. * Release all resources
  54984. */
  54985. dispose(): void;
  54986. /**
  54987. * Helper function to create a SceneOptimizer with one single line of code
  54988. * @param scene defines the scene to work on
  54989. * @param options defines the options to use with the SceneOptimizer
  54990. * @param onSuccess defines a callback to call on success
  54991. * @param onFailure defines a callback to call on failure
  54992. * @returns the new SceneOptimizer object
  54993. */
  54994. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  54995. }
  54996. }
  54997. declare module "babylonjs/Misc/sceneSerializer" {
  54998. import { Scene } from "babylonjs/scene";
  54999. /**
  55000. * Class used to serialize a scene into a string
  55001. */
  55002. export class SceneSerializer {
  55003. /**
  55004. * Clear cache used by a previous serialization
  55005. */
  55006. static ClearCache(): void;
  55007. /**
  55008. * Serialize a scene into a JSON compatible object
  55009. * @param scene defines the scene to serialize
  55010. * @returns a JSON compatible object
  55011. */
  55012. static Serialize(scene: Scene): any;
  55013. /**
  55014. * Serialize a mesh into a JSON compatible object
  55015. * @param toSerialize defines the mesh to serialize
  55016. * @param withParents defines if parents must be serialized as well
  55017. * @param withChildren defines if children must be serialized as well
  55018. * @returns a JSON compatible object
  55019. */
  55020. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55021. }
  55022. }
  55023. declare module "babylonjs/Misc/videoRecorder" {
  55024. import { Nullable } from "babylonjs/types";
  55025. import { Engine } from "babylonjs/Engines/engine";
  55026. /**
  55027. * This represents the different options avilable for the video capture.
  55028. */
  55029. export interface VideoRecorderOptions {
  55030. /** Defines the mime type of the video */
  55031. mimeType: string;
  55032. /** Defines the video the video should be recorded at */
  55033. fps: number;
  55034. /** Defines the chunk size for the recording data */
  55035. recordChunckSize: number;
  55036. }
  55037. /**
  55038. * This can helps recording videos from BabylonJS.
  55039. * This is based on the available WebRTC functionalities of the browser.
  55040. *
  55041. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55042. */
  55043. export class VideoRecorder {
  55044. private static readonly _defaultOptions;
  55045. /**
  55046. * Returns wehther or not the VideoRecorder is available in your browser.
  55047. * @param engine Defines the Babylon Engine to check the support for
  55048. * @returns true if supported otherwise false
  55049. */
  55050. static IsSupported(engine: Engine): boolean;
  55051. private readonly _options;
  55052. private _canvas;
  55053. private _mediaRecorder;
  55054. private _recordedChunks;
  55055. private _fileName;
  55056. private _resolve;
  55057. private _reject;
  55058. /**
  55059. * True wether a recording is already in progress.
  55060. */
  55061. readonly isRecording: boolean;
  55062. /**
  55063. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55064. * a video file.
  55065. * @param engine Defines the BabylonJS Engine you wish to record
  55066. * @param options Defines options that can be used to customized the capture
  55067. */
  55068. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55069. /**
  55070. * Stops the current recording before the default capture timeout passed in the startRecording
  55071. * functions.
  55072. */
  55073. stopRecording(): void;
  55074. /**
  55075. * Starts recording the canvas for a max duration specified in parameters.
  55076. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  55077. * @param maxDuration Defines the maximum recording time in seconds.
  55078. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55079. * @return a promise callback at the end of the recording with the video data in Blob.
  55080. */
  55081. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55082. /**
  55083. * Releases internal resources used during the recording.
  55084. */
  55085. dispose(): void;
  55086. private _handleDataAvailable;
  55087. private _handleError;
  55088. private _handleStop;
  55089. }
  55090. }
  55091. declare module "babylonjs/Misc/workerPool" {
  55092. import { IDisposable } from "babylonjs/scene";
  55093. /**
  55094. * Helper class to push actions to a pool of workers.
  55095. */
  55096. export class WorkerPool implements IDisposable {
  55097. private _workerInfos;
  55098. private _pendingActions;
  55099. /**
  55100. * Constructor
  55101. * @param workers Array of workers to use for actions
  55102. */
  55103. constructor(workers: Array<Worker>);
  55104. /**
  55105. * Terminates all workers and clears any pending actions.
  55106. */
  55107. dispose(): void;
  55108. /**
  55109. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55110. * pended until a worker has completed its action.
  55111. * @param action The action to perform. Call onComplete when the action is complete.
  55112. */
  55113. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55114. private _execute;
  55115. }
  55116. }
  55117. declare module "babylonjs/Misc/screenshotTools" {
  55118. import { Camera } from "babylonjs/Cameras/camera";
  55119. import { Engine } from "babylonjs/Engines/engine";
  55120. /**
  55121. * Class containing a set of static utilities functions for screenshots
  55122. */
  55123. export class ScreenshotTools {
  55124. /**
  55125. * Captures a screenshot of the current rendering
  55126. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55127. * @param engine defines the rendering engine
  55128. * @param camera defines the source camera
  55129. * @param size This parameter can be set to a single number or to an object with the
  55130. * following (optional) properties: precision, width, height. If a single number is passed,
  55131. * it will be used for both width and height. If an object is passed, the screenshot size
  55132. * will be derived from the parameters. The precision property is a multiplier allowing
  55133. * rendering at a higher or lower resolution
  55134. * @param successCallback defines the callback receives a single parameter which contains the
  55135. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55136. * src parameter of an <img> to display it
  55137. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55138. * Check your browser for supported MIME types
  55139. */
  55140. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55141. /**
  55142. * Generates an image screenshot from the specified camera.
  55143. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55144. * @param engine The engine to use for rendering
  55145. * @param camera The camera to use for rendering
  55146. * @param size This parameter can be set to a single number or to an object with the
  55147. * following (optional) properties: precision, width, height. If a single number is passed,
  55148. * it will be used for both width and height. If an object is passed, the screenshot size
  55149. * will be derived from the parameters. The precision property is a multiplier allowing
  55150. * rendering at a higher or lower resolution
  55151. * @param successCallback The callback receives a single parameter which contains the
  55152. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55153. * src parameter of an <img> to display it
  55154. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55155. * Check your browser for supported MIME types
  55156. * @param samples Texture samples (default: 1)
  55157. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55158. * @param fileName A name for for the downloaded file.
  55159. */
  55160. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55161. }
  55162. }
  55163. declare module "babylonjs/Misc/index" {
  55164. export * from "babylonjs/Misc/andOrNotEvaluator";
  55165. export * from "babylonjs/Misc/assetsManager";
  55166. export * from "babylonjs/Misc/dds";
  55167. export * from "babylonjs/Misc/decorators";
  55168. export * from "babylonjs/Misc/deferred";
  55169. export * from "babylonjs/Misc/environmentTextureTools";
  55170. export * from "babylonjs/Misc/filesInput";
  55171. export * from "babylonjs/Misc/HighDynamicRange/index";
  55172. export * from "babylonjs/Misc/khronosTextureContainer";
  55173. export * from "babylonjs/Misc/observable";
  55174. export * from "babylonjs/Misc/performanceMonitor";
  55175. export * from "babylonjs/Misc/promise";
  55176. export * from "babylonjs/Misc/sceneOptimizer";
  55177. export * from "babylonjs/Misc/sceneSerializer";
  55178. export * from "babylonjs/Misc/smartArray";
  55179. export * from "babylonjs/Misc/stringDictionary";
  55180. export * from "babylonjs/Misc/tags";
  55181. export * from "babylonjs/Misc/textureTools";
  55182. export * from "babylonjs/Misc/tga";
  55183. export * from "babylonjs/Misc/tools";
  55184. export * from "babylonjs/Misc/videoRecorder";
  55185. export * from "babylonjs/Misc/virtualJoystick";
  55186. export * from "babylonjs/Misc/workerPool";
  55187. export * from "babylonjs/Misc/logger";
  55188. export * from "babylonjs/Misc/typeStore";
  55189. export * from "babylonjs/Misc/filesInputStore";
  55190. export * from "babylonjs/Misc/deepCopier";
  55191. export * from "babylonjs/Misc/pivotTools";
  55192. export * from "babylonjs/Misc/precisionDate";
  55193. export * from "babylonjs/Misc/screenshotTools";
  55194. export * from "babylonjs/Misc/typeStore";
  55195. }
  55196. declare module "babylonjs/index" {
  55197. export * from "babylonjs/abstractScene";
  55198. export * from "babylonjs/Actions/index";
  55199. export * from "babylonjs/Animations/index";
  55200. export * from "babylonjs/assetContainer";
  55201. export * from "babylonjs/Audio/index";
  55202. export * from "babylonjs/Behaviors/index";
  55203. export * from "babylonjs/Bones/index";
  55204. export * from "babylonjs/Cameras/index";
  55205. export * from "babylonjs/Collisions/index";
  55206. export * from "babylonjs/Culling/index";
  55207. export * from "babylonjs/Debug/index";
  55208. export * from "babylonjs/Engines/index";
  55209. export * from "babylonjs/Events/index";
  55210. export * from "babylonjs/Gamepads/index";
  55211. export * from "babylonjs/Gizmos/index";
  55212. export * from "babylonjs/Helpers/index";
  55213. export * from "babylonjs/Instrumentation/index";
  55214. export * from "babylonjs/Layers/index";
  55215. export * from "babylonjs/LensFlares/index";
  55216. export * from "babylonjs/Lights/index";
  55217. export * from "babylonjs/Loading/index";
  55218. export * from "babylonjs/Materials/index";
  55219. export * from "babylonjs/Maths/index";
  55220. export * from "babylonjs/Meshes/index";
  55221. export * from "babylonjs/Morph/index";
  55222. export * from "babylonjs/node";
  55223. export * from "babylonjs/Offline/index";
  55224. export * from "babylonjs/Particles/index";
  55225. export * from "babylonjs/Physics/index";
  55226. export * from "babylonjs/PostProcesses/index";
  55227. export * from "babylonjs/Probes/index";
  55228. export * from "babylonjs/Rendering/index";
  55229. export * from "babylonjs/scene";
  55230. export * from "babylonjs/sceneComponent";
  55231. export * from "babylonjs/Sprites/index";
  55232. export * from "babylonjs/States/index";
  55233. export * from "babylonjs/Misc/index";
  55234. export * from "babylonjs/types";
  55235. }
  55236. declare module "babylonjs/Legacy/legacy" {
  55237. export * from "babylonjs/index";
  55238. }
  55239. declare module "babylonjs/Shaders/blur.fragment" {
  55240. /** @hidden */
  55241. export var blurPixelShader: {
  55242. name: string;
  55243. shader: string;
  55244. };
  55245. }
  55246. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  55247. /** @hidden */
  55248. export var bones300Declaration: {
  55249. name: string;
  55250. shader: string;
  55251. };
  55252. }
  55253. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  55254. /** @hidden */
  55255. export var instances300Declaration: {
  55256. name: string;
  55257. shader: string;
  55258. };
  55259. }
  55260. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  55261. /** @hidden */
  55262. export var pointCloudVertexDeclaration: {
  55263. name: string;
  55264. shader: string;
  55265. };
  55266. }
  55267. // Mixins
  55268. interface Window {
  55269. mozIndexedDB: IDBFactory;
  55270. webkitIndexedDB: IDBFactory;
  55271. msIndexedDB: IDBFactory;
  55272. webkitURL: typeof URL;
  55273. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55274. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55275. WebGLRenderingContext: WebGLRenderingContext;
  55276. MSGesture: MSGesture;
  55277. CANNON: any;
  55278. AudioContext: AudioContext;
  55279. webkitAudioContext: AudioContext;
  55280. PointerEvent: any;
  55281. Math: Math;
  55282. Uint8Array: Uint8ArrayConstructor;
  55283. Float32Array: Float32ArrayConstructor;
  55284. mozURL: typeof URL;
  55285. msURL: typeof URL;
  55286. VRFrameData: any; // WebVR, from specs 1.1
  55287. DracoDecoderModule: any;
  55288. setImmediate(handler: (...args: any[]) => void): number;
  55289. }
  55290. interface Document {
  55291. mozCancelFullScreen(): void;
  55292. msCancelFullScreen(): void;
  55293. webkitCancelFullScreen(): void;
  55294. requestPointerLock(): void;
  55295. exitPointerLock(): void;
  55296. mozFullScreen: boolean;
  55297. msIsFullScreen: boolean;
  55298. readonly webkitIsFullScreen: boolean;
  55299. readonly pointerLockElement: Element;
  55300. mozPointerLockElement: HTMLElement;
  55301. msPointerLockElement: HTMLElement;
  55302. webkitPointerLockElement: HTMLElement;
  55303. }
  55304. interface HTMLCanvasElement {
  55305. requestPointerLock(): void;
  55306. msRequestPointerLock?(): void;
  55307. mozRequestPointerLock?(): void;
  55308. webkitRequestPointerLock?(): void;
  55309. /** Track wether a record is in progress */
  55310. isRecording: boolean;
  55311. /** Capture Stream method defined by some browsers */
  55312. captureStream(fps?: number): MediaStream;
  55313. }
  55314. interface CanvasRenderingContext2D {
  55315. msImageSmoothingEnabled: boolean;
  55316. }
  55317. interface MouseEvent {
  55318. mozMovementX: number;
  55319. mozMovementY: number;
  55320. webkitMovementX: number;
  55321. webkitMovementY: number;
  55322. msMovementX: number;
  55323. msMovementY: number;
  55324. }
  55325. interface Navigator {
  55326. mozGetVRDevices: (any: any) => any;
  55327. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55328. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55329. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55330. webkitGetGamepads(): Gamepad[];
  55331. msGetGamepads(): Gamepad[];
  55332. webkitGamepads(): Gamepad[];
  55333. }
  55334. interface HTMLVideoElement {
  55335. mozSrcObject: any;
  55336. }
  55337. interface Math {
  55338. fround(x: number): number;
  55339. imul(a: number, b: number): number;
  55340. }
  55341. interface WebGLProgram {
  55342. context?: WebGLRenderingContext;
  55343. vertexShader?: WebGLShader;
  55344. fragmentShader?: WebGLShader;
  55345. isParallelCompiled: boolean;
  55346. onCompiled?: () => void;
  55347. }
  55348. interface WebGLRenderingContext {
  55349. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55350. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55351. vertexAttribDivisor(index: number, divisor: number): void;
  55352. createVertexArray(): any;
  55353. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55354. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55355. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55356. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55357. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55358. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55359. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55360. // Queries
  55361. createQuery(): WebGLQuery;
  55362. deleteQuery(query: WebGLQuery): void;
  55363. beginQuery(target: number, query: WebGLQuery): void;
  55364. endQuery(target: number): void;
  55365. getQueryParameter(query: WebGLQuery, pname: number): any;
  55366. getQuery(target: number, pname: number): any;
  55367. MAX_SAMPLES: number;
  55368. RGBA8: number;
  55369. READ_FRAMEBUFFER: number;
  55370. DRAW_FRAMEBUFFER: number;
  55371. UNIFORM_BUFFER: number;
  55372. HALF_FLOAT_OES: number;
  55373. RGBA16F: number;
  55374. RGBA32F: number;
  55375. R32F: number;
  55376. RG32F: number;
  55377. RGB32F: number;
  55378. R16F: number;
  55379. RG16F: number;
  55380. RGB16F: number;
  55381. RED: number;
  55382. RG: number;
  55383. R8: number;
  55384. RG8: number;
  55385. UNSIGNED_INT_24_8: number;
  55386. DEPTH24_STENCIL8: number;
  55387. /* Multiple Render Targets */
  55388. drawBuffers(buffers: number[]): void;
  55389. readBuffer(src: number): void;
  55390. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55391. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55392. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55393. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55394. // Occlusion Query
  55395. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55396. ANY_SAMPLES_PASSED: number;
  55397. QUERY_RESULT_AVAILABLE: number;
  55398. QUERY_RESULT: number;
  55399. }
  55400. interface WebGLBuffer {
  55401. references: number;
  55402. capacity: number;
  55403. is32Bits: boolean;
  55404. }
  55405. interface WebGLProgram {
  55406. transformFeedback?: WebGLTransformFeedback | null;
  55407. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55408. }
  55409. interface EXT_disjoint_timer_query {
  55410. QUERY_COUNTER_BITS_EXT: number;
  55411. TIME_ELAPSED_EXT: number;
  55412. TIMESTAMP_EXT: number;
  55413. GPU_DISJOINT_EXT: number;
  55414. QUERY_RESULT_EXT: number;
  55415. QUERY_RESULT_AVAILABLE_EXT: number;
  55416. queryCounterEXT(query: WebGLQuery, target: number): void;
  55417. createQueryEXT(): WebGLQuery;
  55418. beginQueryEXT(target: number, query: WebGLQuery): void;
  55419. endQueryEXT(target: number): void;
  55420. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55421. deleteQueryEXT(query: WebGLQuery): void;
  55422. }
  55423. interface WebGLUniformLocation {
  55424. _currentState: any;
  55425. }
  55426. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55427. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55428. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55429. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55430. interface WebGLRenderingContext {
  55431. readonly RASTERIZER_DISCARD: number;
  55432. readonly DEPTH_COMPONENT24: number;
  55433. readonly TEXTURE_3D: number;
  55434. readonly TEXTURE_2D_ARRAY: number;
  55435. readonly TEXTURE_COMPARE_FUNC: number;
  55436. readonly TEXTURE_COMPARE_MODE: number;
  55437. readonly COMPARE_REF_TO_TEXTURE: number;
  55438. readonly TEXTURE_WRAP_R: number;
  55439. readonly HALF_FLOAT: number;
  55440. readonly RGB8: number;
  55441. readonly RED_INTEGER: number;
  55442. readonly RG_INTEGER: number;
  55443. readonly RGB_INTEGER: number;
  55444. readonly RGBA_INTEGER: number;
  55445. readonly R8_SNORM: number;
  55446. readonly RG8_SNORM: number;
  55447. readonly RGB8_SNORM: number;
  55448. readonly RGBA8_SNORM: number;
  55449. readonly R8I: number;
  55450. readonly RG8I: number;
  55451. readonly RGB8I: number;
  55452. readonly RGBA8I: number;
  55453. readonly R8UI: number;
  55454. readonly RG8UI: number;
  55455. readonly RGB8UI: number;
  55456. readonly RGBA8UI: number;
  55457. readonly R16I: number;
  55458. readonly RG16I: number;
  55459. readonly RGB16I: number;
  55460. readonly RGBA16I: number;
  55461. readonly R16UI: number;
  55462. readonly RG16UI: number;
  55463. readonly RGB16UI: number;
  55464. readonly RGBA16UI: number;
  55465. readonly R32I: number;
  55466. readonly RG32I: number;
  55467. readonly RGB32I: number;
  55468. readonly RGBA32I: number;
  55469. readonly R32UI: number;
  55470. readonly RG32UI: number;
  55471. readonly RGB32UI: number;
  55472. readonly RGBA32UI: number;
  55473. readonly RGB10_A2UI: number;
  55474. readonly R11F_G11F_B10F: number;
  55475. readonly RGB9_E5: number;
  55476. readonly RGB10_A2: number;
  55477. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55478. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55479. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55480. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55481. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55482. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55483. 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;
  55484. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55485. readonly TRANSFORM_FEEDBACK: number;
  55486. readonly INTERLEAVED_ATTRIBS: number;
  55487. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55488. createTransformFeedback(): WebGLTransformFeedback;
  55489. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55490. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55491. beginTransformFeedback(primitiveMode: number): void;
  55492. endTransformFeedback(): void;
  55493. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55494. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55495. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55496. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55497. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55498. }
  55499. interface ImageBitmap {
  55500. readonly width: number;
  55501. readonly height: number;
  55502. close(): void;
  55503. }
  55504. interface WebGLQuery extends WebGLObject {
  55505. }
  55506. declare var WebGLQuery: {
  55507. prototype: WebGLQuery;
  55508. new(): WebGLQuery;
  55509. };
  55510. interface WebGLSampler extends WebGLObject {
  55511. }
  55512. declare var WebGLSampler: {
  55513. prototype: WebGLSampler;
  55514. new(): WebGLSampler;
  55515. };
  55516. interface WebGLSync extends WebGLObject {
  55517. }
  55518. declare var WebGLSync: {
  55519. prototype: WebGLSync;
  55520. new(): WebGLSync;
  55521. };
  55522. interface WebGLTransformFeedback extends WebGLObject {
  55523. }
  55524. declare var WebGLTransformFeedback: {
  55525. prototype: WebGLTransformFeedback;
  55526. new(): WebGLTransformFeedback;
  55527. };
  55528. interface WebGLVertexArrayObject extends WebGLObject {
  55529. }
  55530. declare var WebGLVertexArrayObject: {
  55531. prototype: WebGLVertexArrayObject;
  55532. new(): WebGLVertexArrayObject;
  55533. };
  55534. // Type definitions for WebVR API
  55535. // Project: https://w3c.github.io/webvr/
  55536. // Definitions by: six a <https://github.com/lostfictions>
  55537. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55538. interface VRDisplay extends EventTarget {
  55539. /**
  55540. * Dictionary of capabilities describing the VRDisplay.
  55541. */
  55542. readonly capabilities: VRDisplayCapabilities;
  55543. /**
  55544. * z-depth defining the far plane of the eye view frustum
  55545. * enables mapping of values in the render target depth
  55546. * attachment to scene coordinates. Initially set to 10000.0.
  55547. */
  55548. depthFar: number;
  55549. /**
  55550. * z-depth defining the near plane of the eye view frustum
  55551. * enables mapping of values in the render target depth
  55552. * attachment to scene coordinates. Initially set to 0.01.
  55553. */
  55554. depthNear: number;
  55555. /**
  55556. * An identifier for this distinct VRDisplay. Used as an
  55557. * association point in the Gamepad API.
  55558. */
  55559. readonly displayId: number;
  55560. /**
  55561. * A display name, a user-readable name identifying it.
  55562. */
  55563. readonly displayName: string;
  55564. readonly isConnected: boolean;
  55565. readonly isPresenting: boolean;
  55566. /**
  55567. * If this VRDisplay supports room-scale experiences, the optional
  55568. * stage attribute contains details on the room-scale parameters.
  55569. */
  55570. readonly stageParameters: VRStageParameters | null;
  55571. /**
  55572. * Passing the value returned by `requestAnimationFrame` to
  55573. * `cancelAnimationFrame` will unregister the callback.
  55574. * @param handle Define the hanle of the request to cancel
  55575. */
  55576. cancelAnimationFrame(handle: number): void;
  55577. /**
  55578. * Stops presenting to the VRDisplay.
  55579. * @returns a promise to know when it stopped
  55580. */
  55581. exitPresent(): Promise<void>;
  55582. /**
  55583. * Return the current VREyeParameters for the given eye.
  55584. * @param whichEye Define the eye we want the parameter for
  55585. * @returns the eye parameters
  55586. */
  55587. getEyeParameters(whichEye: string): VREyeParameters;
  55588. /**
  55589. * Populates the passed VRFrameData with the information required to render
  55590. * the current frame.
  55591. * @param frameData Define the data structure to populate
  55592. * @returns true if ok otherwise false
  55593. */
  55594. getFrameData(frameData: VRFrameData): boolean;
  55595. /**
  55596. * Get the layers currently being presented.
  55597. * @returns the list of VR layers
  55598. */
  55599. getLayers(): VRLayer[];
  55600. /**
  55601. * Return a VRPose containing the future predicted pose of the VRDisplay
  55602. * when the current frame will be presented. The value returned will not
  55603. * change until JavaScript has returned control to the browser.
  55604. *
  55605. * The VRPose will contain the position, orientation, velocity,
  55606. * and acceleration of each of these properties.
  55607. * @returns the pose object
  55608. */
  55609. getPose(): VRPose;
  55610. /**
  55611. * Return the current instantaneous pose of the VRDisplay, with no
  55612. * prediction applied.
  55613. * @returns the current instantaneous pose
  55614. */
  55615. getImmediatePose(): VRPose;
  55616. /**
  55617. * The callback passed to `requestAnimationFrame` will be called
  55618. * any time a new frame should be rendered. When the VRDisplay is
  55619. * presenting the callback will be called at the native refresh
  55620. * rate of the HMD. When not presenting this function acts
  55621. * identically to how window.requestAnimationFrame acts. Content should
  55622. * make no assumptions of frame rate or vsync behavior as the HMD runs
  55623. * asynchronously from other displays and at differing refresh rates.
  55624. * @param callback Define the eaction to run next frame
  55625. * @returns the request handle it
  55626. */
  55627. requestAnimationFrame(callback: FrameRequestCallback): number;
  55628. /**
  55629. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  55630. * Repeat calls while already presenting will update the VRLayers being displayed.
  55631. * @param layers Define the list of layer to present
  55632. * @returns a promise to know when the request has been fulfilled
  55633. */
  55634. requestPresent(layers: VRLayer[]): Promise<void>;
  55635. /**
  55636. * Reset the pose for this display, treating its current position and
  55637. * orientation as the "origin/zero" values. VRPose.position,
  55638. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  55639. * updated when calling resetPose(). This should be called in only
  55640. * sitting-space experiences.
  55641. */
  55642. resetPose(): void;
  55643. /**
  55644. * The VRLayer provided to the VRDisplay will be captured and presented
  55645. * in the HMD. Calling this function has the same effect on the source
  55646. * canvas as any other operation that uses its source image, and canvases
  55647. * created without preserveDrawingBuffer set to true will be cleared.
  55648. * @param pose Define the pose to submit
  55649. */
  55650. submitFrame(pose?: VRPose): void;
  55651. }
  55652. declare var VRDisplay: {
  55653. prototype: VRDisplay;
  55654. new(): VRDisplay;
  55655. };
  55656. interface VRLayer {
  55657. leftBounds?: number[] | Float32Array | null;
  55658. rightBounds?: number[] | Float32Array | null;
  55659. source?: HTMLCanvasElement | null;
  55660. }
  55661. interface VRDisplayCapabilities {
  55662. readonly canPresent: boolean;
  55663. readonly hasExternalDisplay: boolean;
  55664. readonly hasOrientation: boolean;
  55665. readonly hasPosition: boolean;
  55666. readonly maxLayers: number;
  55667. }
  55668. interface VREyeParameters {
  55669. /** @deprecated */
  55670. readonly fieldOfView: VRFieldOfView;
  55671. readonly offset: Float32Array;
  55672. readonly renderHeight: number;
  55673. readonly renderWidth: number;
  55674. }
  55675. interface VRFieldOfView {
  55676. readonly downDegrees: number;
  55677. readonly leftDegrees: number;
  55678. readonly rightDegrees: number;
  55679. readonly upDegrees: number;
  55680. }
  55681. interface VRFrameData {
  55682. readonly leftProjectionMatrix: Float32Array;
  55683. readonly leftViewMatrix: Float32Array;
  55684. readonly pose: VRPose;
  55685. readonly rightProjectionMatrix: Float32Array;
  55686. readonly rightViewMatrix: Float32Array;
  55687. readonly timestamp: number;
  55688. }
  55689. interface VRPose {
  55690. readonly angularAcceleration: Float32Array | null;
  55691. readonly angularVelocity: Float32Array | null;
  55692. readonly linearAcceleration: Float32Array | null;
  55693. readonly linearVelocity: Float32Array | null;
  55694. readonly orientation: Float32Array | null;
  55695. readonly position: Float32Array | null;
  55696. readonly timestamp: number;
  55697. }
  55698. interface VRStageParameters {
  55699. sittingToStandingTransform?: Float32Array;
  55700. sizeX?: number;
  55701. sizeY?: number;
  55702. }
  55703. interface Navigator {
  55704. getVRDisplays(): Promise<VRDisplay[]>;
  55705. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  55706. }
  55707. interface Window {
  55708. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  55709. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  55710. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  55711. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55712. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55713. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  55714. }
  55715. interface Gamepad {
  55716. readonly displayId: number;
  55717. }
  55718. interface XRDevice {
  55719. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  55720. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  55721. }
  55722. interface XRSession {
  55723. getInputSources(): Array<any>;
  55724. baseLayer: XRWebGLLayer;
  55725. requestFrameOfReference(type: string): Promise<void>;
  55726. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  55727. end(): Promise<void>;
  55728. requestAnimationFrame: Function;
  55729. addEventListener: Function;
  55730. }
  55731. interface XRSessionCreationOptions {
  55732. outputContext?: WebGLRenderingContext | null;
  55733. immersive?: boolean;
  55734. environmentIntegration?: boolean;
  55735. }
  55736. interface XRLayer {
  55737. getViewport: Function;
  55738. framebufferWidth: number;
  55739. framebufferHeight: number;
  55740. }
  55741. interface XRView {
  55742. projectionMatrix: Float32Array;
  55743. }
  55744. interface XRFrame {
  55745. getDevicePose: Function;
  55746. getInputPose: Function;
  55747. views: Array<XRView>;
  55748. baseLayer: XRLayer;
  55749. }
  55750. interface XRFrameOfReference {
  55751. }
  55752. interface XRWebGLLayer extends XRLayer {
  55753. framebuffer: WebGLFramebuffer;
  55754. }
  55755. declare var XRWebGLLayer: {
  55756. prototype: XRWebGLLayer;
  55757. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  55758. };
  55759. declare module "babylonjs" {
  55760. export * from "babylonjs/Legacy/legacy";
  55761. }