babylon.module.d.ts 2.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835
  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. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21966. */
  21967. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21968. /**
  21969. * Creates a MultiMaterial from parsed MultiMaterial data.
  21970. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21971. * @param scene defines the hosting scene
  21972. * @returns a new MultiMaterial
  21973. */
  21974. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21975. }
  21976. }
  21977. declare module "babylonjs/Meshes/subMesh" {
  21978. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  21979. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21980. import { Engine } from "babylonjs/Engines/engine";
  21981. import { Collider } from "babylonjs/Collisions/collider";
  21982. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21983. import { Ray } from "babylonjs/Culling/ray";
  21984. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21985. import { Effect } from "babylonjs/Materials/effect";
  21986. import { Material } from "babylonjs/Materials/material";
  21987. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21989. import { Mesh } from "babylonjs/Meshes/mesh";
  21990. /**
  21991. * Base class for submeshes
  21992. */
  21993. export class BaseSubMesh {
  21994. /** @hidden */
  21995. _materialDefines: Nullable<MaterialDefines>;
  21996. /** @hidden */
  21997. _materialEffect: Nullable<Effect>;
  21998. /**
  21999. * Gets associated effect
  22000. */
  22001. readonly effect: Nullable<Effect>;
  22002. /**
  22003. * Sets associated effect (effect used to render this submesh)
  22004. * @param effect defines the effect to associate with
  22005. * @param defines defines the set of defines used to compile this effect
  22006. */
  22007. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22008. }
  22009. /**
  22010. * Defines a subdivision inside a mesh
  22011. */
  22012. export class SubMesh extends BaseSubMesh implements ICullable {
  22013. /** the material index to use */
  22014. materialIndex: number;
  22015. /** vertex index start */
  22016. verticesStart: number;
  22017. /** vertices count */
  22018. verticesCount: number;
  22019. /** index start */
  22020. indexStart: number;
  22021. /** indices count */
  22022. indexCount: number;
  22023. /** @hidden */
  22024. _linesIndexCount: number;
  22025. private _mesh;
  22026. private _renderingMesh;
  22027. private _boundingInfo;
  22028. private _linesIndexBuffer;
  22029. /** @hidden */
  22030. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22031. /** @hidden */
  22032. _trianglePlanes: Plane[];
  22033. /** @hidden */
  22034. _lastColliderTransformMatrix: Matrix;
  22035. /** @hidden */
  22036. _renderId: number;
  22037. /** @hidden */
  22038. _alphaIndex: number;
  22039. /** @hidden */
  22040. _distanceToCamera: number;
  22041. /** @hidden */
  22042. _id: number;
  22043. private _currentMaterial;
  22044. /**
  22045. * Add a new submesh to a mesh
  22046. * @param materialIndex defines the material index to use
  22047. * @param verticesStart defines vertex index start
  22048. * @param verticesCount defines vertices count
  22049. * @param indexStart defines index start
  22050. * @param indexCount defines indices count
  22051. * @param mesh defines the parent mesh
  22052. * @param renderingMesh defines an optional rendering mesh
  22053. * @param createBoundingBox defines if bounding box should be created for this submesh
  22054. * @returns the new submesh
  22055. */
  22056. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22057. /**
  22058. * Creates a new submesh
  22059. * @param materialIndex defines the material index to use
  22060. * @param verticesStart defines vertex index start
  22061. * @param verticesCount defines vertices count
  22062. * @param indexStart defines index start
  22063. * @param indexCount defines indices count
  22064. * @param mesh defines the parent mesh
  22065. * @param renderingMesh defines an optional rendering mesh
  22066. * @param createBoundingBox defines if bounding box should be created for this submesh
  22067. */
  22068. constructor(
  22069. /** the material index to use */
  22070. materialIndex: number,
  22071. /** vertex index start */
  22072. verticesStart: number,
  22073. /** vertices count */
  22074. verticesCount: number,
  22075. /** index start */
  22076. indexStart: number,
  22077. /** indices count */
  22078. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22079. /**
  22080. * Returns true if this submesh covers the entire parent mesh
  22081. * @ignorenaming
  22082. */
  22083. readonly IsGlobal: boolean;
  22084. /**
  22085. * Returns the submesh BoudingInfo object
  22086. * @returns current bounding info (or mesh's one if the submesh is global)
  22087. */
  22088. getBoundingInfo(): BoundingInfo;
  22089. /**
  22090. * Sets the submesh BoundingInfo
  22091. * @param boundingInfo defines the new bounding info to use
  22092. * @returns the SubMesh
  22093. */
  22094. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22095. /**
  22096. * Returns the mesh of the current submesh
  22097. * @return the parent mesh
  22098. */
  22099. getMesh(): AbstractMesh;
  22100. /**
  22101. * Returns the rendering mesh of the submesh
  22102. * @returns the rendering mesh (could be different from parent mesh)
  22103. */
  22104. getRenderingMesh(): Mesh;
  22105. /**
  22106. * Returns the submesh material
  22107. * @returns null or the current material
  22108. */
  22109. getMaterial(): Nullable<Material>;
  22110. /**
  22111. * Sets a new updated BoundingInfo object to the submesh
  22112. * @returns the SubMesh
  22113. */
  22114. refreshBoundingInfo(): SubMesh;
  22115. /** @hidden */
  22116. _checkCollision(collider: Collider): boolean;
  22117. /**
  22118. * Updates the submesh BoundingInfo
  22119. * @param world defines the world matrix to use to update the bounding info
  22120. * @returns the submesh
  22121. */
  22122. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22123. /**
  22124. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22125. * @param frustumPlanes defines the frustum planes
  22126. * @returns true if the submesh is intersecting with the frustum
  22127. */
  22128. isInFrustum(frustumPlanes: Plane[]): boolean;
  22129. /**
  22130. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22131. * @param frustumPlanes defines the frustum planes
  22132. * @returns true if the submesh is inside the frustum
  22133. */
  22134. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22135. /**
  22136. * Renders the submesh
  22137. * @param enableAlphaMode defines if alpha needs to be used
  22138. * @returns the submesh
  22139. */
  22140. render(enableAlphaMode: boolean): SubMesh;
  22141. /**
  22142. * @hidden
  22143. */
  22144. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22145. /**
  22146. * Checks if the submesh intersects with a ray
  22147. * @param ray defines the ray to test
  22148. * @returns true is the passed ray intersects the submesh bounding box
  22149. */
  22150. canIntersects(ray: Ray): boolean;
  22151. /**
  22152. * Intersects current submesh with a ray
  22153. * @param ray defines the ray to test
  22154. * @param positions defines mesh's positions array
  22155. * @param indices defines mesh's indices array
  22156. * @param fastCheck defines if only bounding info should be used
  22157. * @returns intersection info or null if no intersection
  22158. */
  22159. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22160. /** @hidden */
  22161. private _intersectLines;
  22162. /** @hidden */
  22163. private _intersectTriangles;
  22164. /** @hidden */
  22165. _rebuild(): void;
  22166. /**
  22167. * Creates a new submesh from the passed mesh
  22168. * @param newMesh defines the new hosting mesh
  22169. * @param newRenderingMesh defines an optional rendering mesh
  22170. * @returns the new submesh
  22171. */
  22172. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22173. /**
  22174. * Release associated resources
  22175. */
  22176. dispose(): void;
  22177. /**
  22178. * Gets the class name
  22179. * @returns the string "SubMesh".
  22180. */
  22181. getClassName(): string;
  22182. /**
  22183. * Creates a new submesh from indices data
  22184. * @param materialIndex the index of the main mesh material
  22185. * @param startIndex the index where to start the copy in the mesh indices array
  22186. * @param indexCount the number of indices to copy then from the startIndex
  22187. * @param mesh the main mesh to create the submesh from
  22188. * @param renderingMesh the optional rendering mesh
  22189. * @returns a new submesh
  22190. */
  22191. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22192. }
  22193. }
  22194. declare module "babylonjs/Meshes/geometry" {
  22195. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22196. import { Scene } from "babylonjs/scene";
  22197. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22198. import { Engine } from "babylonjs/Engines/engine";
  22199. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22200. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22201. import { Effect } from "babylonjs/Materials/effect";
  22202. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22203. import { Mesh } from "babylonjs/Meshes/mesh";
  22204. /**
  22205. * Class used to store geometry data (vertex buffers + index buffer)
  22206. */
  22207. export class Geometry implements IGetSetVerticesData {
  22208. /**
  22209. * Gets or sets the ID of the geometry
  22210. */
  22211. id: string;
  22212. /**
  22213. * Gets or sets the unique ID of the geometry
  22214. */
  22215. uniqueId: number;
  22216. /**
  22217. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22218. */
  22219. delayLoadState: number;
  22220. /**
  22221. * Gets the file containing the data to load when running in delay load state
  22222. */
  22223. delayLoadingFile: Nullable<string>;
  22224. /**
  22225. * Callback called when the geometry is updated
  22226. */
  22227. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22228. private _scene;
  22229. private _engine;
  22230. private _meshes;
  22231. private _totalVertices;
  22232. /** @hidden */
  22233. _indices: IndicesArray;
  22234. /** @hidden */
  22235. _vertexBuffers: {
  22236. [key: string]: VertexBuffer;
  22237. };
  22238. private _isDisposed;
  22239. private _extend;
  22240. private _boundingBias;
  22241. /** @hidden */
  22242. _delayInfo: Array<string>;
  22243. private _indexBuffer;
  22244. private _indexBufferIsUpdatable;
  22245. /** @hidden */
  22246. _boundingInfo: Nullable<BoundingInfo>;
  22247. /** @hidden */
  22248. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22249. /** @hidden */
  22250. _softwareSkinningFrameId: number;
  22251. private _vertexArrayObjects;
  22252. private _updatable;
  22253. /** @hidden */
  22254. _positions: Nullable<Vector3[]>;
  22255. /**
  22256. * 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
  22257. */
  22258. /**
  22259. * 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
  22260. */
  22261. boundingBias: Vector2;
  22262. /**
  22263. * Static function used to attach a new empty geometry to a mesh
  22264. * @param mesh defines the mesh to attach the geometry to
  22265. * @returns the new Geometry
  22266. */
  22267. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22268. /**
  22269. * Creates a new geometry
  22270. * @param id defines the unique ID
  22271. * @param scene defines the hosting scene
  22272. * @param vertexData defines the VertexData used to get geometry data
  22273. * @param updatable defines if geometry must be updatable (false by default)
  22274. * @param mesh defines the mesh that will be associated with the geometry
  22275. */
  22276. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22277. /**
  22278. * Gets the current extend of the geometry
  22279. */
  22280. readonly extend: {
  22281. minimum: Vector3;
  22282. maximum: Vector3;
  22283. };
  22284. /**
  22285. * Gets the hosting scene
  22286. * @returns the hosting Scene
  22287. */
  22288. getScene(): Scene;
  22289. /**
  22290. * Gets the hosting engine
  22291. * @returns the hosting Engine
  22292. */
  22293. getEngine(): Engine;
  22294. /**
  22295. * Defines if the geometry is ready to use
  22296. * @returns true if the geometry is ready to be used
  22297. */
  22298. isReady(): boolean;
  22299. /**
  22300. * Gets a value indicating that the geometry should not be serialized
  22301. */
  22302. readonly doNotSerialize: boolean;
  22303. /** @hidden */
  22304. _rebuild(): void;
  22305. /**
  22306. * Affects all geometry data in one call
  22307. * @param vertexData defines the geometry data
  22308. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22309. */
  22310. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22311. /**
  22312. * Set specific vertex data
  22313. * @param kind defines the data kind (Position, normal, etc...)
  22314. * @param data defines the vertex data to use
  22315. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22316. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22317. */
  22318. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22319. /**
  22320. * Removes a specific vertex data
  22321. * @param kind defines the data kind (Position, normal, etc...)
  22322. */
  22323. removeVerticesData(kind: string): void;
  22324. /**
  22325. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22326. * @param buffer defines the vertex buffer to use
  22327. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22328. */
  22329. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22330. /**
  22331. * Update a specific vertex buffer
  22332. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22333. * It will do nothing if the buffer is not updatable
  22334. * @param kind defines the data kind (Position, normal, etc...)
  22335. * @param data defines the data to use
  22336. * @param offset defines the offset in the target buffer where to store the data
  22337. * @param useBytes set to true if the offset is in bytes
  22338. */
  22339. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22340. /**
  22341. * Update a specific vertex buffer
  22342. * This function will create a new buffer if the current one is not updatable
  22343. * @param kind defines the data kind (Position, normal, etc...)
  22344. * @param data defines the data to use
  22345. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22346. */
  22347. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22348. private _updateBoundingInfo;
  22349. /** @hidden */
  22350. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22351. /**
  22352. * Gets total number of vertices
  22353. * @returns the total number of vertices
  22354. */
  22355. getTotalVertices(): number;
  22356. /**
  22357. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22358. * @param kind defines the data kind (Position, normal, etc...)
  22359. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22360. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22361. * @returns a float array containing vertex data
  22362. */
  22363. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22364. /**
  22365. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22366. * @param kind defines the data kind (Position, normal, etc...)
  22367. * @returns true if the vertex buffer with the specified kind is updatable
  22368. */
  22369. isVertexBufferUpdatable(kind: string): boolean;
  22370. /**
  22371. * Gets a specific vertex buffer
  22372. * @param kind defines the data kind (Position, normal, etc...)
  22373. * @returns a VertexBuffer
  22374. */
  22375. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22376. /**
  22377. * Returns all vertex buffers
  22378. * @return an object holding all vertex buffers indexed by kind
  22379. */
  22380. getVertexBuffers(): Nullable<{
  22381. [key: string]: VertexBuffer;
  22382. }>;
  22383. /**
  22384. * Gets a boolean indicating if specific vertex buffer is present
  22385. * @param kind defines the data kind (Position, normal, etc...)
  22386. * @returns true if data is present
  22387. */
  22388. isVerticesDataPresent(kind: string): boolean;
  22389. /**
  22390. * Gets a list of all attached data kinds (Position, normal, etc...)
  22391. * @returns a list of string containing all kinds
  22392. */
  22393. getVerticesDataKinds(): string[];
  22394. /**
  22395. * Update index buffer
  22396. * @param indices defines the indices to store in the index buffer
  22397. * @param offset defines the offset in the target buffer where to store the data
  22398. */
  22399. updateIndices(indices: IndicesArray, offset?: number): void;
  22400. /**
  22401. * Creates a new index buffer
  22402. * @param indices defines the indices to store in the index buffer
  22403. * @param totalVertices defines the total number of vertices (could be null)
  22404. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22405. */
  22406. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22407. /**
  22408. * Return the total number of indices
  22409. * @returns the total number of indices
  22410. */
  22411. getTotalIndices(): number;
  22412. /**
  22413. * Gets the index buffer array
  22414. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22415. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22416. * @returns the index buffer array
  22417. */
  22418. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22419. /**
  22420. * Gets the index buffer
  22421. * @return the index buffer
  22422. */
  22423. getIndexBuffer(): Nullable<WebGLBuffer>;
  22424. /** @hidden */
  22425. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22426. /**
  22427. * Release the associated resources for a specific mesh
  22428. * @param mesh defines the source mesh
  22429. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22430. */
  22431. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22432. /**
  22433. * Apply current geometry to a given mesh
  22434. * @param mesh defines the mesh to apply geometry to
  22435. */
  22436. applyToMesh(mesh: Mesh): void;
  22437. private _updateExtend;
  22438. private _applyToMesh;
  22439. private notifyUpdate;
  22440. /**
  22441. * Load the geometry if it was flagged as delay loaded
  22442. * @param scene defines the hosting scene
  22443. * @param onLoaded defines a callback called when the geometry is loaded
  22444. */
  22445. load(scene: Scene, onLoaded?: () => void): void;
  22446. private _queueLoad;
  22447. /**
  22448. * Invert the geometry to move from a right handed system to a left handed one.
  22449. */
  22450. toLeftHanded(): void;
  22451. /** @hidden */
  22452. _resetPointsArrayCache(): void;
  22453. /** @hidden */
  22454. _generatePointsArray(): boolean;
  22455. /**
  22456. * Gets a value indicating if the geometry is disposed
  22457. * @returns true if the geometry was disposed
  22458. */
  22459. isDisposed(): boolean;
  22460. private _disposeVertexArrayObjects;
  22461. /**
  22462. * Free all associated resources
  22463. */
  22464. dispose(): void;
  22465. /**
  22466. * Clone the current geometry into a new geometry
  22467. * @param id defines the unique ID of the new geometry
  22468. * @returns a new geometry object
  22469. */
  22470. copy(id: string): Geometry;
  22471. /**
  22472. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22473. * @return a JSON representation of the current geometry data (without the vertices data)
  22474. */
  22475. serialize(): any;
  22476. private toNumberArray;
  22477. /**
  22478. * Serialize all vertices data into a JSON oject
  22479. * @returns a JSON representation of the current geometry data
  22480. */
  22481. serializeVerticeData(): any;
  22482. /**
  22483. * Extracts a clone of a mesh geometry
  22484. * @param mesh defines the source mesh
  22485. * @param id defines the unique ID of the new geometry object
  22486. * @returns the new geometry object
  22487. */
  22488. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22489. /**
  22490. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22491. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22492. * Be aware Math.random() could cause collisions, but:
  22493. * "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"
  22494. * @returns a string containing a new GUID
  22495. */
  22496. static RandomId(): string;
  22497. /** @hidden */
  22498. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22499. private static _CleanMatricesWeights;
  22500. /**
  22501. * Create a new geometry from persisted data (Using .babylon file format)
  22502. * @param parsedVertexData defines the persisted data
  22503. * @param scene defines the hosting scene
  22504. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22505. * @returns the new geometry object
  22506. */
  22507. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22508. }
  22509. /**
  22510. * Abstract class used to provide common services for all typed geometries
  22511. * @hidden
  22512. */
  22513. export class _PrimitiveGeometry extends Geometry {
  22514. private _canBeRegenerated;
  22515. private _beingRegenerated;
  22516. /**
  22517. * Creates a new typed geometry
  22518. * @param id defines the unique ID of the geometry
  22519. * @param scene defines the hosting scene
  22520. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22521. * @param mesh defines the hosting mesh (can be null)
  22522. */
  22523. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22524. /**
  22525. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  22526. * @returns true if the geometry can be regenerated
  22527. */
  22528. canBeRegenerated(): boolean;
  22529. /**
  22530. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  22531. */
  22532. regenerate(): void;
  22533. /**
  22534. * Clone the geometry
  22535. * @param id defines the unique ID of the new geometry
  22536. * @returns the new geometry
  22537. */
  22538. asNewGeometry(id: string): Geometry;
  22539. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22540. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  22541. /** @hidden */
  22542. _regenerateVertexData(): VertexData;
  22543. copy(id: string): Geometry;
  22544. serialize(): any;
  22545. }
  22546. /**
  22547. * Creates a ribbon geometry
  22548. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  22549. */
  22550. export class RibbonGeometry extends _PrimitiveGeometry {
  22551. /**
  22552. * Defines the array of paths to use
  22553. */
  22554. pathArray: Vector3[][];
  22555. /**
  22556. * Defines if the last and first points of each path in your pathArray must be joined
  22557. */
  22558. closeArray: boolean;
  22559. /**
  22560. * Defines if the last and first points of each path in your pathArray must be joined
  22561. */
  22562. closePath: boolean;
  22563. /**
  22564. * Defines the offset between points
  22565. */
  22566. offset: number;
  22567. /**
  22568. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22569. */
  22570. side: number;
  22571. /**
  22572. * Creates a ribbon geometry
  22573. * @param id defines the unique ID of the geometry
  22574. * @param scene defines the hosting scene
  22575. * @param pathArray defines the array of paths to use
  22576. * @param closeArray defines if the last path and the first path must be joined
  22577. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  22578. * @param offset defines the offset between points
  22579. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22580. * @param mesh defines the hosting mesh (can be null)
  22581. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22582. */
  22583. constructor(id: string, scene: Scene,
  22584. /**
  22585. * Defines the array of paths to use
  22586. */
  22587. pathArray: Vector3[][],
  22588. /**
  22589. * Defines if the last and first points of each path in your pathArray must be joined
  22590. */
  22591. closeArray: boolean,
  22592. /**
  22593. * Defines if the last and first points of each path in your pathArray must be joined
  22594. */
  22595. closePath: boolean,
  22596. /**
  22597. * Defines the offset between points
  22598. */
  22599. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  22600. /**
  22601. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22602. */
  22603. side?: number);
  22604. /** @hidden */
  22605. _regenerateVertexData(): VertexData;
  22606. copy(id: string): Geometry;
  22607. }
  22608. /**
  22609. * Creates a box geometry
  22610. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  22611. */
  22612. export class BoxGeometry extends _PrimitiveGeometry {
  22613. /**
  22614. * Defines the zise of the box (width, height and depth are the same)
  22615. */
  22616. size: number;
  22617. /**
  22618. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22619. */
  22620. side: number;
  22621. /**
  22622. * Creates a box geometry
  22623. * @param id defines the unique ID of the geometry
  22624. * @param scene defines the hosting scene
  22625. * @param size defines the zise of the box (width, height and depth are the same)
  22626. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22627. * @param mesh defines the hosting mesh (can be null)
  22628. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22629. */
  22630. constructor(id: string, scene: Scene,
  22631. /**
  22632. * Defines the zise of the box (width, height and depth are the same)
  22633. */
  22634. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22635. /**
  22636. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22637. */
  22638. side?: number);
  22639. /** @hidden */
  22640. _regenerateVertexData(): VertexData;
  22641. copy(id: string): Geometry;
  22642. serialize(): any;
  22643. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  22644. }
  22645. /**
  22646. * Creates a sphere geometry
  22647. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  22648. */
  22649. export class SphereGeometry extends _PrimitiveGeometry {
  22650. /**
  22651. * Defines the number of segments to use to create the sphere
  22652. */
  22653. segments: number;
  22654. /**
  22655. * Defines the diameter of the sphere
  22656. */
  22657. diameter: number;
  22658. /**
  22659. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22660. */
  22661. side: number;
  22662. /**
  22663. * Create a new sphere geometry
  22664. * @param id defines the unique ID of the geometry
  22665. * @param scene defines the hosting scene
  22666. * @param segments defines the number of segments to use to create the sphere
  22667. * @param diameter defines the diameter of the sphere
  22668. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22669. * @param mesh defines the hosting mesh (can be null)
  22670. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22671. */
  22672. constructor(id: string, scene: Scene,
  22673. /**
  22674. * Defines the number of segments to use to create the sphere
  22675. */
  22676. segments: number,
  22677. /**
  22678. * Defines the diameter of the sphere
  22679. */
  22680. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22681. /**
  22682. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22683. */
  22684. side?: number);
  22685. /** @hidden */
  22686. _regenerateVertexData(): VertexData;
  22687. copy(id: string): Geometry;
  22688. serialize(): any;
  22689. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  22690. }
  22691. /**
  22692. * Creates a disc geometry
  22693. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22694. */
  22695. export class DiscGeometry extends _PrimitiveGeometry {
  22696. /**
  22697. * Defines the radius of the disc
  22698. */
  22699. radius: number;
  22700. /**
  22701. * Defines the tesselation factor to apply to the disc
  22702. */
  22703. tessellation: number;
  22704. /**
  22705. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22706. */
  22707. side: number;
  22708. /**
  22709. * Creates a new disc geometry
  22710. * @param id defines the unique ID of the geometry
  22711. * @param scene defines the hosting scene
  22712. * @param radius defines the radius of the disc
  22713. * @param tessellation defines the tesselation factor to apply to the disc
  22714. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22715. * @param mesh defines the hosting mesh (can be null)
  22716. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22717. */
  22718. constructor(id: string, scene: Scene,
  22719. /**
  22720. * Defines the radius of the disc
  22721. */
  22722. radius: number,
  22723. /**
  22724. * Defines the tesselation factor to apply to the disc
  22725. */
  22726. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22727. /**
  22728. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22729. */
  22730. side?: number);
  22731. /** @hidden */
  22732. _regenerateVertexData(): VertexData;
  22733. copy(id: string): Geometry;
  22734. }
  22735. /**
  22736. * Creates a new cylinder geometry
  22737. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  22738. */
  22739. export class CylinderGeometry extends _PrimitiveGeometry {
  22740. /**
  22741. * Defines the height of the cylinder
  22742. */
  22743. height: number;
  22744. /**
  22745. * Defines the diameter of the cylinder's top cap
  22746. */
  22747. diameterTop: number;
  22748. /**
  22749. * Defines the diameter of the cylinder's bottom cap
  22750. */
  22751. diameterBottom: number;
  22752. /**
  22753. * Defines the tessellation factor to apply to the cylinder
  22754. */
  22755. tessellation: number;
  22756. /**
  22757. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22758. */
  22759. subdivisions: number;
  22760. /**
  22761. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22762. */
  22763. side: number;
  22764. /**
  22765. * Creates a new cylinder geometry
  22766. * @param id defines the unique ID of the geometry
  22767. * @param scene defines the hosting scene
  22768. * @param height defines the height of the cylinder
  22769. * @param diameterTop defines the diameter of the cylinder's top cap
  22770. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  22771. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  22772. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  22773. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22774. * @param mesh defines the hosting mesh (can be null)
  22775. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22776. */
  22777. constructor(id: string, scene: Scene,
  22778. /**
  22779. * Defines the height of the cylinder
  22780. */
  22781. height: number,
  22782. /**
  22783. * Defines the diameter of the cylinder's top cap
  22784. */
  22785. diameterTop: number,
  22786. /**
  22787. * Defines the diameter of the cylinder's bottom cap
  22788. */
  22789. diameterBottom: number,
  22790. /**
  22791. * Defines the tessellation factor to apply to the cylinder
  22792. */
  22793. tessellation: number,
  22794. /**
  22795. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22796. */
  22797. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22798. /**
  22799. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22800. */
  22801. side?: number);
  22802. /** @hidden */
  22803. _regenerateVertexData(): VertexData;
  22804. copy(id: string): Geometry;
  22805. serialize(): any;
  22806. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  22807. }
  22808. /**
  22809. * Creates a new torus geometry
  22810. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  22811. */
  22812. export class TorusGeometry extends _PrimitiveGeometry {
  22813. /**
  22814. * Defines the diameter of the torus
  22815. */
  22816. diameter: number;
  22817. /**
  22818. * Defines the thickness of the torus (ie. internal diameter)
  22819. */
  22820. thickness: number;
  22821. /**
  22822. * Defines the tesselation factor to apply to the torus
  22823. */
  22824. tessellation: number;
  22825. /**
  22826. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22827. */
  22828. side: number;
  22829. /**
  22830. * Creates a new torus geometry
  22831. * @param id defines the unique ID of the geometry
  22832. * @param scene defines the hosting scene
  22833. * @param diameter defines the diameter of the torus
  22834. * @param thickness defines the thickness of the torus (ie. internal diameter)
  22835. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  22836. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22837. * @param mesh defines the hosting mesh (can be null)
  22838. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22839. */
  22840. constructor(id: string, scene: Scene,
  22841. /**
  22842. * Defines the diameter of the torus
  22843. */
  22844. diameter: number,
  22845. /**
  22846. * Defines the thickness of the torus (ie. internal diameter)
  22847. */
  22848. thickness: number,
  22849. /**
  22850. * Defines the tesselation factor to apply to the torus
  22851. */
  22852. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22853. /**
  22854. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22855. */
  22856. side?: number);
  22857. /** @hidden */
  22858. _regenerateVertexData(): VertexData;
  22859. copy(id: string): Geometry;
  22860. serialize(): any;
  22861. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  22862. }
  22863. /**
  22864. * Creates a new ground geometry
  22865. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  22866. */
  22867. export class GroundGeometry extends _PrimitiveGeometry {
  22868. /**
  22869. * Defines the width of the ground
  22870. */
  22871. width: number;
  22872. /**
  22873. * Defines the height of the ground
  22874. */
  22875. height: number;
  22876. /**
  22877. * Defines the subdivisions to apply to the ground
  22878. */
  22879. subdivisions: number;
  22880. /**
  22881. * Creates a new ground geometry
  22882. * @param id defines the unique ID of the geometry
  22883. * @param scene defines the hosting scene
  22884. * @param width defines the width of the ground
  22885. * @param height defines the height of the ground
  22886. * @param subdivisions defines the subdivisions to apply to the ground
  22887. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22888. * @param mesh defines the hosting mesh (can be null)
  22889. */
  22890. constructor(id: string, scene: Scene,
  22891. /**
  22892. * Defines the width of the ground
  22893. */
  22894. width: number,
  22895. /**
  22896. * Defines the height of the ground
  22897. */
  22898. height: number,
  22899. /**
  22900. * Defines the subdivisions to apply to the ground
  22901. */
  22902. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22903. /** @hidden */
  22904. _regenerateVertexData(): VertexData;
  22905. copy(id: string): Geometry;
  22906. serialize(): any;
  22907. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  22908. }
  22909. /**
  22910. * Creates a tiled ground geometry
  22911. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  22912. */
  22913. export class TiledGroundGeometry extends _PrimitiveGeometry {
  22914. /**
  22915. * Defines the minimum value on X axis
  22916. */
  22917. xmin: number;
  22918. /**
  22919. * Defines the minimum value on Z axis
  22920. */
  22921. zmin: number;
  22922. /**
  22923. * Defines the maximum value on X axis
  22924. */
  22925. xmax: number;
  22926. /**
  22927. * Defines the maximum value on Z axis
  22928. */
  22929. zmax: number;
  22930. /**
  22931. * Defines the subdivisions to apply to the ground
  22932. */
  22933. subdivisions: {
  22934. w: number;
  22935. h: number;
  22936. };
  22937. /**
  22938. * Defines the precision to use when computing the tiles
  22939. */
  22940. precision: {
  22941. w: number;
  22942. h: number;
  22943. };
  22944. /**
  22945. * Creates a tiled ground geometry
  22946. * @param id defines the unique ID of the geometry
  22947. * @param scene defines the hosting scene
  22948. * @param xmin defines the minimum value on X axis
  22949. * @param zmin defines the minimum value on Z axis
  22950. * @param xmax defines the maximum value on X axis
  22951. * @param zmax defines the maximum value on Z axis
  22952. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  22953. * @param precision defines the precision to use when computing the tiles
  22954. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22955. * @param mesh defines the hosting mesh (can be null)
  22956. */
  22957. constructor(id: string, scene: Scene,
  22958. /**
  22959. * Defines the minimum value on X axis
  22960. */
  22961. xmin: number,
  22962. /**
  22963. * Defines the minimum value on Z axis
  22964. */
  22965. zmin: number,
  22966. /**
  22967. * Defines the maximum value on X axis
  22968. */
  22969. xmax: number,
  22970. /**
  22971. * Defines the maximum value on Z axis
  22972. */
  22973. zmax: number,
  22974. /**
  22975. * Defines the subdivisions to apply to the ground
  22976. */
  22977. subdivisions: {
  22978. w: number;
  22979. h: number;
  22980. },
  22981. /**
  22982. * Defines the precision to use when computing the tiles
  22983. */
  22984. precision: {
  22985. w: number;
  22986. h: number;
  22987. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22988. /** @hidden */
  22989. _regenerateVertexData(): VertexData;
  22990. copy(id: string): Geometry;
  22991. }
  22992. /**
  22993. * Creates a plane geometry
  22994. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  22995. */
  22996. export class PlaneGeometry extends _PrimitiveGeometry {
  22997. /**
  22998. * Defines the size of the plane (width === height)
  22999. */
  23000. size: number;
  23001. /**
  23002. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23003. */
  23004. side: number;
  23005. /**
  23006. * Creates a plane geometry
  23007. * @param id defines the unique ID of the geometry
  23008. * @param scene defines the hosting scene
  23009. * @param size defines the size of the plane (width === height)
  23010. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23011. * @param mesh defines the hosting mesh (can be null)
  23012. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23013. */
  23014. constructor(id: string, scene: Scene,
  23015. /**
  23016. * Defines the size of the plane (width === height)
  23017. */
  23018. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23019. /**
  23020. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23021. */
  23022. side?: number);
  23023. /** @hidden */
  23024. _regenerateVertexData(): VertexData;
  23025. copy(id: string): Geometry;
  23026. serialize(): any;
  23027. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  23028. }
  23029. /**
  23030. * Creates a torus knot geometry
  23031. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  23032. */
  23033. export class TorusKnotGeometry extends _PrimitiveGeometry {
  23034. /**
  23035. * Defines the radius of the torus knot
  23036. */
  23037. radius: number;
  23038. /**
  23039. * Defines the thickness of the torus knot tube
  23040. */
  23041. tube: number;
  23042. /**
  23043. * Defines the number of radial segments
  23044. */
  23045. radialSegments: number;
  23046. /**
  23047. * Defines the number of tubular segments
  23048. */
  23049. tubularSegments: number;
  23050. /**
  23051. * Defines the first number of windings
  23052. */
  23053. p: number;
  23054. /**
  23055. * Defines the second number of windings
  23056. */
  23057. q: number;
  23058. /**
  23059. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23060. */
  23061. side: number;
  23062. /**
  23063. * Creates a torus knot geometry
  23064. * @param id defines the unique ID of the geometry
  23065. * @param scene defines the hosting scene
  23066. * @param radius defines the radius of the torus knot
  23067. * @param tube defines the thickness of the torus knot tube
  23068. * @param radialSegments defines the number of radial segments
  23069. * @param tubularSegments defines the number of tubular segments
  23070. * @param p defines the first number of windings
  23071. * @param q defines the second number of windings
  23072. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  23073. * @param mesh defines the hosting mesh (can be null)
  23074. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23075. */
  23076. constructor(id: string, scene: Scene,
  23077. /**
  23078. * Defines the radius of the torus knot
  23079. */
  23080. radius: number,
  23081. /**
  23082. * Defines the thickness of the torus knot tube
  23083. */
  23084. tube: number,
  23085. /**
  23086. * Defines the number of radial segments
  23087. */
  23088. radialSegments: number,
  23089. /**
  23090. * Defines the number of tubular segments
  23091. */
  23092. tubularSegments: number,
  23093. /**
  23094. * Defines the first number of windings
  23095. */
  23096. p: number,
  23097. /**
  23098. * Defines the second number of windings
  23099. */
  23100. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  23101. /**
  23102. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  23103. */
  23104. side?: number);
  23105. /** @hidden */
  23106. _regenerateVertexData(): VertexData;
  23107. copy(id: string): Geometry;
  23108. serialize(): any;
  23109. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  23110. }
  23111. }
  23112. declare module "babylonjs/Meshes/mesh.vertexData" {
  23113. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23114. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23115. import { Geometry } from "babylonjs/Meshes/geometry";
  23116. import { Mesh } from "babylonjs/Meshes/mesh";
  23117. /**
  23118. * Define an interface for all classes that will get and set the data on vertices
  23119. */
  23120. export interface IGetSetVerticesData {
  23121. /**
  23122. * Gets a boolean indicating if specific vertex data is present
  23123. * @param kind defines the vertex data kind to use
  23124. * @returns true is data kind is present
  23125. */
  23126. isVerticesDataPresent(kind: string): boolean;
  23127. /**
  23128. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23129. * @param kind defines the data kind (Position, normal, etc...)
  23130. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23131. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23132. * @returns a float array containing vertex data
  23133. */
  23134. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23135. /**
  23136. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23137. * @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.
  23138. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23139. * @returns the indices array or an empty array if the mesh has no geometry
  23140. */
  23141. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23142. /**
  23143. * Set specific vertex data
  23144. * @param kind defines the data kind (Position, normal, etc...)
  23145. * @param data defines the vertex data to use
  23146. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23147. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23148. */
  23149. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23150. /**
  23151. * Update a specific associated vertex buffer
  23152. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23153. * - VertexBuffer.PositionKind
  23154. * - VertexBuffer.UVKind
  23155. * - VertexBuffer.UV2Kind
  23156. * - VertexBuffer.UV3Kind
  23157. * - VertexBuffer.UV4Kind
  23158. * - VertexBuffer.UV5Kind
  23159. * - VertexBuffer.UV6Kind
  23160. * - VertexBuffer.ColorKind
  23161. * - VertexBuffer.MatricesIndicesKind
  23162. * - VertexBuffer.MatricesIndicesExtraKind
  23163. * - VertexBuffer.MatricesWeightsKind
  23164. * - VertexBuffer.MatricesWeightsExtraKind
  23165. * @param data defines the data source
  23166. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23167. * @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)
  23168. */
  23169. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23170. /**
  23171. * Creates a new index buffer
  23172. * @param indices defines the indices to store in the index buffer
  23173. * @param totalVertices defines the total number of vertices (could be null)
  23174. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23175. */
  23176. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23177. }
  23178. /**
  23179. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23180. */
  23181. export class VertexData {
  23182. /**
  23183. * Mesh side orientation : usually the external or front surface
  23184. */
  23185. static readonly FRONTSIDE: number;
  23186. /**
  23187. * Mesh side orientation : usually the internal or back surface
  23188. */
  23189. static readonly BACKSIDE: number;
  23190. /**
  23191. * Mesh side orientation : both internal and external or front and back surfaces
  23192. */
  23193. static readonly DOUBLESIDE: number;
  23194. /**
  23195. * Mesh side orientation : by default, `FRONTSIDE`
  23196. */
  23197. static readonly DEFAULTSIDE: number;
  23198. /**
  23199. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23200. */
  23201. positions: Nullable<FloatArray>;
  23202. /**
  23203. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23204. */
  23205. normals: Nullable<FloatArray>;
  23206. /**
  23207. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23208. */
  23209. tangents: Nullable<FloatArray>;
  23210. /**
  23211. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23212. */
  23213. uvs: Nullable<FloatArray>;
  23214. /**
  23215. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23216. */
  23217. uvs2: Nullable<FloatArray>;
  23218. /**
  23219. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23220. */
  23221. uvs3: Nullable<FloatArray>;
  23222. /**
  23223. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23224. */
  23225. uvs4: Nullable<FloatArray>;
  23226. /**
  23227. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23228. */
  23229. uvs5: Nullable<FloatArray>;
  23230. /**
  23231. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23232. */
  23233. uvs6: Nullable<FloatArray>;
  23234. /**
  23235. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23236. */
  23237. colors: Nullable<FloatArray>;
  23238. /**
  23239. * 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).
  23240. */
  23241. matricesIndices: Nullable<FloatArray>;
  23242. /**
  23243. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23244. */
  23245. matricesWeights: Nullable<FloatArray>;
  23246. /**
  23247. * An array extending the number of possible indices
  23248. */
  23249. matricesIndicesExtra: Nullable<FloatArray>;
  23250. /**
  23251. * An array extending the number of possible weights when the number of indices is extended
  23252. */
  23253. matricesWeightsExtra: Nullable<FloatArray>;
  23254. /**
  23255. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23256. */
  23257. indices: Nullable<IndicesArray>;
  23258. /**
  23259. * Uses the passed data array to set the set the values for the specified kind of data
  23260. * @param data a linear array of floating numbers
  23261. * @param kind the type of data that is being set, eg positions, colors etc
  23262. */
  23263. set(data: FloatArray, kind: string): void;
  23264. /**
  23265. * Associates the vertexData to the passed Mesh.
  23266. * Sets it as updatable or not (default `false`)
  23267. * @param mesh the mesh the vertexData is applied to
  23268. * @param updatable when used and having the value true allows new data to update the vertexData
  23269. * @returns the VertexData
  23270. */
  23271. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23272. /**
  23273. * Associates the vertexData to the passed Geometry.
  23274. * Sets it as updatable or not (default `false`)
  23275. * @param geometry the geometry the vertexData is applied to
  23276. * @param updatable when used and having the value true allows new data to update the vertexData
  23277. * @returns VertexData
  23278. */
  23279. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23280. /**
  23281. * Updates the associated mesh
  23282. * @param mesh the mesh to be updated
  23283. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23284. * @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
  23285. * @returns VertexData
  23286. */
  23287. updateMesh(mesh: Mesh): VertexData;
  23288. /**
  23289. * Updates the associated geometry
  23290. * @param geometry the geometry to be updated
  23291. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23292. * @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
  23293. * @returns VertexData.
  23294. */
  23295. updateGeometry(geometry: Geometry): VertexData;
  23296. private _applyTo;
  23297. private _update;
  23298. /**
  23299. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23300. * @param matrix the transforming matrix
  23301. * @returns the VertexData
  23302. */
  23303. transform(matrix: Matrix): VertexData;
  23304. /**
  23305. * Merges the passed VertexData into the current one
  23306. * @param other the VertexData to be merged into the current one
  23307. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23308. * @returns the modified VertexData
  23309. */
  23310. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23311. private _mergeElement;
  23312. private _validate;
  23313. /**
  23314. * Serializes the VertexData
  23315. * @returns a serialized object
  23316. */
  23317. serialize(): any;
  23318. /**
  23319. * Extracts the vertexData from a mesh
  23320. * @param mesh the mesh from which to extract the VertexData
  23321. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23322. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23323. * @returns the object VertexData associated to the passed mesh
  23324. */
  23325. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23326. /**
  23327. * Extracts the vertexData from the geometry
  23328. * @param geometry the geometry from which to extract the VertexData
  23329. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23330. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23331. * @returns the object VertexData associated to the passed mesh
  23332. */
  23333. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23334. private static _ExtractFrom;
  23335. /**
  23336. * Creates the VertexData for a Ribbon
  23337. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23338. * * pathArray array of paths, each of which an array of successive Vector3
  23339. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23340. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23341. * * 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
  23342. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23343. * * 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)
  23344. * * 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)
  23345. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23346. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23347. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23348. * @returns the VertexData of the ribbon
  23349. */
  23350. static CreateRibbon(options: {
  23351. pathArray: Vector3[][];
  23352. closeArray?: boolean;
  23353. closePath?: boolean;
  23354. offset?: number;
  23355. sideOrientation?: number;
  23356. frontUVs?: Vector4;
  23357. backUVs?: Vector4;
  23358. invertUV?: boolean;
  23359. uvs?: Vector2[];
  23360. colors?: Color4[];
  23361. }): VertexData;
  23362. /**
  23363. * Creates the VertexData for a box
  23364. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23365. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23366. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23367. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23368. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23369. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23370. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23371. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23372. * * 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)
  23373. * * 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)
  23374. * @returns the VertexData of the box
  23375. */
  23376. static CreateBox(options: {
  23377. size?: number;
  23378. width?: number;
  23379. height?: number;
  23380. depth?: number;
  23381. faceUV?: Vector4[];
  23382. faceColors?: Color4[];
  23383. sideOrientation?: number;
  23384. frontUVs?: Vector4;
  23385. backUVs?: Vector4;
  23386. }): VertexData;
  23387. /**
  23388. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23389. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23390. * * segments sets the number of horizontal strips optional, default 32
  23391. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23392. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23393. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23394. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23395. * * 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
  23396. * * 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
  23397. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23398. * * 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)
  23399. * * 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)
  23400. * @returns the VertexData of the ellipsoid
  23401. */
  23402. static CreateSphere(options: {
  23403. segments?: number;
  23404. diameter?: number;
  23405. diameterX?: number;
  23406. diameterY?: number;
  23407. diameterZ?: number;
  23408. arc?: number;
  23409. slice?: number;
  23410. sideOrientation?: number;
  23411. frontUVs?: Vector4;
  23412. backUVs?: Vector4;
  23413. }): VertexData;
  23414. /**
  23415. * Creates the VertexData for a cylinder, cone or prism
  23416. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23417. * * height sets the height (y direction) of the cylinder, optional, default 2
  23418. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23419. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23420. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23421. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23422. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23423. * * 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
  23424. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23425. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23426. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23427. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23428. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23429. * * 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)
  23430. * * 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)
  23431. * @returns the VertexData of the cylinder, cone or prism
  23432. */
  23433. static CreateCylinder(options: {
  23434. height?: number;
  23435. diameterTop?: number;
  23436. diameterBottom?: number;
  23437. diameter?: number;
  23438. tessellation?: number;
  23439. subdivisions?: number;
  23440. arc?: number;
  23441. faceColors?: Color4[];
  23442. faceUV?: Vector4[];
  23443. hasRings?: boolean;
  23444. enclose?: boolean;
  23445. sideOrientation?: number;
  23446. frontUVs?: Vector4;
  23447. backUVs?: Vector4;
  23448. }): VertexData;
  23449. /**
  23450. * Creates the VertexData for a torus
  23451. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23452. * * diameter the diameter of the torus, optional default 1
  23453. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23454. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23455. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23456. * * 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)
  23457. * * 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)
  23458. * @returns the VertexData of the torus
  23459. */
  23460. static CreateTorus(options: {
  23461. diameter?: number;
  23462. thickness?: number;
  23463. tessellation?: number;
  23464. sideOrientation?: number;
  23465. frontUVs?: Vector4;
  23466. backUVs?: Vector4;
  23467. }): VertexData;
  23468. /**
  23469. * Creates the VertexData of the LineSystem
  23470. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23471. * - lines an array of lines, each line being an array of successive Vector3
  23472. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23473. * @returns the VertexData of the LineSystem
  23474. */
  23475. static CreateLineSystem(options: {
  23476. lines: Vector3[][];
  23477. colors?: Nullable<Color4[][]>;
  23478. }): VertexData;
  23479. /**
  23480. * Create the VertexData for a DashedLines
  23481. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23482. * - points an array successive Vector3
  23483. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23484. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23485. * - dashNb the intended total number of dashes, optional, default 200
  23486. * @returns the VertexData for the DashedLines
  23487. */
  23488. static CreateDashedLines(options: {
  23489. points: Vector3[];
  23490. dashSize?: number;
  23491. gapSize?: number;
  23492. dashNb?: number;
  23493. }): VertexData;
  23494. /**
  23495. * Creates the VertexData for a Ground
  23496. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23497. * - width the width (x direction) of the ground, optional, default 1
  23498. * - height the height (z direction) of the ground, optional, default 1
  23499. * - subdivisions the number of subdivisions per side, optional, default 1
  23500. * @returns the VertexData of the Ground
  23501. */
  23502. static CreateGround(options: {
  23503. width?: number;
  23504. height?: number;
  23505. subdivisions?: number;
  23506. subdivisionsX?: number;
  23507. subdivisionsY?: number;
  23508. }): VertexData;
  23509. /**
  23510. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23511. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23512. * * xmin the ground minimum X coordinate, optional, default -1
  23513. * * zmin the ground minimum Z coordinate, optional, default -1
  23514. * * xmax the ground maximum X coordinate, optional, default 1
  23515. * * zmax the ground maximum Z coordinate, optional, default 1
  23516. * * 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}
  23517. * * 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}
  23518. * @returns the VertexData of the TiledGround
  23519. */
  23520. static CreateTiledGround(options: {
  23521. xmin: number;
  23522. zmin: number;
  23523. xmax: number;
  23524. zmax: number;
  23525. subdivisions?: {
  23526. w: number;
  23527. h: number;
  23528. };
  23529. precision?: {
  23530. w: number;
  23531. h: number;
  23532. };
  23533. }): VertexData;
  23534. /**
  23535. * Creates the VertexData of the Ground designed from a heightmap
  23536. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23537. * * width the width (x direction) of the ground
  23538. * * height the height (z direction) of the ground
  23539. * * subdivisions the number of subdivisions per side
  23540. * * minHeight the minimum altitude on the ground, optional, default 0
  23541. * * maxHeight the maximum altitude on the ground, optional default 1
  23542. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23543. * * buffer the array holding the image color data
  23544. * * bufferWidth the width of image
  23545. * * bufferHeight the height of image
  23546. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23547. * @returns the VertexData of the Ground designed from a heightmap
  23548. */
  23549. static CreateGroundFromHeightMap(options: {
  23550. width: number;
  23551. height: number;
  23552. subdivisions: number;
  23553. minHeight: number;
  23554. maxHeight: number;
  23555. colorFilter: Color3;
  23556. buffer: Uint8Array;
  23557. bufferWidth: number;
  23558. bufferHeight: number;
  23559. alphaFilter: number;
  23560. }): VertexData;
  23561. /**
  23562. * Creates the VertexData for a Plane
  23563. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23564. * * size sets the width and height of the plane to the value of size, optional default 1
  23565. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23566. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23567. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23568. * * 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)
  23569. * * 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)
  23570. * @returns the VertexData of the box
  23571. */
  23572. static CreatePlane(options: {
  23573. size?: number;
  23574. width?: number;
  23575. height?: number;
  23576. sideOrientation?: number;
  23577. frontUVs?: Vector4;
  23578. backUVs?: Vector4;
  23579. }): VertexData;
  23580. /**
  23581. * Creates the VertexData of the Disc or regular Polygon
  23582. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23583. * * radius the radius of the disc, optional default 0.5
  23584. * * tessellation the number of polygon sides, optional, default 64
  23585. * * 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
  23586. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23587. * * 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)
  23588. * * 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)
  23589. * @returns the VertexData of the box
  23590. */
  23591. static CreateDisc(options: {
  23592. radius?: number;
  23593. tessellation?: number;
  23594. arc?: number;
  23595. sideOrientation?: number;
  23596. frontUVs?: Vector4;
  23597. backUVs?: Vector4;
  23598. }): VertexData;
  23599. /**
  23600. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23601. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23602. * @param polygon a mesh built from polygonTriangulation.build()
  23603. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23604. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23605. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23606. * @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)
  23607. * @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)
  23608. * @returns the VertexData of the Polygon
  23609. */
  23610. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23611. /**
  23612. * Creates the VertexData of the IcoSphere
  23613. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23614. * * radius the radius of the IcoSphere, optional default 1
  23615. * * radiusX allows stretching in the x direction, optional, default radius
  23616. * * radiusY allows stretching in the y direction, optional, default radius
  23617. * * radiusZ allows stretching in the z direction, optional, default radius
  23618. * * flat when true creates a flat shaded mesh, optional, default true
  23619. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23620. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23621. * * 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)
  23622. * * 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)
  23623. * @returns the VertexData of the IcoSphere
  23624. */
  23625. static CreateIcoSphere(options: {
  23626. radius?: number;
  23627. radiusX?: number;
  23628. radiusY?: number;
  23629. radiusZ?: number;
  23630. flat?: boolean;
  23631. subdivisions?: number;
  23632. sideOrientation?: number;
  23633. frontUVs?: Vector4;
  23634. backUVs?: Vector4;
  23635. }): VertexData;
  23636. /**
  23637. * Creates the VertexData for a Polyhedron
  23638. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23639. * * type provided types are:
  23640. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23641. * * 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)
  23642. * * size the size of the IcoSphere, optional default 1
  23643. * * sizeX allows stretching in the x direction, optional, default size
  23644. * * sizeY allows stretching in the y direction, optional, default size
  23645. * * sizeZ allows stretching in the z direction, optional, default size
  23646. * * 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
  23647. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23648. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23649. * * flat when true creates a flat shaded mesh, optional, default true
  23650. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23651. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23652. * * 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)
  23653. * * 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)
  23654. * @returns the VertexData of the Polyhedron
  23655. */
  23656. static CreatePolyhedron(options: {
  23657. type?: number;
  23658. size?: number;
  23659. sizeX?: number;
  23660. sizeY?: number;
  23661. sizeZ?: number;
  23662. custom?: any;
  23663. faceUV?: Vector4[];
  23664. faceColors?: Color4[];
  23665. flat?: boolean;
  23666. sideOrientation?: number;
  23667. frontUVs?: Vector4;
  23668. backUVs?: Vector4;
  23669. }): VertexData;
  23670. /**
  23671. * Creates the VertexData for a TorusKnot
  23672. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23673. * * radius the radius of the torus knot, optional, default 2
  23674. * * tube the thickness of the tube, optional, default 0.5
  23675. * * radialSegments the number of sides on each tube segments, optional, default 32
  23676. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23677. * * p the number of windings around the z axis, optional, default 2
  23678. * * q the number of windings around the x axis, optional, default 3
  23679. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23680. * * 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)
  23681. * * 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)
  23682. * @returns the VertexData of the Torus Knot
  23683. */
  23684. static CreateTorusKnot(options: {
  23685. radius?: number;
  23686. tube?: number;
  23687. radialSegments?: number;
  23688. tubularSegments?: number;
  23689. p?: number;
  23690. q?: number;
  23691. sideOrientation?: number;
  23692. frontUVs?: Vector4;
  23693. backUVs?: Vector4;
  23694. }): VertexData;
  23695. /**
  23696. * Compute normals for given positions and indices
  23697. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23698. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23699. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23700. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23701. * * facetNormals : optional array of facet normals (vector3)
  23702. * * facetPositions : optional array of facet positions (vector3)
  23703. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23704. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23705. * * bInfo : optional bounding info, required for facetPartitioning computation
  23706. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23707. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23708. * * useRightHandedSystem: optional boolean to for right handed system computation
  23709. * * depthSort : optional boolean to enable the facet depth sort computation
  23710. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23711. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23712. */
  23713. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23714. facetNormals?: any;
  23715. facetPositions?: any;
  23716. facetPartitioning?: any;
  23717. ratio?: number;
  23718. bInfo?: any;
  23719. bbSize?: Vector3;
  23720. subDiv?: any;
  23721. useRightHandedSystem?: boolean;
  23722. depthSort?: boolean;
  23723. distanceTo?: Vector3;
  23724. depthSortedFacets?: any;
  23725. }): void;
  23726. private static _ComputeSides;
  23727. /**
  23728. * Applies VertexData created from the imported parameters to the geometry
  23729. * @param parsedVertexData the parsed data from an imported file
  23730. * @param geometry the geometry to apply the VertexData to
  23731. */
  23732. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23733. }
  23734. }
  23735. declare module "babylonjs/Meshes/polygonMesh" {
  23736. import { Scene } from "babylonjs/scene";
  23737. import { Vector2, Path2 } from "babylonjs/Maths/math";
  23738. import { Mesh } from "babylonjs/Meshes/mesh";
  23739. /**
  23740. * Polygon
  23741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  23742. */
  23743. export class Polygon {
  23744. /**
  23745. * Creates a rectangle
  23746. * @param xmin bottom X coord
  23747. * @param ymin bottom Y coord
  23748. * @param xmax top X coord
  23749. * @param ymax top Y coord
  23750. * @returns points that make the resulting rectation
  23751. */
  23752. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23753. /**
  23754. * Creates a circle
  23755. * @param radius radius of circle
  23756. * @param cx scale in x
  23757. * @param cy scale in y
  23758. * @param numberOfSides number of sides that make up the circle
  23759. * @returns points that make the resulting circle
  23760. */
  23761. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23762. /**
  23763. * Creates a polygon from input string
  23764. * @param input Input polygon data
  23765. * @returns the parsed points
  23766. */
  23767. static Parse(input: string): Vector2[];
  23768. /**
  23769. * Starts building a polygon from x and y coordinates
  23770. * @param x x coordinate
  23771. * @param y y coordinate
  23772. * @returns the started path2
  23773. */
  23774. static StartingAt(x: number, y: number): Path2;
  23775. }
  23776. /**
  23777. * Builds a polygon
  23778. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  23779. */
  23780. export class PolygonMeshBuilder {
  23781. private _points;
  23782. private _outlinepoints;
  23783. private _holes;
  23784. private _name;
  23785. private _scene;
  23786. private _epoints;
  23787. private _eholes;
  23788. private _addToepoint;
  23789. /**
  23790. * Babylon reference to the earcut plugin.
  23791. */
  23792. bjsEarcut: any;
  23793. /**
  23794. * Creates a PolygonMeshBuilder
  23795. * @param name name of the builder
  23796. * @param contours Path of the polygon
  23797. * @param scene scene to add to
  23798. */
  23799. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  23800. /**
  23801. * Adds a whole within the polygon
  23802. * @param hole Array of points defining the hole
  23803. * @returns this
  23804. */
  23805. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23806. /**
  23807. * Creates the polygon
  23808. * @param updatable If the mesh should be updatable
  23809. * @param depth The depth of the mesh created
  23810. * @returns the created mesh
  23811. */
  23812. build(updatable?: boolean, depth?: number): Mesh;
  23813. /**
  23814. * Adds a side to the polygon
  23815. * @param positions points that make the polygon
  23816. * @param normals normals of the polygon
  23817. * @param uvs uvs of the polygon
  23818. * @param indices indices of the polygon
  23819. * @param bounds bounds of the polygon
  23820. * @param points points of the polygon
  23821. * @param depth depth of the polygon
  23822. * @param flip flip of the polygon
  23823. */
  23824. private addSide;
  23825. }
  23826. }
  23827. declare module "babylonjs/Meshes/meshBuilder" {
  23828. import { Nullable } from "babylonjs/types";
  23829. import { Scene } from "babylonjs/scene";
  23830. import { Vector3, Vector2, Color3, Color4, Plane, Vector4 } from "babylonjs/Maths/math";
  23831. import { Mesh } from "babylonjs/Meshes/mesh";
  23832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23833. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23834. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23835. /**
  23836. * Class containing static functions to help procedurally build meshes
  23837. */
  23838. export class MeshBuilder {
  23839. private static _UpdateSideOrientation;
  23840. /**
  23841. * Creates a box mesh
  23842. * * The parameter `size` sets the size (float) of each box side (default 1)
  23843. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  23844. * * 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)
  23845. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  23846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23849. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  23850. * @param name defines the name of the mesh
  23851. * @param options defines the options used to create the mesh
  23852. * @param scene defines the hosting scene
  23853. * @returns the box mesh
  23854. */
  23855. static CreateBox(name: string, options: {
  23856. size?: number;
  23857. width?: number;
  23858. height?: number;
  23859. depth?: number;
  23860. faceUV?: Vector4[];
  23861. faceColors?: Color4[];
  23862. sideOrientation?: number;
  23863. frontUVs?: Vector4;
  23864. backUVs?: Vector4;
  23865. updatable?: boolean;
  23866. }, scene?: Nullable<Scene>): Mesh;
  23867. /**
  23868. * Creates a sphere mesh
  23869. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  23870. * * 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`)
  23871. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  23872. * * 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
  23873. * * 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)
  23874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23877. * @param name defines the name of the mesh
  23878. * @param options defines the options used to create the mesh
  23879. * @param scene defines the hosting scene
  23880. * @returns the sphere mesh
  23881. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  23882. */
  23883. static CreateSphere(name: string, options: {
  23884. segments?: number;
  23885. diameter?: number;
  23886. diameterX?: number;
  23887. diameterY?: number;
  23888. diameterZ?: number;
  23889. arc?: number;
  23890. slice?: number;
  23891. sideOrientation?: number;
  23892. frontUVs?: Vector4;
  23893. backUVs?: Vector4;
  23894. updatable?: boolean;
  23895. }, scene: any): Mesh;
  23896. /**
  23897. * Creates a plane polygonal mesh. By default, this is a disc
  23898. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23899. * * 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
  23900. * * 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
  23901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23904. * @param name defines the name of the mesh
  23905. * @param options defines the options used to create the mesh
  23906. * @param scene defines the hosting scene
  23907. * @returns the plane polygonal mesh
  23908. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23909. */
  23910. static CreateDisc(name: string, options: {
  23911. radius?: number;
  23912. tessellation?: number;
  23913. arc?: number;
  23914. updatable?: boolean;
  23915. sideOrientation?: number;
  23916. frontUVs?: Vector4;
  23917. backUVs?: Vector4;
  23918. }, scene?: Nullable<Scene>): Mesh;
  23919. /**
  23920. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23921. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23922. * * 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`)
  23923. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23924. * * 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
  23925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23928. * @param name defines the name of the mesh
  23929. * @param options defines the options used to create the mesh
  23930. * @param scene defines the hosting scene
  23931. * @returns the icosahedron mesh
  23932. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23933. */
  23934. static CreateIcoSphere(name: string, options: {
  23935. radius?: number;
  23936. radiusX?: number;
  23937. radiusY?: number;
  23938. radiusZ?: number;
  23939. flat?: boolean;
  23940. subdivisions?: number;
  23941. sideOrientation?: number;
  23942. frontUVs?: Vector4;
  23943. backUVs?: Vector4;
  23944. updatable?: boolean;
  23945. }, scene: Scene): Mesh;
  23946. /**
  23947. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23948. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  23949. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  23950. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  23951. * * 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
  23952. * * 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
  23953. * * 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
  23954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23956. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23957. * * 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
  23958. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  23959. * * 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
  23960. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  23961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23962. * @param name defines the name of the mesh
  23963. * @param options defines the options used to create the mesh
  23964. * @param scene defines the hosting scene
  23965. * @returns the ribbon mesh
  23966. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  23967. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23968. */
  23969. static CreateRibbon(name: string, options: {
  23970. pathArray: Vector3[][];
  23971. closeArray?: boolean;
  23972. closePath?: boolean;
  23973. offset?: number;
  23974. updatable?: boolean;
  23975. sideOrientation?: number;
  23976. frontUVs?: Vector4;
  23977. backUVs?: Vector4;
  23978. instance?: Mesh;
  23979. invertUV?: boolean;
  23980. uvs?: Vector2[];
  23981. colors?: Color4[];
  23982. }, scene?: Nullable<Scene>): Mesh;
  23983. /**
  23984. * Creates a cylinder or a cone mesh
  23985. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23986. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23987. * * 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.
  23988. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23989. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23990. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  23991. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  23992. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  23993. * * 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).
  23994. * * 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
  23995. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  23996. * * 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
  23997. * * 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.
  23998. * * If `enclose` is false, a ring surface is one element.
  23999. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  24000. * * 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
  24001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24004. * @param name defines the name of the mesh
  24005. * @param options defines the options used to create the mesh
  24006. * @param scene defines the hosting scene
  24007. * @returns the cylinder mesh
  24008. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  24009. */
  24010. static CreateCylinder(name: string, options: {
  24011. height?: number;
  24012. diameterTop?: number;
  24013. diameterBottom?: number;
  24014. diameter?: number;
  24015. tessellation?: number;
  24016. subdivisions?: number;
  24017. arc?: number;
  24018. faceColors?: Color4[];
  24019. faceUV?: Vector4[];
  24020. updatable?: boolean;
  24021. hasRings?: boolean;
  24022. enclose?: boolean;
  24023. sideOrientation?: number;
  24024. frontUVs?: Vector4;
  24025. backUVs?: Vector4;
  24026. }, scene: any): Mesh;
  24027. /**
  24028. * Creates a torus mesh
  24029. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  24030. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  24031. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  24032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24035. * @param name defines the name of the mesh
  24036. * @param options defines the options used to create the mesh
  24037. * @param scene defines the hosting scene
  24038. * @returns the torus mesh
  24039. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  24040. */
  24041. static CreateTorus(name: string, options: {
  24042. diameter?: number;
  24043. thickness?: number;
  24044. tessellation?: number;
  24045. updatable?: boolean;
  24046. sideOrientation?: number;
  24047. frontUVs?: Vector4;
  24048. backUVs?: Vector4;
  24049. }, scene: any): Mesh;
  24050. /**
  24051. * Creates a torus knot mesh
  24052. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  24053. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  24054. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  24055. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  24056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24059. * @param name defines the name of the mesh
  24060. * @param options defines the options used to create the mesh
  24061. * @param scene defines the hosting scene
  24062. * @returns the torus knot mesh
  24063. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  24064. */
  24065. static CreateTorusKnot(name: string, options: {
  24066. radius?: number;
  24067. tube?: number;
  24068. radialSegments?: number;
  24069. tubularSegments?: number;
  24070. p?: number;
  24071. q?: number;
  24072. updatable?: boolean;
  24073. sideOrientation?: number;
  24074. frontUVs?: Vector4;
  24075. backUVs?: Vector4;
  24076. }, scene: any): Mesh;
  24077. /**
  24078. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  24079. * * 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
  24080. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  24081. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  24082. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  24083. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  24084. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  24085. * * 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
  24086. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  24087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24088. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  24089. * @param name defines the name of the new line system
  24090. * @param options defines the options used to create the line system
  24091. * @param scene defines the hosting scene
  24092. * @returns a new line system mesh
  24093. */
  24094. static CreateLineSystem(name: string, options: {
  24095. lines: Vector3[][];
  24096. updatable?: boolean;
  24097. instance?: Nullable<LinesMesh>;
  24098. colors?: Nullable<Color4[][]>;
  24099. useVertexAlpha?: boolean;
  24100. }, scene: Nullable<Scene>): LinesMesh;
  24101. /**
  24102. * Creates a line mesh
  24103. * 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
  24104. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  24105. * * The parameter `points` is an array successive Vector3
  24106. * * 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
  24107. * * The optional parameter `colors` is an array of successive Color4, one per line point
  24108. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  24109. * * When updating an instance, remember that only point positions can change, not the number of points
  24110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  24112. * @param name defines the name of the new line system
  24113. * @param options defines the options used to create the line system
  24114. * @param scene defines the hosting scene
  24115. * @returns a new line mesh
  24116. */
  24117. static CreateLines(name: string, options: {
  24118. points: Vector3[];
  24119. updatable?: boolean;
  24120. instance?: Nullable<LinesMesh>;
  24121. colors?: Color4[];
  24122. useVertexAlpha?: boolean;
  24123. }, scene?: Nullable<Scene>): LinesMesh;
  24124. /**
  24125. * Creates a dashed line mesh
  24126. * * 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
  24127. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  24128. * * The parameter `points` is an array successive Vector3
  24129. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  24130. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  24131. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24132. * * 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
  24133. * * When updating an instance, remember that only point positions can change, not the number of points
  24134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24135. * @param name defines the name of the mesh
  24136. * @param options defines the options used to create the mesh
  24137. * @param scene defines the hosting scene
  24138. * @returns the dashed line mesh
  24139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  24140. */
  24141. static CreateDashedLines(name: string, options: {
  24142. points: Vector3[];
  24143. dashSize?: number;
  24144. gapSize?: number;
  24145. dashNb?: number;
  24146. updatable?: boolean;
  24147. instance?: LinesMesh;
  24148. }, scene?: Nullable<Scene>): LinesMesh;
  24149. /**
  24150. * 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.
  24151. * * 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.
  24152. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  24153. * * 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.
  24154. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  24155. * * 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
  24156. * * 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
  24157. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  24158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24160. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  24161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24162. * @param name defines the name of the mesh
  24163. * @param options defines the options used to create the mesh
  24164. * @param scene defines the hosting scene
  24165. * @returns the extruded shape mesh
  24166. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  24167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24168. */
  24169. static ExtrudeShape(name: string, options: {
  24170. shape: Vector3[];
  24171. path: Vector3[];
  24172. scale?: number;
  24173. rotation?: number;
  24174. cap?: number;
  24175. updatable?: boolean;
  24176. sideOrientation?: number;
  24177. frontUVs?: Vector4;
  24178. backUVs?: Vector4;
  24179. instance?: Mesh;
  24180. invertUV?: boolean;
  24181. }, scene?: Nullable<Scene>): Mesh;
  24182. /**
  24183. * Creates an custom extruded shape mesh.
  24184. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  24185. * * 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.
  24186. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  24187. * * 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
  24188. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  24189. * * 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
  24190. * * It must returns a float value that will be the scale value applied to the shape on each path point
  24191. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24192. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  24193. * * 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
  24194. * * 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
  24195. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  24196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24198. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24200. * @param name defines the name of the mesh
  24201. * @param options defines the options used to create the mesh
  24202. * @param scene defines the hosting scene
  24203. * @returns the custom extruded shape mesh
  24204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  24205. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  24206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24207. */
  24208. static ExtrudeShapeCustom(name: string, options: {
  24209. shape: Vector3[];
  24210. path: Vector3[];
  24211. scaleFunction?: any;
  24212. rotationFunction?: any;
  24213. ribbonCloseArray?: boolean;
  24214. ribbonClosePath?: boolean;
  24215. cap?: number;
  24216. updatable?: boolean;
  24217. sideOrientation?: number;
  24218. frontUVs?: Vector4;
  24219. backUVs?: Vector4;
  24220. instance?: Mesh;
  24221. invertUV?: boolean;
  24222. }, scene: Scene): Mesh;
  24223. /**
  24224. * Creates lathe mesh.
  24225. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  24226. * * 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
  24227. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  24228. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  24229. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  24230. * * 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
  24231. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  24232. * * 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
  24233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24237. * @param name defines the name of the mesh
  24238. * @param options defines the options used to create the mesh
  24239. * @param scene defines the hosting scene
  24240. * @returns the lathe mesh
  24241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  24242. */
  24243. static CreateLathe(name: string, options: {
  24244. shape: Vector3[];
  24245. radius?: number;
  24246. tessellation?: number;
  24247. clip?: number;
  24248. arc?: number;
  24249. closed?: boolean;
  24250. updatable?: boolean;
  24251. sideOrientation?: number;
  24252. frontUVs?: Vector4;
  24253. backUVs?: Vector4;
  24254. cap?: number;
  24255. invertUV?: boolean;
  24256. }, scene: Scene): Mesh;
  24257. /**
  24258. * Creates a plane mesh
  24259. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  24260. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  24261. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  24262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24265. * @param name defines the name of the mesh
  24266. * @param options defines the options used to create the mesh
  24267. * @param scene defines the hosting scene
  24268. * @returns the plane mesh
  24269. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  24270. */
  24271. static CreatePlane(name: string, options: {
  24272. size?: number;
  24273. width?: number;
  24274. height?: number;
  24275. sideOrientation?: number;
  24276. frontUVs?: Vector4;
  24277. backUVs?: Vector4;
  24278. updatable?: boolean;
  24279. sourcePlane?: Plane;
  24280. }, scene: Scene): Mesh;
  24281. /**
  24282. * Creates a ground mesh
  24283. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  24284. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  24285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24286. * @param name defines the name of the mesh
  24287. * @param options defines the options used to create the mesh
  24288. * @param scene defines the hosting scene
  24289. * @returns the ground mesh
  24290. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  24291. */
  24292. static CreateGround(name: string, options: {
  24293. width?: number;
  24294. height?: number;
  24295. subdivisions?: number;
  24296. subdivisionsX?: number;
  24297. subdivisionsY?: number;
  24298. updatable?: boolean;
  24299. }, scene: any): Mesh;
  24300. /**
  24301. * Creates a tiled ground mesh
  24302. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  24303. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  24304. * * 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
  24305. * * 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
  24306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24307. * @param name defines the name of the mesh
  24308. * @param options defines the options used to create the mesh
  24309. * @param scene defines the hosting scene
  24310. * @returns the tiled ground mesh
  24311. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  24312. */
  24313. static CreateTiledGround(name: string, options: {
  24314. xmin: number;
  24315. zmin: number;
  24316. xmax: number;
  24317. zmax: number;
  24318. subdivisions?: {
  24319. w: number;
  24320. h: number;
  24321. };
  24322. precision?: {
  24323. w: number;
  24324. h: number;
  24325. };
  24326. updatable?: boolean;
  24327. }, scene: Scene): Mesh;
  24328. /**
  24329. * Creates a ground mesh from a height map
  24330. * * The parameter `url` sets the URL of the height map image resource.
  24331. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  24332. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  24333. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  24334. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  24335. * * 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.
  24336. * * 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).
  24337. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24339. * @param name defines the name of the mesh
  24340. * @param url defines the url to the height map
  24341. * @param options defines the options used to create the mesh
  24342. * @param scene defines the hosting scene
  24343. * @returns the ground mesh
  24344. * @see https://doc.babylonjs.com/babylon101/height_map
  24345. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  24346. */
  24347. static CreateGroundFromHeightMap(name: string, url: string, options: {
  24348. width?: number;
  24349. height?: number;
  24350. subdivisions?: number;
  24351. minHeight?: number;
  24352. maxHeight?: number;
  24353. colorFilter?: Color3;
  24354. alphaFilter?: number;
  24355. updatable?: boolean;
  24356. onReady?: (mesh: GroundMesh) => void;
  24357. }, scene: Scene): GroundMesh;
  24358. /**
  24359. * Creates a polygon mesh
  24360. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  24361. * * 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
  24362. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24364. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  24365. * * Remember you can only change the shape positions, not their number when updating a polygon
  24366. * @param name defines the name of the mesh
  24367. * @param options defines the options used to create the mesh
  24368. * @param scene defines the hosting scene
  24369. * @returns the polygon mesh
  24370. */
  24371. static CreatePolygon(name: string, options: {
  24372. shape: Vector3[];
  24373. holes?: Vector3[][];
  24374. depth?: number;
  24375. faceUV?: Vector4[];
  24376. faceColors?: Color4[];
  24377. updatable?: boolean;
  24378. sideOrientation?: number;
  24379. frontUVs?: Vector4;
  24380. backUVs?: Vector4;
  24381. }, scene: Scene): Mesh;
  24382. /**
  24383. * Creates an extruded polygon mesh, with depth in the Y direction.
  24384. * * 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)
  24385. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  24386. * @param name defines the name of the mesh
  24387. * @param options defines the options used to create the mesh
  24388. * @param scene defines the hosting scene
  24389. * @returns the polygon mesh
  24390. */
  24391. static ExtrudePolygon(name: string, options: {
  24392. shape: Vector3[];
  24393. holes?: Vector3[][];
  24394. depth?: number;
  24395. faceUV?: Vector4[];
  24396. faceColors?: Color4[];
  24397. updatable?: boolean;
  24398. sideOrientation?: number;
  24399. frontUVs?: Vector4;
  24400. backUVs?: Vector4;
  24401. }, scene: Scene): Mesh;
  24402. /**
  24403. * Creates a tube mesh.
  24404. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  24405. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  24406. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  24407. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  24408. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  24409. * * 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)
  24410. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  24411. * * 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
  24412. * * 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
  24413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24415. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24417. * @param name defines the name of the mesh
  24418. * @param options defines the options used to create the mesh
  24419. * @param scene defines the hosting scene
  24420. * @returns the tube mesh
  24421. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  24422. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  24423. */
  24424. static CreateTube(name: string, options: {
  24425. path: Vector3[];
  24426. radius?: number;
  24427. tessellation?: number;
  24428. radiusFunction?: {
  24429. (i: number, distance: number): number;
  24430. };
  24431. cap?: number;
  24432. arc?: number;
  24433. updatable?: boolean;
  24434. sideOrientation?: number;
  24435. frontUVs?: Vector4;
  24436. backUVs?: Vector4;
  24437. instance?: Mesh;
  24438. invertUV?: boolean;
  24439. }, scene: Scene): Mesh;
  24440. /**
  24441. * Creates a polyhedron mesh
  24442. * * 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
  24443. * * The parameter `size` (positive float, default 1) sets the polygon size
  24444. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24445. * * 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`
  24446. * * 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
  24447. * * 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)`)
  24448. * * 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
  24449. * * 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
  24450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24453. * @param name defines the name of the mesh
  24454. * @param options defines the options used to create the mesh
  24455. * @param scene defines the hosting scene
  24456. * @returns the polyhedron mesh
  24457. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  24458. */
  24459. static CreatePolyhedron(name: string, options: {
  24460. type?: number;
  24461. size?: number;
  24462. sizeX?: number;
  24463. sizeY?: number;
  24464. sizeZ?: number;
  24465. custom?: any;
  24466. faceUV?: Vector4[];
  24467. faceColors?: Color4[];
  24468. flat?: boolean;
  24469. updatable?: boolean;
  24470. sideOrientation?: number;
  24471. frontUVs?: Vector4;
  24472. backUVs?: Vector4;
  24473. }, scene: Scene): Mesh;
  24474. /**
  24475. * Creates a decal mesh.
  24476. * 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
  24477. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  24478. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  24479. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  24480. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  24481. * @param name defines the name of the mesh
  24482. * @param sourceMesh defines the mesh where the decal must be applied
  24483. * @param options defines the options used to create the mesh
  24484. * @param scene defines the hosting scene
  24485. * @returns the decal mesh
  24486. * @see https://doc.babylonjs.com/how_to/decals
  24487. */
  24488. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  24489. position?: Vector3;
  24490. normal?: Vector3;
  24491. size?: Vector3;
  24492. angle?: number;
  24493. }): Mesh;
  24494. private static _ExtrudeShapeGeneric;
  24495. }
  24496. }
  24497. declare module "babylonjs/Particles/solidParticleSystem" {
  24498. import { Vector3 } from "babylonjs/Maths/math";
  24499. import { Mesh } from "babylonjs/Meshes/mesh";
  24500. import { Scene, IDisposable } from "babylonjs/scene";
  24501. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24502. /**
  24503. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24504. *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.
  24505. * The SPS is also a particle system. It provides some methods to manage the particles.
  24506. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24507. *
  24508. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24509. */
  24510. export class SolidParticleSystem implements IDisposable {
  24511. /**
  24512. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24513. * Example : var p = SPS.particles[i];
  24514. */
  24515. particles: SolidParticle[];
  24516. /**
  24517. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24518. */
  24519. nbParticles: number;
  24520. /**
  24521. * If the particles must ever face the camera (default false). Useful for planar particles.
  24522. */
  24523. billboard: boolean;
  24524. /**
  24525. * Recompute normals when adding a shape
  24526. */
  24527. recomputeNormals: boolean;
  24528. /**
  24529. * This a counter ofr your own usage. It's not set by any SPS functions.
  24530. */
  24531. counter: number;
  24532. /**
  24533. * The SPS name. This name is also given to the underlying mesh.
  24534. */
  24535. name: string;
  24536. /**
  24537. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24538. */
  24539. mesh: Mesh;
  24540. /**
  24541. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24542. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24543. */
  24544. vars: any;
  24545. /**
  24546. * This array is populated when the SPS is set as 'pickable'.
  24547. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24548. * Each element of this array is an object `{idx: int, faceId: int}`.
  24549. * `idx` is the picked particle index in the `SPS.particles` array
  24550. * `faceId` is the picked face index counted within this particle.
  24551. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24552. */
  24553. pickedParticles: {
  24554. idx: number;
  24555. faceId: number;
  24556. }[];
  24557. /**
  24558. * This array is populated when `enableDepthSort` is set to true.
  24559. * Each element of this array is an instance of the class DepthSortedParticle.
  24560. */
  24561. depthSortedParticles: DepthSortedParticle[];
  24562. /**
  24563. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24564. * @hidden
  24565. */
  24566. _bSphereOnly: boolean;
  24567. /**
  24568. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24569. * @hidden
  24570. */
  24571. _bSphereRadiusFactor: number;
  24572. private _scene;
  24573. private _positions;
  24574. private _indices;
  24575. private _normals;
  24576. private _colors;
  24577. private _uvs;
  24578. private _indices32;
  24579. private _positions32;
  24580. private _normals32;
  24581. private _fixedNormal32;
  24582. private _colors32;
  24583. private _uvs32;
  24584. private _index;
  24585. private _updatable;
  24586. private _pickable;
  24587. private _isVisibilityBoxLocked;
  24588. private _alwaysVisible;
  24589. private _depthSort;
  24590. private _shapeCounter;
  24591. private _copy;
  24592. private _color;
  24593. private _computeParticleColor;
  24594. private _computeParticleTexture;
  24595. private _computeParticleRotation;
  24596. private _computeParticleVertex;
  24597. private _computeBoundingBox;
  24598. private _depthSortParticles;
  24599. private _camera;
  24600. private _mustUnrotateFixedNormals;
  24601. private _particlesIntersect;
  24602. private _needs32Bits;
  24603. /**
  24604. * Creates a SPS (Solid Particle System) object.
  24605. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24606. * @param scene (Scene) is the scene in which the SPS is added.
  24607. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24608. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24609. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24610. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24611. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24612. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24613. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24614. */
  24615. constructor(name: string, scene: Scene, options?: {
  24616. updatable?: boolean;
  24617. isPickable?: boolean;
  24618. enableDepthSort?: boolean;
  24619. particleIntersection?: boolean;
  24620. boundingSphereOnly?: boolean;
  24621. bSphereRadiusFactor?: number;
  24622. });
  24623. /**
  24624. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24625. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24626. * @returns the created mesh
  24627. */
  24628. buildMesh(): Mesh;
  24629. /**
  24630. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24631. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24632. * Thus the particles generated from `digest()` have their property `position` set yet.
  24633. * @param mesh ( Mesh ) is the mesh to be digested
  24634. * @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
  24635. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24636. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24637. * @returns the current SPS
  24638. */
  24639. digest(mesh: Mesh, options?: {
  24640. facetNb?: number;
  24641. number?: number;
  24642. delta?: number;
  24643. }): SolidParticleSystem;
  24644. private _unrotateFixedNormals;
  24645. private _resetCopy;
  24646. private _meshBuilder;
  24647. private _posToShape;
  24648. private _uvsToShapeUV;
  24649. private _addParticle;
  24650. /**
  24651. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24652. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24653. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24654. * @param nb (positive integer) the number of particles to be created from this model
  24655. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24656. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24657. * @returns the number of shapes in the system
  24658. */
  24659. addShape(mesh: Mesh, nb: number, options?: {
  24660. positionFunction?: any;
  24661. vertexFunction?: any;
  24662. }): number;
  24663. private _rebuildParticle;
  24664. /**
  24665. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24666. * @returns the SPS.
  24667. */
  24668. rebuildMesh(): SolidParticleSystem;
  24669. /**
  24670. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24671. * This method calls `updateParticle()` for each particle of the SPS.
  24672. * For an animated SPS, it is usually called within the render loop.
  24673. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24674. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24675. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24676. * @returns the SPS.
  24677. */
  24678. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24679. /**
  24680. * Disposes the SPS.
  24681. */
  24682. dispose(): void;
  24683. /**
  24684. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24685. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24686. * @returns the SPS.
  24687. */
  24688. refreshVisibleSize(): SolidParticleSystem;
  24689. /**
  24690. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24691. * @param size the size (float) of the visibility box
  24692. * note : this doesn't lock the SPS mesh bounding box.
  24693. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24694. */
  24695. setVisibilityBox(size: number): void;
  24696. /**
  24697. * Gets whether the SPS as always visible or not
  24698. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24699. */
  24700. /**
  24701. * Sets the SPS as always visible or not
  24702. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24703. */
  24704. isAlwaysVisible: boolean;
  24705. /**
  24706. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24707. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24708. */
  24709. /**
  24710. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24711. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24712. */
  24713. isVisibilityBoxLocked: boolean;
  24714. /**
  24715. * Tells to `setParticles()` to compute the particle rotations or not.
  24716. * Default value : true. The SPS is faster when it's set to false.
  24717. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24718. */
  24719. /**
  24720. * Gets if `setParticles()` computes the particle rotations or not.
  24721. * Default value : true. The SPS is faster when it's set to false.
  24722. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24723. */
  24724. computeParticleRotation: boolean;
  24725. /**
  24726. * Tells to `setParticles()` to compute the particle colors or not.
  24727. * Default value : true. The SPS is faster when it's set to false.
  24728. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24729. */
  24730. /**
  24731. * Gets if `setParticles()` computes the particle colors or not.
  24732. * Default value : true. The SPS is faster when it's set to false.
  24733. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24734. */
  24735. computeParticleColor: boolean;
  24736. /**
  24737. * Gets if `setParticles()` computes the particle textures or not.
  24738. * Default value : true. The SPS is faster when it's set to false.
  24739. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24740. */
  24741. computeParticleTexture: boolean;
  24742. /**
  24743. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24744. * Default value : false. The SPS is faster when it's set to false.
  24745. * Note : the particle custom vertex positions aren't stored values.
  24746. */
  24747. /**
  24748. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24749. * Default value : false. The SPS is faster when it's set to false.
  24750. * Note : the particle custom vertex positions aren't stored values.
  24751. */
  24752. computeParticleVertex: boolean;
  24753. /**
  24754. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24755. */
  24756. /**
  24757. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24758. */
  24759. computeBoundingBox: boolean;
  24760. /**
  24761. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24762. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24763. * Default : `true`
  24764. */
  24765. /**
  24766. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24767. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24768. * Default : `true`
  24769. */
  24770. depthSortParticles: boolean;
  24771. /**
  24772. * This function does nothing. It may be overwritten to set all the particle first values.
  24773. * The SPS doesn't call this function, you may have to call it by your own.
  24774. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24775. */
  24776. initParticles(): void;
  24777. /**
  24778. * This function does nothing. It may be overwritten to recycle a particle.
  24779. * The SPS doesn't call this function, you may have to call it by your own.
  24780. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24781. * @param particle The particle to recycle
  24782. * @returns the recycled particle
  24783. */
  24784. recycleParticle(particle: SolidParticle): SolidParticle;
  24785. /**
  24786. * Updates a particle : this function should be overwritten by the user.
  24787. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24788. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24789. * @example : just set a particle position or velocity and recycle conditions
  24790. * @param particle The particle to update
  24791. * @returns the updated particle
  24792. */
  24793. updateParticle(particle: SolidParticle): SolidParticle;
  24794. /**
  24795. * Updates a vertex of a particle : it can be overwritten by the user.
  24796. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24797. * @param particle the current particle
  24798. * @param vertex the current index of the current particle
  24799. * @param pt the index of the current vertex in the particle shape
  24800. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24801. * @example : just set a vertex particle position
  24802. * @returns the updated vertex
  24803. */
  24804. updateParticleVertex(vertex: Vector3): Vector3;
  24805. /**
  24806. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24807. * This does nothing and may be overwritten by the user.
  24808. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24809. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24810. * @param update the boolean update value actually passed to setParticles()
  24811. */
  24812. beforeUpdateParticles(): void;
  24813. /**
  24814. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24815. * This will be passed three parameters.
  24816. * This does nothing and may be overwritten by the user.
  24817. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24818. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24819. * @param update the boolean update value actually passed to setParticles()
  24820. */
  24821. afterUpdateParticles(): void;
  24822. }
  24823. }
  24824. declare module "babylonjs/Particles/solidParticle" {
  24825. import { Nullable } from "babylonjs/types";
  24826. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24827. import { Mesh } from "babylonjs/Meshes/mesh";
  24828. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24829. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24830. /**
  24831. * Represents one particle of a solid particle system.
  24832. */
  24833. export class SolidParticle {
  24834. /**
  24835. * particle global index
  24836. */
  24837. idx: number;
  24838. /**
  24839. * The color of the particle
  24840. */
  24841. color: Nullable<Color4>;
  24842. /**
  24843. * The world space position of the particle.
  24844. */
  24845. position: Vector3;
  24846. /**
  24847. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24848. */
  24849. rotation: Vector3;
  24850. /**
  24851. * The world space rotation quaternion of the particle.
  24852. */
  24853. rotationQuaternion: Nullable<Quaternion>;
  24854. /**
  24855. * The scaling of the particle.
  24856. */
  24857. scaling: Vector3;
  24858. /**
  24859. * The uvs of the particle.
  24860. */
  24861. uvs: Vector4;
  24862. /**
  24863. * The current speed of the particle.
  24864. */
  24865. velocity: Vector3;
  24866. /**
  24867. * The pivot point in the particle local space.
  24868. */
  24869. pivot: Vector3;
  24870. /**
  24871. * Must the particle be translated from its pivot point in its local space ?
  24872. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24873. * Default : false
  24874. */
  24875. translateFromPivot: boolean;
  24876. /**
  24877. * Is the particle active or not ?
  24878. */
  24879. alive: boolean;
  24880. /**
  24881. * Is the particle visible or not ?
  24882. */
  24883. isVisible: boolean;
  24884. /**
  24885. * Index of this particle in the global "positions" array (Internal use)
  24886. * @hidden
  24887. */
  24888. _pos: number;
  24889. /**
  24890. * @hidden Index of this particle in the global "indices" array (Internal use)
  24891. */
  24892. _ind: number;
  24893. /**
  24894. * @hidden ModelShape of this particle (Internal use)
  24895. */
  24896. _model: ModelShape;
  24897. /**
  24898. * ModelShape id of this particle
  24899. */
  24900. shapeId: number;
  24901. /**
  24902. * Index of the particle in its shape id (Internal use)
  24903. */
  24904. idxInShape: number;
  24905. /**
  24906. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24907. */
  24908. _modelBoundingInfo: BoundingInfo;
  24909. /**
  24910. * @hidden Particle BoundingInfo object (Internal use)
  24911. */
  24912. _boundingInfo: BoundingInfo;
  24913. /**
  24914. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24915. */
  24916. _sps: SolidParticleSystem;
  24917. /**
  24918. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24919. */
  24920. _stillInvisible: boolean;
  24921. /**
  24922. * @hidden Last computed particle rotation matrix
  24923. */
  24924. _rotationMatrix: number[];
  24925. /**
  24926. * Parent particle Id, if any.
  24927. * Default null.
  24928. */
  24929. parentId: Nullable<number>;
  24930. /**
  24931. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24932. * The possible values are :
  24933. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24934. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24935. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24936. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24937. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24938. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24939. * */
  24940. cullingStrategy: number;
  24941. /**
  24942. * @hidden Internal global position in the SPS.
  24943. */
  24944. _globalPosition: Vector3;
  24945. /**
  24946. * Creates a Solid Particle object.
  24947. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24948. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24949. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24950. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24951. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24952. * @param shapeId (integer) is the model shape identifier in the SPS.
  24953. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24954. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24955. */
  24956. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24957. /**
  24958. * Legacy support, changed scale to scaling
  24959. */
  24960. /**
  24961. * Legacy support, changed scale to scaling
  24962. */
  24963. scale: Vector3;
  24964. /**
  24965. * Legacy support, changed quaternion to rotationQuaternion
  24966. */
  24967. /**
  24968. * Legacy support, changed quaternion to rotationQuaternion
  24969. */
  24970. quaternion: Nullable<Quaternion>;
  24971. /**
  24972. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24973. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24974. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24975. * @returns true if it intersects
  24976. */
  24977. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24978. /**
  24979. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24980. * A particle is in the frustum if its bounding box intersects the frustum
  24981. * @param frustumPlanes defines the frustum to test
  24982. * @returns true if the particle is in the frustum planes
  24983. */
  24984. isInFrustum(frustumPlanes: Plane[]): boolean;
  24985. /**
  24986. * get the rotation matrix of the particle
  24987. * @hidden
  24988. */
  24989. getRotationMatrix(m: Matrix): void;
  24990. }
  24991. /**
  24992. * Represents the shape of the model used by one particle of a solid particle system.
  24993. * SPS internal tool, don't use it manually.
  24994. */
  24995. export class ModelShape {
  24996. /**
  24997. * The shape id
  24998. * @hidden
  24999. */
  25000. shapeID: number;
  25001. /**
  25002. * flat array of model positions (internal use)
  25003. * @hidden
  25004. */
  25005. _shape: Vector3[];
  25006. /**
  25007. * flat array of model UVs (internal use)
  25008. * @hidden
  25009. */
  25010. _shapeUV: number[];
  25011. /**
  25012. * length of the shape in the model indices array (internal use)
  25013. * @hidden
  25014. */
  25015. _indicesLength: number;
  25016. /**
  25017. * Custom position function (internal use)
  25018. * @hidden
  25019. */
  25020. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25021. /**
  25022. * Custom vertex function (internal use)
  25023. * @hidden
  25024. */
  25025. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25026. /**
  25027. * 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.
  25028. * SPS internal tool, don't use it manually.
  25029. * @hidden
  25030. */
  25031. 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>);
  25032. }
  25033. /**
  25034. * Represents a Depth Sorted Particle in the solid particle system.
  25035. */
  25036. export class DepthSortedParticle {
  25037. /**
  25038. * Index of the particle in the "indices" array
  25039. */
  25040. ind: number;
  25041. /**
  25042. * Length of the particle shape in the "indices" array
  25043. */
  25044. indicesLength: number;
  25045. /**
  25046. * Squared distance from the particle to the camera
  25047. */
  25048. sqDistance: number;
  25049. }
  25050. }
  25051. declare module "babylonjs/Meshes/abstractMesh" {
  25052. import { Observable } from "babylonjs/Misc/observable";
  25053. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25054. import { Camera } from "babylonjs/Cameras/camera";
  25055. import { Scene, IDisposable } from "babylonjs/scene";
  25056. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25057. import { Node } from "babylonjs/node";
  25058. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25059. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25060. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25061. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25062. import { Collider } from "babylonjs/Collisions/collider";
  25063. import { Ray } from "babylonjs/Culling/ray";
  25064. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25065. import { Material } from "babylonjs/Materials/material";
  25066. import { Light } from "babylonjs/Lights/light";
  25067. import { ActionManager } from "babylonjs/Actions/actionManager";
  25068. import { Skeleton } from "babylonjs/Bones/skeleton";
  25069. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25070. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25071. /**
  25072. * Class used to store all common mesh properties
  25073. */
  25074. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25075. /** No occlusion */
  25076. static OCCLUSION_TYPE_NONE: number;
  25077. /** Occlusion set to optimisitic */
  25078. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25079. /** Occlusion set to strict */
  25080. static OCCLUSION_TYPE_STRICT: number;
  25081. /** Use an accurante occlusion algorithm */
  25082. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25083. /** Use a conservative occlusion algorithm */
  25084. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25085. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25086. * Test order :
  25087. * Is the bounding sphere outside the frustum ?
  25088. * If not, are the bounding box vertices outside the frustum ?
  25089. * It not, then the cullable object is in the frustum.
  25090. */
  25091. static readonly CULLINGSTRATEGY_STANDARD: number;
  25092. /** Culling strategy : Bounding Sphere Only.
  25093. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25094. * It's also less accurate than the standard because some not visible objects can still be selected.
  25095. * Test : is the bounding sphere outside the frustum ?
  25096. * If not, then the cullable object is in the frustum.
  25097. */
  25098. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25099. /** Culling strategy : Optimistic Inclusion.
  25100. * This in an inclusion test first, then the standard exclusion test.
  25101. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25102. * 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.
  25103. * Anyway, it's as accurate as the standard strategy.
  25104. * Test :
  25105. * Is the cullable object bounding sphere center in the frustum ?
  25106. * If not, apply the default culling strategy.
  25107. */
  25108. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25109. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25110. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25111. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25112. * 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.
  25113. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25114. * Test :
  25115. * Is the cullable object bounding sphere center in the frustum ?
  25116. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25117. */
  25118. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25119. /**
  25120. * No billboard
  25121. */
  25122. static readonly BILLBOARDMODE_NONE: number;
  25123. /** Billboard on X axis */
  25124. static readonly BILLBOARDMODE_X: number;
  25125. /** Billboard on Y axis */
  25126. static readonly BILLBOARDMODE_Y: number;
  25127. /** Billboard on Z axis */
  25128. static readonly BILLBOARDMODE_Z: number;
  25129. /** Billboard on all axes */
  25130. static readonly BILLBOARDMODE_ALL: number;
  25131. private _facetData;
  25132. /**
  25133. * The culling strategy to use to check whether the mesh must be rendered or not.
  25134. * This value can be changed at any time and will be used on the next render mesh selection.
  25135. * The possible values are :
  25136. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25137. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25138. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25139. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25140. * Please read each static variable documentation to get details about the culling process.
  25141. * */
  25142. cullingStrategy: number;
  25143. /**
  25144. * Gets the number of facets in the mesh
  25145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25146. */
  25147. readonly facetNb: number;
  25148. /**
  25149. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25150. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25151. */
  25152. partitioningSubdivisions: number;
  25153. /**
  25154. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25155. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25156. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25157. */
  25158. partitioningBBoxRatio: number;
  25159. /**
  25160. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25161. * Works only for updatable meshes.
  25162. * Doesn't work with multi-materials
  25163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25164. */
  25165. mustDepthSortFacets: boolean;
  25166. /**
  25167. * The location (Vector3) where the facet depth sort must be computed from.
  25168. * By default, the active camera position.
  25169. * Used only when facet depth sort is enabled
  25170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25171. */
  25172. facetDepthSortFrom: Vector3;
  25173. /**
  25174. * gets a boolean indicating if facetData is enabled
  25175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25176. */
  25177. readonly isFacetDataEnabled: boolean;
  25178. /** @hidden */
  25179. _updateNonUniformScalingState(value: boolean): boolean;
  25180. /**
  25181. * An event triggered when this mesh collides with another one
  25182. */
  25183. onCollideObservable: Observable<AbstractMesh>;
  25184. private _onCollideObserver;
  25185. /** Set a function to call when this mesh collides with another one */
  25186. onCollide: () => void;
  25187. /**
  25188. * An event triggered when the collision's position changes
  25189. */
  25190. onCollisionPositionChangeObservable: Observable<Vector3>;
  25191. private _onCollisionPositionChangeObserver;
  25192. /** Set a function to call when the collision's position changes */
  25193. onCollisionPositionChange: () => void;
  25194. /**
  25195. * An event triggered when material is changed
  25196. */
  25197. onMaterialChangedObservable: Observable<AbstractMesh>;
  25198. /**
  25199. * Gets or sets the orientation for POV movement & rotation
  25200. */
  25201. definedFacingForward: boolean;
  25202. /** @hidden */
  25203. _occlusionQuery: Nullable<WebGLQuery>;
  25204. private _visibility;
  25205. /**
  25206. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25207. */
  25208. /**
  25209. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25210. */
  25211. visibility: number;
  25212. /** Gets or sets the alpha index used to sort transparent meshes
  25213. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25214. */
  25215. alphaIndex: number;
  25216. /**
  25217. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25218. */
  25219. isVisible: boolean;
  25220. /**
  25221. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25222. */
  25223. isPickable: boolean;
  25224. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25225. showSubMeshesBoundingBox: boolean;
  25226. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25227. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25228. */
  25229. isBlocker: boolean;
  25230. /**
  25231. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25232. */
  25233. enablePointerMoveEvents: boolean;
  25234. /**
  25235. * Specifies the rendering group id for this mesh (0 by default)
  25236. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25237. */
  25238. renderingGroupId: number;
  25239. private _material;
  25240. /** Gets or sets current material */
  25241. material: Nullable<Material>;
  25242. private _receiveShadows;
  25243. /**
  25244. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25245. * @see http://doc.babylonjs.com/babylon101/shadows
  25246. */
  25247. receiveShadows: boolean;
  25248. /** Defines color to use when rendering outline */
  25249. outlineColor: Color3;
  25250. /** Define width to use when rendering outline */
  25251. outlineWidth: number;
  25252. /** Defines color to use when rendering overlay */
  25253. overlayColor: Color3;
  25254. /** Defines alpha to use when rendering overlay */
  25255. overlayAlpha: number;
  25256. private _hasVertexAlpha;
  25257. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25258. hasVertexAlpha: boolean;
  25259. private _useVertexColors;
  25260. /** 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) */
  25261. useVertexColors: boolean;
  25262. private _computeBonesUsingShaders;
  25263. /**
  25264. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25265. */
  25266. computeBonesUsingShaders: boolean;
  25267. private _numBoneInfluencers;
  25268. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25269. numBoneInfluencers: number;
  25270. private _applyFog;
  25271. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25272. applyFog: boolean;
  25273. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25274. useOctreeForRenderingSelection: boolean;
  25275. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25276. useOctreeForPicking: boolean;
  25277. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25278. useOctreeForCollisions: boolean;
  25279. private _layerMask;
  25280. /**
  25281. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25282. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25283. */
  25284. layerMask: number;
  25285. /**
  25286. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25287. */
  25288. alwaysSelectAsActiveMesh: boolean;
  25289. /**
  25290. * Gets or sets the current action manager
  25291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25292. */
  25293. actionManager: Nullable<ActionManager>;
  25294. private _checkCollisions;
  25295. private _collisionMask;
  25296. private _collisionGroup;
  25297. /**
  25298. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25299. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25300. */
  25301. ellipsoid: Vector3;
  25302. /**
  25303. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25304. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25305. */
  25306. ellipsoidOffset: Vector3;
  25307. private _collider;
  25308. private _oldPositionForCollisions;
  25309. private _diffPositionForCollisions;
  25310. /**
  25311. * Gets or sets a collision mask used to mask collisions (default is -1).
  25312. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25313. */
  25314. collisionMask: number;
  25315. /**
  25316. * Gets or sets the current collision group mask (-1 by default).
  25317. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25318. */
  25319. collisionGroup: number;
  25320. /**
  25321. * Defines edge width used when edgesRenderer is enabled
  25322. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25323. */
  25324. edgesWidth: number;
  25325. /**
  25326. * Defines edge color used when edgesRenderer is enabled
  25327. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25328. */
  25329. edgesColor: Color4;
  25330. /** @hidden */
  25331. _edgesRenderer: Nullable<IEdgesRenderer>;
  25332. /** @hidden */
  25333. _masterMesh: Nullable<AbstractMesh>;
  25334. /** @hidden */
  25335. _boundingInfo: Nullable<BoundingInfo>;
  25336. /** @hidden */
  25337. _renderId: number;
  25338. /**
  25339. * Gets or sets the list of subMeshes
  25340. * @see http://doc.babylonjs.com/how_to/multi_materials
  25341. */
  25342. subMeshes: SubMesh[];
  25343. /** @hidden */
  25344. _intersectionsInProgress: AbstractMesh[];
  25345. /** @hidden */
  25346. _unIndexed: boolean;
  25347. /** @hidden */
  25348. _lightSources: Light[];
  25349. /** @hidden */
  25350. readonly _positions: Nullable<Vector3[]>;
  25351. /** @hidden */
  25352. _waitingActions: any;
  25353. /** @hidden */
  25354. _waitingFreezeWorldMatrix: Nullable<boolean>;
  25355. private _skeleton;
  25356. /** @hidden */
  25357. _bonesTransformMatrices: Nullable<Float32Array>;
  25358. /**
  25359. * Gets or sets a skeleton to apply skining transformations
  25360. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25361. */
  25362. skeleton: Nullable<Skeleton>;
  25363. /**
  25364. * An event triggered when the mesh is rebuilt.
  25365. */
  25366. onRebuildObservable: Observable<AbstractMesh>;
  25367. /**
  25368. * Creates a new AbstractMesh
  25369. * @param name defines the name of the mesh
  25370. * @param scene defines the hosting scene
  25371. */
  25372. constructor(name: string, scene?: Nullable<Scene>);
  25373. /**
  25374. * Returns the string "AbstractMesh"
  25375. * @returns "AbstractMesh"
  25376. */
  25377. getClassName(): string;
  25378. /**
  25379. * Gets a string representation of the current mesh
  25380. * @param fullDetails defines a boolean indicating if full details must be included
  25381. * @returns a string representation of the current mesh
  25382. */
  25383. toString(fullDetails?: boolean): string;
  25384. /** @hidden */
  25385. _rebuild(): void;
  25386. /** @hidden */
  25387. _resyncLightSources(): void;
  25388. /** @hidden */
  25389. _resyncLighSource(light: Light): void;
  25390. /** @hidden */
  25391. _unBindEffect(): void;
  25392. /** @hidden */
  25393. _removeLightSource(light: Light): void;
  25394. private _markSubMeshesAsDirty;
  25395. /** @hidden */
  25396. _markSubMeshesAsLightDirty(): void;
  25397. /** @hidden */
  25398. _markSubMeshesAsAttributesDirty(): void;
  25399. /** @hidden */
  25400. _markSubMeshesAsMiscDirty(): void;
  25401. /**
  25402. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25403. */
  25404. scaling: Vector3;
  25405. /**
  25406. * Returns true if the mesh is blocked. Implemented by child classes
  25407. */
  25408. readonly isBlocked: boolean;
  25409. /**
  25410. * Returns the mesh itself by default. Implemented by child classes
  25411. * @param camera defines the camera to use to pick the right LOD level
  25412. * @returns the currentAbstractMesh
  25413. */
  25414. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25415. /**
  25416. * Returns 0 by default. Implemented by child classes
  25417. * @returns an integer
  25418. */
  25419. getTotalVertices(): number;
  25420. /**
  25421. * Returns a positive integer : the total number of indices in this mesh geometry.
  25422. * @returns the numner of indices or zero if the mesh has no geometry.
  25423. */
  25424. getTotalIndices(): number;
  25425. /**
  25426. * Returns null by default. Implemented by child classes
  25427. * @returns null
  25428. */
  25429. getIndices(): Nullable<IndicesArray>;
  25430. /**
  25431. * Returns the array of the requested vertex data kind. Implemented by child classes
  25432. * @param kind defines the vertex data kind to use
  25433. * @returns null
  25434. */
  25435. getVerticesData(kind: string): Nullable<FloatArray>;
  25436. /**
  25437. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25438. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25439. * Note that a new underlying VertexBuffer object is created each call.
  25440. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25441. * @param kind defines vertex data kind:
  25442. * * VertexBuffer.PositionKind
  25443. * * VertexBuffer.UVKind
  25444. * * VertexBuffer.UV2Kind
  25445. * * VertexBuffer.UV3Kind
  25446. * * VertexBuffer.UV4Kind
  25447. * * VertexBuffer.UV5Kind
  25448. * * VertexBuffer.UV6Kind
  25449. * * VertexBuffer.ColorKind
  25450. * * VertexBuffer.MatricesIndicesKind
  25451. * * VertexBuffer.MatricesIndicesExtraKind
  25452. * * VertexBuffer.MatricesWeightsKind
  25453. * * VertexBuffer.MatricesWeightsExtraKind
  25454. * @param data defines the data source
  25455. * @param updatable defines if the data must be flagged as updatable (or static)
  25456. * @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
  25457. * @returns the current mesh
  25458. */
  25459. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25460. /**
  25461. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25462. * If the mesh has no geometry, it is simply returned as it is.
  25463. * @param kind defines vertex data kind:
  25464. * * VertexBuffer.PositionKind
  25465. * * VertexBuffer.UVKind
  25466. * * VertexBuffer.UV2Kind
  25467. * * VertexBuffer.UV3Kind
  25468. * * VertexBuffer.UV4Kind
  25469. * * VertexBuffer.UV5Kind
  25470. * * VertexBuffer.UV6Kind
  25471. * * VertexBuffer.ColorKind
  25472. * * VertexBuffer.MatricesIndicesKind
  25473. * * VertexBuffer.MatricesIndicesExtraKind
  25474. * * VertexBuffer.MatricesWeightsKind
  25475. * * VertexBuffer.MatricesWeightsExtraKind
  25476. * @param data defines the data source
  25477. * @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
  25478. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25479. * @returns the current mesh
  25480. */
  25481. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25482. /**
  25483. * Sets the mesh indices,
  25484. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25485. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25486. * @param totalVertices Defines the total number of vertices
  25487. * @returns the current mesh
  25488. */
  25489. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25490. /**
  25491. * Gets a boolean indicating if specific vertex data is present
  25492. * @param kind defines the vertex data kind to use
  25493. * @returns true is data kind is present
  25494. */
  25495. isVerticesDataPresent(kind: string): boolean;
  25496. /**
  25497. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25498. * @returns a BoundingInfo
  25499. */
  25500. getBoundingInfo(): BoundingInfo;
  25501. /**
  25502. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25503. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  25504. * @returns the current mesh
  25505. */
  25506. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  25507. /**
  25508. * Overwrite the current bounding info
  25509. * @param boundingInfo defines the new bounding info
  25510. * @returns the current mesh
  25511. */
  25512. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25513. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25514. readonly useBones: boolean;
  25515. /** @hidden */
  25516. _preActivate(): void;
  25517. /** @hidden */
  25518. _preActivateForIntermediateRendering(renderId: number): void;
  25519. /** @hidden */
  25520. _activate(renderId: number): void;
  25521. /**
  25522. * Gets the current world matrix
  25523. * @returns a Matrix
  25524. */
  25525. getWorldMatrix(): Matrix;
  25526. /** @hidden */
  25527. _getWorldMatrixDeterminant(): number;
  25528. /**
  25529. * Perform relative position change from the point of view of behind the front of the mesh.
  25530. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25531. * Supports definition of mesh facing forward or backward
  25532. * @param amountRight defines the distance on the right axis
  25533. * @param amountUp defines the distance on the up axis
  25534. * @param amountForward defines the distance on the forward axis
  25535. * @returns the current mesh
  25536. */
  25537. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25538. /**
  25539. * Calculate relative position change from the point of view of behind the front of the mesh.
  25540. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25541. * Supports definition of mesh facing forward or backward
  25542. * @param amountRight defines the distance on the right axis
  25543. * @param amountUp defines the distance on the up axis
  25544. * @param amountForward defines the distance on the forward axis
  25545. * @returns the new displacement vector
  25546. */
  25547. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25548. /**
  25549. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25550. * Supports definition of mesh facing forward or backward
  25551. * @param flipBack defines the flip
  25552. * @param twirlClockwise defines the twirl
  25553. * @param tiltRight defines the tilt
  25554. * @returns the current mesh
  25555. */
  25556. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25557. /**
  25558. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25559. * Supports definition of mesh facing forward or backward.
  25560. * @param flipBack defines the flip
  25561. * @param twirlClockwise defines the twirl
  25562. * @param tiltRight defines the tilt
  25563. * @returns the new rotation vector
  25564. */
  25565. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25566. /**
  25567. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  25568. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25569. * @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
  25570. * @returns the new bounding vectors
  25571. */
  25572. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25573. min: Vector3;
  25574. max: Vector3;
  25575. };
  25576. /**
  25577. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25578. * This means the mesh underlying bounding box and sphere are recomputed.
  25579. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25580. * @returns the current mesh
  25581. */
  25582. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25583. /** @hidden */
  25584. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25585. /** @hidden */
  25586. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25587. /** @hidden */
  25588. _updateBoundingInfo(): AbstractMesh;
  25589. /** @hidden */
  25590. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25591. /** @hidden */
  25592. protected _afterComputeWorldMatrix(): void;
  25593. /**
  25594. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25595. * A mesh is in the frustum if its bounding box intersects the frustum
  25596. * @param frustumPlanes defines the frustum to test
  25597. * @returns true if the mesh is in the frustum planes
  25598. */
  25599. isInFrustum(frustumPlanes: Plane[]): boolean;
  25600. /**
  25601. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25602. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25603. * @param frustumPlanes defines the frustum to test
  25604. * @returns true if the mesh is completely in the frustum planes
  25605. */
  25606. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25607. /**
  25608. * True if the mesh intersects another mesh or a SolidParticle object
  25609. * @param mesh defines a target mesh or SolidParticle to test
  25610. * @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)
  25611. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25612. * @returns true if there is an intersection
  25613. */
  25614. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25615. /**
  25616. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25617. * @param point defines the point to test
  25618. * @returns true if there is an intersection
  25619. */
  25620. intersectsPoint(point: Vector3): boolean;
  25621. /**
  25622. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25623. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25624. */
  25625. checkCollisions: boolean;
  25626. /**
  25627. * Gets Collider object used to compute collisions (not physics)
  25628. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25629. */
  25630. readonly collider: Collider;
  25631. /**
  25632. * Move the mesh using collision engine
  25633. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25634. * @param displacement defines the requested displacement vector
  25635. * @returns the current mesh
  25636. */
  25637. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25638. private _onCollisionPositionChange;
  25639. /** @hidden */
  25640. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25641. /** @hidden */
  25642. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25643. /** @hidden */
  25644. _checkCollision(collider: Collider): AbstractMesh;
  25645. /** @hidden */
  25646. _generatePointsArray(): boolean;
  25647. /**
  25648. * Checks if the passed Ray intersects with the mesh
  25649. * @param ray defines the ray to use
  25650. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25651. * @returns the picking info
  25652. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25653. */
  25654. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  25655. /**
  25656. * Clones the current mesh
  25657. * @param name defines the mesh name
  25658. * @param newParent defines the new mesh parent
  25659. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25660. * @returns the new mesh
  25661. */
  25662. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25663. /**
  25664. * Disposes all the submeshes of the current meshnp
  25665. * @returns the current mesh
  25666. */
  25667. releaseSubMeshes(): AbstractMesh;
  25668. /**
  25669. * Releases resources associated with this abstract mesh.
  25670. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25671. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25672. */
  25673. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25674. /**
  25675. * Adds the passed mesh as a child to the current mesh
  25676. * @param mesh defines the child mesh
  25677. * @returns the current mesh
  25678. */
  25679. addChild(mesh: AbstractMesh): AbstractMesh;
  25680. /**
  25681. * Removes the passed mesh from the current mesh children list
  25682. * @param mesh defines the child mesh
  25683. * @returns the current mesh
  25684. */
  25685. removeChild(mesh: AbstractMesh): AbstractMesh;
  25686. /** @hidden */
  25687. private _initFacetData;
  25688. /**
  25689. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25690. * This method can be called within the render loop.
  25691. * 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
  25692. * @returns the current mesh
  25693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25694. */
  25695. updateFacetData(): AbstractMesh;
  25696. /**
  25697. * Returns the facetLocalNormals array.
  25698. * The normals are expressed in the mesh local spac
  25699. * @returns an array of Vector3
  25700. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25701. */
  25702. getFacetLocalNormals(): Vector3[];
  25703. /**
  25704. * Returns the facetLocalPositions array.
  25705. * The facet positions are expressed in the mesh local space
  25706. * @returns an array of Vector3
  25707. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25708. */
  25709. getFacetLocalPositions(): Vector3[];
  25710. /**
  25711. * Returns the facetLocalPartioning array
  25712. * @returns an array of array of numbers
  25713. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25714. */
  25715. getFacetLocalPartitioning(): number[][];
  25716. /**
  25717. * Returns the i-th facet position in the world system.
  25718. * This method allocates a new Vector3 per call
  25719. * @param i defines the facet index
  25720. * @returns a new Vector3
  25721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25722. */
  25723. getFacetPosition(i: number): Vector3;
  25724. /**
  25725. * Sets the reference Vector3 with the i-th facet position in the world system
  25726. * @param i defines the facet index
  25727. * @param ref defines the target vector
  25728. * @returns the current mesh
  25729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25730. */
  25731. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25732. /**
  25733. * Returns the i-th facet normal in the world system.
  25734. * This method allocates a new Vector3 per call
  25735. * @param i defines the facet index
  25736. * @returns a new Vector3
  25737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25738. */
  25739. getFacetNormal(i: number): Vector3;
  25740. /**
  25741. * Sets the reference Vector3 with the i-th facet normal in the world system
  25742. * @param i defines the facet index
  25743. * @param ref defines the target vector
  25744. * @returns the current mesh
  25745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25746. */
  25747. getFacetNormalToRef(i: number, ref: Vector3): this;
  25748. /**
  25749. * 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)
  25750. * @param x defines x coordinate
  25751. * @param y defines y coordinate
  25752. * @param z defines z coordinate
  25753. * @returns the array of facet indexes
  25754. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25755. */
  25756. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25757. /**
  25758. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25759. * @param projected sets as the (x,y,z) world projection on the facet
  25760. * @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
  25761. * @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
  25762. * @param x defines x coordinate
  25763. * @param y defines y coordinate
  25764. * @param z defines z coordinate
  25765. * @returns the face index if found (or null instead)
  25766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25767. */
  25768. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25769. /**
  25770. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25771. * @param projected sets as the (x,y,z) local projection on the facet
  25772. * @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
  25773. * @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
  25774. * @param x defines x coordinate
  25775. * @param y defines y coordinate
  25776. * @param z defines z coordinate
  25777. * @returns the face index if found (or null instead)
  25778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25779. */
  25780. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25781. /**
  25782. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25783. * @returns the parameters
  25784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25785. */
  25786. getFacetDataParameters(): any;
  25787. /**
  25788. * Disables the feature FacetData and frees the related memory
  25789. * @returns the current mesh
  25790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25791. */
  25792. disableFacetData(): AbstractMesh;
  25793. /**
  25794. * Updates the AbstractMesh indices array
  25795. * @param indices defines the data source
  25796. * @returns the current mesh
  25797. */
  25798. updateIndices(indices: IndicesArray): AbstractMesh;
  25799. /**
  25800. * Creates new normals data for the mesh
  25801. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25802. * @returns the current mesh
  25803. */
  25804. createNormals(updatable: boolean): AbstractMesh;
  25805. /**
  25806. * Align the mesh with a normal
  25807. * @param normal defines the normal to use
  25808. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25809. * @returns the current mesh
  25810. */
  25811. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25812. /** @hidden */
  25813. _checkOcclusionQuery(): boolean;
  25814. }
  25815. }
  25816. declare module "babylonjs/node" {
  25817. import { Scene } from "babylonjs/scene";
  25818. import { Nullable } from "babylonjs/types";
  25819. import { Matrix } from "babylonjs/Maths/math";
  25820. import { Engine } from "babylonjs/Engines/engine";
  25821. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25822. import { Observable } from "babylonjs/Misc/observable";
  25823. import { Animatable } from "babylonjs/Animations/animatable";
  25824. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25825. import { Animation } from "babylonjs/Animations/animation";
  25826. import { AnimationRange } from "babylonjs/Animations/animation";
  25827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25828. /**
  25829. * Defines how a node can be built from a string name.
  25830. */
  25831. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25832. /**
  25833. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25834. */
  25835. export class Node implements IBehaviorAware<Node> {
  25836. /** @hidden */
  25837. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animation").AnimationRange;
  25838. private static _NodeConstructors;
  25839. /**
  25840. * Add a new node constructor
  25841. * @param type defines the type name of the node to construct
  25842. * @param constructorFunc defines the constructor function
  25843. */
  25844. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25845. /**
  25846. * Returns a node constructor based on type name
  25847. * @param type defines the type name
  25848. * @param name defines the new node name
  25849. * @param scene defines the hosting scene
  25850. * @param options defines optional options to transmit to constructors
  25851. * @returns the new constructor or null
  25852. */
  25853. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25854. /**
  25855. * Gets or sets the name of the node
  25856. */
  25857. name: string;
  25858. /**
  25859. * Gets or sets the id of the node
  25860. */
  25861. id: string;
  25862. /**
  25863. * Gets or sets the unique id of the node
  25864. */
  25865. uniqueId: number;
  25866. /**
  25867. * Gets or sets a string used to store user defined state for the node
  25868. */
  25869. state: string;
  25870. /**
  25871. * Gets or sets an object used to store user defined information for the node
  25872. */
  25873. metadata: any;
  25874. /**
  25875. * For internal use only. Please do not use.
  25876. */
  25877. reservedDataStore: any;
  25878. /**
  25879. * Gets or sets a boolean used to define if the node must be serialized
  25880. */
  25881. doNotSerialize: boolean;
  25882. /** @hidden */
  25883. _isDisposed: boolean;
  25884. /**
  25885. * Gets a list of Animations associated with the node
  25886. */
  25887. animations: import("babylonjs/Animations/animation").Animation[];
  25888. protected _ranges: {
  25889. [name: string]: Nullable<AnimationRange>;
  25890. };
  25891. /**
  25892. * Callback raised when the node is ready to be used
  25893. */
  25894. onReady: (node: Node) => void;
  25895. private _isEnabled;
  25896. private _isParentEnabled;
  25897. private _isReady;
  25898. /** @hidden */
  25899. _currentRenderId: number;
  25900. private _parentRenderId;
  25901. protected _childRenderId: number;
  25902. /** @hidden */
  25903. _waitingParentId: Nullable<string>;
  25904. /** @hidden */
  25905. _scene: Scene;
  25906. /** @hidden */
  25907. _cache: any;
  25908. private _parentNode;
  25909. private _children;
  25910. /** @hidden */
  25911. _worldMatrix: Matrix;
  25912. /** @hidden */
  25913. _worldMatrixDeterminant: number;
  25914. /** @hidden */
  25915. private _sceneRootNodesIndex;
  25916. /**
  25917. * Gets a boolean indicating if the node has been disposed
  25918. * @returns true if the node was disposed
  25919. */
  25920. isDisposed(): boolean;
  25921. /**
  25922. * Gets or sets the parent of the node
  25923. */
  25924. parent: Nullable<Node>;
  25925. private addToSceneRootNodes;
  25926. private removeFromSceneRootNodes;
  25927. private _animationPropertiesOverride;
  25928. /**
  25929. * Gets or sets the animation properties override
  25930. */
  25931. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25932. /**
  25933. * Gets a string idenfifying the name of the class
  25934. * @returns "Node" string
  25935. */
  25936. getClassName(): string;
  25937. /** @hidden */
  25938. readonly _isNode: boolean;
  25939. /**
  25940. * An event triggered when the mesh is disposed
  25941. */
  25942. onDisposeObservable: Observable<Node>;
  25943. private _onDisposeObserver;
  25944. /**
  25945. * Sets a callback that will be raised when the node will be disposed
  25946. */
  25947. onDispose: () => void;
  25948. /**
  25949. * Creates a new Node
  25950. * @param name the name and id to be given to this node
  25951. * @param scene the scene this node will be added to
  25952. * @param addToRootNodes the node will be added to scene.rootNodes
  25953. */
  25954. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25955. /**
  25956. * Gets the scene of the node
  25957. * @returns a scene
  25958. */
  25959. getScene(): Scene;
  25960. /**
  25961. * Gets the engine of the node
  25962. * @returns a Engine
  25963. */
  25964. getEngine(): Engine;
  25965. private _behaviors;
  25966. /**
  25967. * Attach a behavior to the node
  25968. * @see http://doc.babylonjs.com/features/behaviour
  25969. * @param behavior defines the behavior to attach
  25970. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25971. * @returns the current Node
  25972. */
  25973. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25974. /**
  25975. * Remove an attached behavior
  25976. * @see http://doc.babylonjs.com/features/behaviour
  25977. * @param behavior defines the behavior to attach
  25978. * @returns the current Node
  25979. */
  25980. removeBehavior(behavior: Behavior<Node>): Node;
  25981. /**
  25982. * Gets the list of attached behaviors
  25983. * @see http://doc.babylonjs.com/features/behaviour
  25984. */
  25985. readonly behaviors: Behavior<Node>[];
  25986. /**
  25987. * Gets an attached behavior by name
  25988. * @param name defines the name of the behavior to look for
  25989. * @see http://doc.babylonjs.com/features/behaviour
  25990. * @returns null if behavior was not found else the requested behavior
  25991. */
  25992. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25993. /**
  25994. * Returns the latest update of the World matrix
  25995. * @returns a Matrix
  25996. */
  25997. getWorldMatrix(): Matrix;
  25998. /** @hidden */
  25999. _getWorldMatrixDeterminant(): number;
  26000. /**
  26001. * Returns directly the latest state of the mesh World matrix.
  26002. * A Matrix is returned.
  26003. */
  26004. readonly worldMatrixFromCache: Matrix;
  26005. /** @hidden */
  26006. _initCache(): void;
  26007. /** @hidden */
  26008. updateCache(force?: boolean): void;
  26009. /** @hidden */
  26010. _updateCache(ignoreParentClass?: boolean): void;
  26011. /** @hidden */
  26012. _isSynchronized(): boolean;
  26013. /** @hidden */
  26014. _markSyncedWithParent(): void;
  26015. /** @hidden */
  26016. isSynchronizedWithParent(): boolean;
  26017. /** @hidden */
  26018. isSynchronized(): boolean;
  26019. /**
  26020. * Is this node ready to be used/rendered
  26021. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26022. * @return true if the node is ready
  26023. */
  26024. isReady(completeCheck?: boolean): boolean;
  26025. /**
  26026. * Is this node enabled?
  26027. * 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
  26028. * @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
  26029. * @return whether this node (and its parent) is enabled
  26030. */
  26031. isEnabled(checkAncestors?: boolean): boolean;
  26032. /** @hidden */
  26033. protected _syncParentEnabledState(): void;
  26034. /**
  26035. * Set the enabled state of this node
  26036. * @param value defines the new enabled state
  26037. */
  26038. setEnabled(value: boolean): void;
  26039. /**
  26040. * Is this node a descendant of the given node?
  26041. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26042. * @param ancestor defines the parent node to inspect
  26043. * @returns a boolean indicating if this node is a descendant of the given node
  26044. */
  26045. isDescendantOf(ancestor: Node): boolean;
  26046. /** @hidden */
  26047. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26048. /**
  26049. * Will return all nodes that have this node as ascendant
  26050. * @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
  26051. * @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
  26052. * @return all children nodes of all types
  26053. */
  26054. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26055. /**
  26056. * Get all child-meshes of this node
  26057. * @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
  26058. * @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
  26059. * @returns an array of AbstractMesh
  26060. */
  26061. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26062. /**
  26063. * Get all direct children of this node
  26064. * @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
  26065. * @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)
  26066. * @returns an array of Node
  26067. */
  26068. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26069. /** @hidden */
  26070. _setReady(state: boolean): void;
  26071. /**
  26072. * Get an animation by name
  26073. * @param name defines the name of the animation to look for
  26074. * @returns null if not found else the requested animation
  26075. */
  26076. getAnimationByName(name: string): Nullable<Animation>;
  26077. /**
  26078. * Creates an animation range for this node
  26079. * @param name defines the name of the range
  26080. * @param from defines the starting key
  26081. * @param to defines the end key
  26082. */
  26083. createAnimationRange(name: string, from: number, to: number): void;
  26084. /**
  26085. * Delete a specific animation range
  26086. * @param name defines the name of the range to delete
  26087. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26088. */
  26089. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26090. /**
  26091. * Get an animation range by name
  26092. * @param name defines the name of the animation range to look for
  26093. * @returns null if not found else the requested animation range
  26094. */
  26095. getAnimationRange(name: string): Nullable<AnimationRange>;
  26096. /**
  26097. * Will start the animation sequence
  26098. * @param name defines the range frames for animation sequence
  26099. * @param loop defines if the animation should loop (false by default)
  26100. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26101. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26102. * @returns the object created for this animation. If range does not exist, it will return null
  26103. */
  26104. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26105. /**
  26106. * Serialize animation ranges into a JSON compatible object
  26107. * @returns serialization object
  26108. */
  26109. serializeAnimationRanges(): any;
  26110. /**
  26111. * Computes the world matrix of the node
  26112. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26113. * @returns the world matrix
  26114. */
  26115. computeWorldMatrix(force?: boolean): Matrix;
  26116. /**
  26117. * Releases resources associated with this node.
  26118. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26119. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26120. */
  26121. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26122. /**
  26123. * Parse animation range data from a serialization object and store them into a given node
  26124. * @param node defines where to store the animation ranges
  26125. * @param parsedNode defines the serialization object to read data from
  26126. * @param scene defines the hosting scene
  26127. */
  26128. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26129. }
  26130. }
  26131. declare module "babylonjs/Animations/animation" {
  26132. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26133. import { Path2, Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26134. import { Nullable } from "babylonjs/types";
  26135. import { Scene } from "babylonjs/scene";
  26136. import { IAnimatable } from "babylonjs/Misc/tools";
  26137. import { Node } from "babylonjs/node";
  26138. import { Animatable } from "babylonjs/Animations/animatable";
  26139. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26140. /**
  26141. * Represents the range of an animation
  26142. */
  26143. export class AnimationRange {
  26144. /**The name of the animation range**/
  26145. name: string;
  26146. /**The starting frame of the animation */
  26147. from: number;
  26148. /**The ending frame of the animation*/
  26149. to: number;
  26150. /**
  26151. * Initializes the range of an animation
  26152. * @param name The name of the animation range
  26153. * @param from The starting frame of the animation
  26154. * @param to The ending frame of the animation
  26155. */
  26156. constructor(
  26157. /**The name of the animation range**/
  26158. name: string,
  26159. /**The starting frame of the animation */
  26160. from: number,
  26161. /**The ending frame of the animation*/
  26162. to: number);
  26163. /**
  26164. * Makes a copy of the animation range
  26165. * @returns A copy of the animation range
  26166. */
  26167. clone(): AnimationRange;
  26168. }
  26169. /**
  26170. * Composed of a frame, and an action function
  26171. */
  26172. export class AnimationEvent {
  26173. /** The frame for which the event is triggered **/
  26174. frame: number;
  26175. /** The event to perform when triggered **/
  26176. action: (currentFrame: number) => void;
  26177. /** Specifies if the event should be triggered only once**/
  26178. onlyOnce?: boolean | undefined;
  26179. /**
  26180. * Specifies if the animation event is done
  26181. */
  26182. isDone: boolean;
  26183. /**
  26184. * Initializes the animation event
  26185. * @param frame The frame for which the event is triggered
  26186. * @param action The event to perform when triggered
  26187. * @param onlyOnce Specifies if the event should be triggered only once
  26188. */
  26189. constructor(
  26190. /** The frame for which the event is triggered **/
  26191. frame: number,
  26192. /** The event to perform when triggered **/
  26193. action: (currentFrame: number) => void,
  26194. /** Specifies if the event should be triggered only once**/
  26195. onlyOnce?: boolean | undefined);
  26196. /** @hidden */
  26197. _clone(): AnimationEvent;
  26198. }
  26199. /**
  26200. * A cursor which tracks a point on a path
  26201. */
  26202. export class PathCursor {
  26203. private path;
  26204. /**
  26205. * Stores path cursor callbacks for when an onchange event is triggered
  26206. */
  26207. private _onchange;
  26208. /**
  26209. * The value of the path cursor
  26210. */
  26211. value: number;
  26212. /**
  26213. * The animation array of the path cursor
  26214. */
  26215. animations: Animation[];
  26216. /**
  26217. * Initializes the path cursor
  26218. * @param path The path to track
  26219. */
  26220. constructor(path: Path2);
  26221. /**
  26222. * Gets the cursor point on the path
  26223. * @returns A point on the path cursor at the cursor location
  26224. */
  26225. getPoint(): Vector3;
  26226. /**
  26227. * Moves the cursor ahead by the step amount
  26228. * @param step The amount to move the cursor forward
  26229. * @returns This path cursor
  26230. */
  26231. moveAhead(step?: number): PathCursor;
  26232. /**
  26233. * Moves the cursor behind by the step amount
  26234. * @param step The amount to move the cursor back
  26235. * @returns This path cursor
  26236. */
  26237. moveBack(step?: number): PathCursor;
  26238. /**
  26239. * Moves the cursor by the step amount
  26240. * If the step amount is greater than one, an exception is thrown
  26241. * @param step The amount to move the cursor
  26242. * @returns This path cursor
  26243. */
  26244. move(step: number): PathCursor;
  26245. /**
  26246. * Ensures that the value is limited between zero and one
  26247. * @returns This path cursor
  26248. */
  26249. private ensureLimits;
  26250. /**
  26251. * Runs onchange callbacks on change (used by the animation engine)
  26252. * @returns This path cursor
  26253. */
  26254. private raiseOnChange;
  26255. /**
  26256. * Executes a function on change
  26257. * @param f A path cursor onchange callback
  26258. * @returns This path cursor
  26259. */
  26260. onchange(f: (cursor: PathCursor) => void): PathCursor;
  26261. }
  26262. /**
  26263. * Defines an interface which represents an animation key frame
  26264. */
  26265. export interface IAnimationKey {
  26266. /**
  26267. * Frame of the key frame
  26268. */
  26269. frame: number;
  26270. /**
  26271. * Value at the specifies key frame
  26272. */
  26273. value: any;
  26274. /**
  26275. * The input tangent for the cubic hermite spline
  26276. */
  26277. inTangent?: any;
  26278. /**
  26279. * The output tangent for the cubic hermite spline
  26280. */
  26281. outTangent?: any;
  26282. /**
  26283. * The animation interpolation type
  26284. */
  26285. interpolation?: AnimationKeyInterpolation;
  26286. }
  26287. /**
  26288. * Enum for the animation key frame interpolation type
  26289. */
  26290. export enum AnimationKeyInterpolation {
  26291. /**
  26292. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  26293. */
  26294. STEP = 1
  26295. }
  26296. /**
  26297. * Class used to store any kind of animation
  26298. */
  26299. export class Animation {
  26300. /**Name of the animation */
  26301. name: string;
  26302. /**Property to animate */
  26303. targetProperty: string;
  26304. /**The frames per second of the animation */
  26305. framePerSecond: number;
  26306. /**The data type of the animation */
  26307. dataType: number;
  26308. /**The loop mode of the animation */
  26309. loopMode?: number | undefined;
  26310. /**Specifies if blending should be enabled */
  26311. enableBlending?: boolean | undefined;
  26312. /**
  26313. * Use matrix interpolation instead of using direct key value when animating matrices
  26314. */
  26315. static AllowMatricesInterpolation: boolean;
  26316. /**
  26317. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26318. */
  26319. static AllowMatrixDecomposeForInterpolation: boolean;
  26320. /**
  26321. * Stores the key frames of the animation
  26322. */
  26323. private _keys;
  26324. /**
  26325. * Stores the easing function of the animation
  26326. */
  26327. private _easingFunction;
  26328. /**
  26329. * @hidden Internal use only
  26330. */
  26331. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26332. /**
  26333. * The set of event that will be linked to this animation
  26334. */
  26335. private _events;
  26336. /**
  26337. * Stores an array of target property paths
  26338. */
  26339. targetPropertyPath: string[];
  26340. /**
  26341. * Stores the blending speed of the animation
  26342. */
  26343. blendingSpeed: number;
  26344. /**
  26345. * Stores the animation ranges for the animation
  26346. */
  26347. private _ranges;
  26348. /**
  26349. * @hidden Internal use
  26350. */
  26351. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26352. /**
  26353. * Sets up an animation
  26354. * @param property The property to animate
  26355. * @param animationType The animation type to apply
  26356. * @param framePerSecond The frames per second of the animation
  26357. * @param easingFunction The easing function used in the animation
  26358. * @returns The created animation
  26359. */
  26360. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26361. /**
  26362. * Create and start an animation on a node
  26363. * @param name defines the name of the global animation that will be run on all nodes
  26364. * @param node defines the root node where the animation will take place
  26365. * @param targetProperty defines property to animate
  26366. * @param framePerSecond defines the number of frame per second yo use
  26367. * @param totalFrame defines the number of frames in total
  26368. * @param from defines the initial value
  26369. * @param to defines the final value
  26370. * @param loopMode defines which loop mode you want to use (off by default)
  26371. * @param easingFunction defines the easing function to use (linear by default)
  26372. * @param onAnimationEnd defines the callback to call when animation end
  26373. * @returns the animatable created for this animation
  26374. */
  26375. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26376. /**
  26377. * Create and start an animation on a node and its descendants
  26378. * @param name defines the name of the global animation that will be run on all nodes
  26379. * @param node defines the root node where the animation will take place
  26380. * @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
  26381. * @param targetProperty defines property to animate
  26382. * @param framePerSecond defines the number of frame per second to use
  26383. * @param totalFrame defines the number of frames in total
  26384. * @param from defines the initial value
  26385. * @param to defines the final value
  26386. * @param loopMode defines which loop mode you want to use (off by default)
  26387. * @param easingFunction defines the easing function to use (linear by default)
  26388. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26389. * @returns the list of animatables created for all nodes
  26390. * @example https://www.babylonjs-playground.com/#MH0VLI
  26391. */
  26392. 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[]>;
  26393. /**
  26394. * Creates a new animation, merges it with the existing animations and starts it
  26395. * @param name Name of the animation
  26396. * @param node Node which contains the scene that begins the animations
  26397. * @param targetProperty Specifies which property to animate
  26398. * @param framePerSecond The frames per second of the animation
  26399. * @param totalFrame The total number of frames
  26400. * @param from The frame at the beginning of the animation
  26401. * @param to The frame at the end of the animation
  26402. * @param loopMode Specifies the loop mode of the animation
  26403. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26404. * @param onAnimationEnd Callback to run once the animation is complete
  26405. * @returns Nullable animation
  26406. */
  26407. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26408. /**
  26409. * Transition property of an host to the target Value
  26410. * @param property The property to transition
  26411. * @param targetValue The target Value of the property
  26412. * @param host The object where the property to animate belongs
  26413. * @param scene Scene used to run the animation
  26414. * @param frameRate Framerate (in frame/s) to use
  26415. * @param transition The transition type we want to use
  26416. * @param duration The duration of the animation, in milliseconds
  26417. * @param onAnimationEnd Callback trigger at the end of the animation
  26418. * @returns Nullable animation
  26419. */
  26420. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26421. /**
  26422. * Return the array of runtime animations currently using this animation
  26423. */
  26424. readonly runtimeAnimations: RuntimeAnimation[];
  26425. /**
  26426. * Specifies if any of the runtime animations are currently running
  26427. */
  26428. readonly hasRunningRuntimeAnimations: boolean;
  26429. /**
  26430. * Initializes the animation
  26431. * @param name Name of the animation
  26432. * @param targetProperty Property to animate
  26433. * @param framePerSecond The frames per second of the animation
  26434. * @param dataType The data type of the animation
  26435. * @param loopMode The loop mode of the animation
  26436. * @param enableBlendings Specifies if blending should be enabled
  26437. */
  26438. constructor(
  26439. /**Name of the animation */
  26440. name: string,
  26441. /**Property to animate */
  26442. targetProperty: string,
  26443. /**The frames per second of the animation */
  26444. framePerSecond: number,
  26445. /**The data type of the animation */
  26446. dataType: number,
  26447. /**The loop mode of the animation */
  26448. loopMode?: number | undefined,
  26449. /**Specifies if blending should be enabled */
  26450. enableBlending?: boolean | undefined);
  26451. /**
  26452. * Converts the animation to a string
  26453. * @param fullDetails support for multiple levels of logging within scene loading
  26454. * @returns String form of the animation
  26455. */
  26456. toString(fullDetails?: boolean): string;
  26457. /**
  26458. * Add an event to this animation
  26459. * @param event Event to add
  26460. */
  26461. addEvent(event: AnimationEvent): void;
  26462. /**
  26463. * Remove all events found at the given frame
  26464. * @param frame The frame to remove events from
  26465. */
  26466. removeEvents(frame: number): void;
  26467. /**
  26468. * Retrieves all the events from the animation
  26469. * @returns Events from the animation
  26470. */
  26471. getEvents(): AnimationEvent[];
  26472. /**
  26473. * Creates an animation range
  26474. * @param name Name of the animation range
  26475. * @param from Starting frame of the animation range
  26476. * @param to Ending frame of the animation
  26477. */
  26478. createRange(name: string, from: number, to: number): void;
  26479. /**
  26480. * Deletes an animation range by name
  26481. * @param name Name of the animation range to delete
  26482. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26483. */
  26484. deleteRange(name: string, deleteFrames?: boolean): void;
  26485. /**
  26486. * Gets the animation range by name, or null if not defined
  26487. * @param name Name of the animation range
  26488. * @returns Nullable animation range
  26489. */
  26490. getRange(name: string): Nullable<AnimationRange>;
  26491. /**
  26492. * Gets the key frames from the animation
  26493. * @returns The key frames of the animation
  26494. */
  26495. getKeys(): Array<IAnimationKey>;
  26496. /**
  26497. * Gets the highest frame rate of the animation
  26498. * @returns Highest frame rate of the animation
  26499. */
  26500. getHighestFrame(): number;
  26501. /**
  26502. * Gets the easing function of the animation
  26503. * @returns Easing function of the animation
  26504. */
  26505. getEasingFunction(): IEasingFunction;
  26506. /**
  26507. * Sets the easing function of the animation
  26508. * @param easingFunction A custom mathematical formula for animation
  26509. */
  26510. setEasingFunction(easingFunction: EasingFunction): void;
  26511. /**
  26512. * Interpolates a scalar linearly
  26513. * @param startValue Start value of the animation curve
  26514. * @param endValue End value of the animation curve
  26515. * @param gradient Scalar amount to interpolate
  26516. * @returns Interpolated scalar value
  26517. */
  26518. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26519. /**
  26520. * Interpolates a scalar cubically
  26521. * @param startValue Start value of the animation curve
  26522. * @param outTangent End tangent of the animation
  26523. * @param endValue End value of the animation curve
  26524. * @param inTangent Start tangent of the animation curve
  26525. * @param gradient Scalar amount to interpolate
  26526. * @returns Interpolated scalar value
  26527. */
  26528. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26529. /**
  26530. * Interpolates a quaternion using a spherical linear interpolation
  26531. * @param startValue Start value of the animation curve
  26532. * @param endValue End value of the animation curve
  26533. * @param gradient Scalar amount to interpolate
  26534. * @returns Interpolated quaternion value
  26535. */
  26536. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26537. /**
  26538. * Interpolates a quaternion cubically
  26539. * @param startValue Start value of the animation curve
  26540. * @param outTangent End tangent of the animation curve
  26541. * @param endValue End value of the animation curve
  26542. * @param inTangent Start tangent of the animation curve
  26543. * @param gradient Scalar amount to interpolate
  26544. * @returns Interpolated quaternion value
  26545. */
  26546. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26547. /**
  26548. * Interpolates a Vector3 linearl
  26549. * @param startValue Start value of the animation curve
  26550. * @param endValue End value of the animation curve
  26551. * @param gradient Scalar amount to interpolate
  26552. * @returns Interpolated scalar value
  26553. */
  26554. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26555. /**
  26556. * Interpolates a Vector3 cubically
  26557. * @param startValue Start value of the animation curve
  26558. * @param outTangent End tangent of the animation
  26559. * @param endValue End value of the animation curve
  26560. * @param inTangent Start tangent of the animation curve
  26561. * @param gradient Scalar amount to interpolate
  26562. * @returns InterpolatedVector3 value
  26563. */
  26564. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26565. /**
  26566. * Interpolates a Vector2 linearly
  26567. * @param startValue Start value of the animation curve
  26568. * @param endValue End value of the animation curve
  26569. * @param gradient Scalar amount to interpolate
  26570. * @returns Interpolated Vector2 value
  26571. */
  26572. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26573. /**
  26574. * Interpolates a Vector2 cubically
  26575. * @param startValue Start value of the animation curve
  26576. * @param outTangent End tangent of the animation
  26577. * @param endValue End value of the animation curve
  26578. * @param inTangent Start tangent of the animation curve
  26579. * @param gradient Scalar amount to interpolate
  26580. * @returns Interpolated Vector2 value
  26581. */
  26582. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26583. /**
  26584. * Interpolates a size linearly
  26585. * @param startValue Start value of the animation curve
  26586. * @param endValue End value of the animation curve
  26587. * @param gradient Scalar amount to interpolate
  26588. * @returns Interpolated Size value
  26589. */
  26590. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26591. /**
  26592. * Interpolates a Color3 linearly
  26593. * @param startValue Start value of the animation curve
  26594. * @param endValue End value of the animation curve
  26595. * @param gradient Scalar amount to interpolate
  26596. * @returns Interpolated Color3 value
  26597. */
  26598. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26599. /**
  26600. * @hidden Internal use only
  26601. */
  26602. _getKeyValue(value: any): any;
  26603. /**
  26604. * @hidden Internal use only
  26605. */
  26606. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26607. /**
  26608. * Defines the function to use to interpolate matrices
  26609. * @param startValue defines the start matrix
  26610. * @param endValue defines the end matrix
  26611. * @param gradient defines the gradient between both matrices
  26612. * @param result defines an optional target matrix where to store the interpolation
  26613. * @returns the interpolated matrix
  26614. */
  26615. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26616. /**
  26617. * Makes a copy of the animation
  26618. * @returns Cloned animation
  26619. */
  26620. clone(): Animation;
  26621. /**
  26622. * Sets the key frames of the animation
  26623. * @param values The animation key frames to set
  26624. */
  26625. setKeys(values: Array<IAnimationKey>): void;
  26626. /**
  26627. * Serializes the animation to an object
  26628. * @returns Serialized object
  26629. */
  26630. serialize(): any;
  26631. /**
  26632. * Float animation type
  26633. */
  26634. private static _ANIMATIONTYPE_FLOAT;
  26635. /**
  26636. * Vector3 animation type
  26637. */
  26638. private static _ANIMATIONTYPE_VECTOR3;
  26639. /**
  26640. * Quaternion animation type
  26641. */
  26642. private static _ANIMATIONTYPE_QUATERNION;
  26643. /**
  26644. * Matrix animation type
  26645. */
  26646. private static _ANIMATIONTYPE_MATRIX;
  26647. /**
  26648. * Color3 animation type
  26649. */
  26650. private static _ANIMATIONTYPE_COLOR3;
  26651. /**
  26652. * Vector2 animation type
  26653. */
  26654. private static _ANIMATIONTYPE_VECTOR2;
  26655. /**
  26656. * Size animation type
  26657. */
  26658. private static _ANIMATIONTYPE_SIZE;
  26659. /**
  26660. * Relative Loop Mode
  26661. */
  26662. private static _ANIMATIONLOOPMODE_RELATIVE;
  26663. /**
  26664. * Cycle Loop Mode
  26665. */
  26666. private static _ANIMATIONLOOPMODE_CYCLE;
  26667. /**
  26668. * Constant Loop Mode
  26669. */
  26670. private static _ANIMATIONLOOPMODE_CONSTANT;
  26671. /**
  26672. * Get the float animation type
  26673. */
  26674. static readonly ANIMATIONTYPE_FLOAT: number;
  26675. /**
  26676. * Get the Vector3 animation type
  26677. */
  26678. static readonly ANIMATIONTYPE_VECTOR3: number;
  26679. /**
  26680. * Get the Vector2 animation type
  26681. */
  26682. static readonly ANIMATIONTYPE_VECTOR2: number;
  26683. /**
  26684. * Get the Size animation type
  26685. */
  26686. static readonly ANIMATIONTYPE_SIZE: number;
  26687. /**
  26688. * Get the Quaternion animation type
  26689. */
  26690. static readonly ANIMATIONTYPE_QUATERNION: number;
  26691. /**
  26692. * Get the Matrix animation type
  26693. */
  26694. static readonly ANIMATIONTYPE_MATRIX: number;
  26695. /**
  26696. * Get the Color3 animation type
  26697. */
  26698. static readonly ANIMATIONTYPE_COLOR3: number;
  26699. /**
  26700. * Get the Relative Loop Mode
  26701. */
  26702. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26703. /**
  26704. * Get the Cycle Loop Mode
  26705. */
  26706. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26707. /**
  26708. * Get the Constant Loop Mode
  26709. */
  26710. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26711. /** @hidden */
  26712. static _UniversalLerp(left: any, right: any, amount: number): any;
  26713. /**
  26714. * Parses an animation object and creates an animation
  26715. * @param parsedAnimation Parsed animation object
  26716. * @returns Animation object
  26717. */
  26718. static Parse(parsedAnimation: any): Animation;
  26719. /**
  26720. * Appends the serialized animations from the source animations
  26721. * @param source Source containing the animations
  26722. * @param destination Target to store the animations
  26723. */
  26724. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26725. }
  26726. }
  26727. declare module "babylonjs/Materials/Textures/baseTexture" {
  26728. import { Observable } from "babylonjs/Misc/observable";
  26729. import { IAnimatable } from "babylonjs/Misc/tools";
  26730. import { Nullable } from "babylonjs/types";
  26731. import { Scene } from "babylonjs/scene";
  26732. import { Matrix, ISize } from "babylonjs/Maths/math";
  26733. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26735. /**
  26736. * Base class of all the textures in babylon.
  26737. * It groups all the common properties the materials, post process, lights... might need
  26738. * in order to make a correct use of the texture.
  26739. */
  26740. export class BaseTexture implements IAnimatable {
  26741. /**
  26742. * Default anisotropic filtering level for the application.
  26743. * It is set to 4 as a good tradeoff between perf and quality.
  26744. */
  26745. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26746. /**
  26747. * Gets or sets the unique id of the texture
  26748. */
  26749. uniqueId: number;
  26750. /**
  26751. * Define the name of the texture.
  26752. */
  26753. name: string;
  26754. /**
  26755. * Gets or sets an object used to store user defined information.
  26756. */
  26757. metadata: any;
  26758. /**
  26759. * For internal use only. Please do not use.
  26760. */
  26761. reservedDataStore: any;
  26762. private _hasAlpha;
  26763. /**
  26764. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26765. */
  26766. hasAlpha: boolean;
  26767. /**
  26768. * Defines if the alpha value should be determined via the rgb values.
  26769. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26770. */
  26771. getAlphaFromRGB: boolean;
  26772. /**
  26773. * Intensity or strength of the texture.
  26774. * It is commonly used by materials to fine tune the intensity of the texture
  26775. */
  26776. level: number;
  26777. /**
  26778. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26779. * This is part of the texture as textures usually maps to one uv set.
  26780. */
  26781. coordinatesIndex: number;
  26782. private _coordinatesMode;
  26783. /**
  26784. * How a texture is mapped.
  26785. *
  26786. * | Value | Type | Description |
  26787. * | ----- | ----------------------------------- | ----------- |
  26788. * | 0 | EXPLICIT_MODE | |
  26789. * | 1 | SPHERICAL_MODE | |
  26790. * | 2 | PLANAR_MODE | |
  26791. * | 3 | CUBIC_MODE | |
  26792. * | 4 | PROJECTION_MODE | |
  26793. * | 5 | SKYBOX_MODE | |
  26794. * | 6 | INVCUBIC_MODE | |
  26795. * | 7 | EQUIRECTANGULAR_MODE | |
  26796. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26797. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26798. */
  26799. coordinatesMode: number;
  26800. /**
  26801. * | Value | Type | Description |
  26802. * | ----- | ------------------ | ----------- |
  26803. * | 0 | CLAMP_ADDRESSMODE | |
  26804. * | 1 | WRAP_ADDRESSMODE | |
  26805. * | 2 | MIRROR_ADDRESSMODE | |
  26806. */
  26807. wrapU: number;
  26808. /**
  26809. * | Value | Type | Description |
  26810. * | ----- | ------------------ | ----------- |
  26811. * | 0 | CLAMP_ADDRESSMODE | |
  26812. * | 1 | WRAP_ADDRESSMODE | |
  26813. * | 2 | MIRROR_ADDRESSMODE | |
  26814. */
  26815. wrapV: number;
  26816. /**
  26817. * | Value | Type | Description |
  26818. * | ----- | ------------------ | ----------- |
  26819. * | 0 | CLAMP_ADDRESSMODE | |
  26820. * | 1 | WRAP_ADDRESSMODE | |
  26821. * | 2 | MIRROR_ADDRESSMODE | |
  26822. */
  26823. wrapR: number;
  26824. /**
  26825. * With compliant hardware and browser (supporting anisotropic filtering)
  26826. * this defines the level of anisotropic filtering in the texture.
  26827. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26828. */
  26829. anisotropicFilteringLevel: number;
  26830. /**
  26831. * Define if the texture is a cube texture or if false a 2d texture.
  26832. */
  26833. isCube: boolean;
  26834. /**
  26835. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26836. */
  26837. is3D: boolean;
  26838. /**
  26839. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26840. * HDR texture are usually stored in linear space.
  26841. * This only impacts the PBR and Background materials
  26842. */
  26843. gammaSpace: boolean;
  26844. /**
  26845. * Gets whether or not the texture contains RGBD data.
  26846. */
  26847. readonly isRGBD: boolean;
  26848. /**
  26849. * Is Z inverted in the texture (useful in a cube texture).
  26850. */
  26851. invertZ: boolean;
  26852. /**
  26853. * Are mip maps generated for this texture or not.
  26854. */
  26855. readonly noMipmap: boolean;
  26856. /**
  26857. * @hidden
  26858. */
  26859. lodLevelInAlpha: boolean;
  26860. /**
  26861. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26862. */
  26863. lodGenerationOffset: number;
  26864. /**
  26865. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26866. */
  26867. lodGenerationScale: number;
  26868. /**
  26869. * Define if the texture is a render target.
  26870. */
  26871. isRenderTarget: boolean;
  26872. /**
  26873. * Define the unique id of the texture in the scene.
  26874. */
  26875. readonly uid: string;
  26876. /**
  26877. * Return a string representation of the texture.
  26878. * @returns the texture as a string
  26879. */
  26880. toString(): string;
  26881. /**
  26882. * Get the class name of the texture.
  26883. * @returns "BaseTexture"
  26884. */
  26885. getClassName(): string;
  26886. /**
  26887. * Define the list of animation attached to the texture.
  26888. */
  26889. animations: import("babylonjs/Animations/animation").Animation[];
  26890. /**
  26891. * An event triggered when the texture is disposed.
  26892. */
  26893. onDisposeObservable: Observable<BaseTexture>;
  26894. private _onDisposeObserver;
  26895. /**
  26896. * Callback triggered when the texture has been disposed.
  26897. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26898. */
  26899. onDispose: () => void;
  26900. /**
  26901. * Define the current state of the loading sequence when in delayed load mode.
  26902. */
  26903. delayLoadState: number;
  26904. private _scene;
  26905. /** @hidden */
  26906. _texture: Nullable<InternalTexture>;
  26907. private _uid;
  26908. /**
  26909. * Define if the texture is preventinga material to render or not.
  26910. * If not and the texture is not ready, the engine will use a default black texture instead.
  26911. */
  26912. readonly isBlocking: boolean;
  26913. /**
  26914. * Instantiates a new BaseTexture.
  26915. * Base class of all the textures in babylon.
  26916. * It groups all the common properties the materials, post process, lights... might need
  26917. * in order to make a correct use of the texture.
  26918. * @param scene Define the scene the texture blongs to
  26919. */
  26920. constructor(scene: Nullable<Scene>);
  26921. /**
  26922. * Get the scene the texture belongs to.
  26923. * @returns the scene or null if undefined
  26924. */
  26925. getScene(): Nullable<Scene>;
  26926. /**
  26927. * Get the texture transform matrix used to offset tile the texture for istance.
  26928. * @returns the transformation matrix
  26929. */
  26930. getTextureMatrix(): Matrix;
  26931. /**
  26932. * Get the texture reflection matrix used to rotate/transform the reflection.
  26933. * @returns the reflection matrix
  26934. */
  26935. getReflectionTextureMatrix(): Matrix;
  26936. /**
  26937. * Get the underlying lower level texture from Babylon.
  26938. * @returns the insternal texture
  26939. */
  26940. getInternalTexture(): Nullable<InternalTexture>;
  26941. /**
  26942. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26943. * @returns true if ready or not blocking
  26944. */
  26945. isReadyOrNotBlocking(): boolean;
  26946. /**
  26947. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26948. * @returns true if fully ready
  26949. */
  26950. isReady(): boolean;
  26951. private _cachedSize;
  26952. /**
  26953. * Get the size of the texture.
  26954. * @returns the texture size.
  26955. */
  26956. getSize(): ISize;
  26957. /**
  26958. * Get the base size of the texture.
  26959. * It can be different from the size if the texture has been resized for POT for instance
  26960. * @returns the base size
  26961. */
  26962. getBaseSize(): ISize;
  26963. /**
  26964. * Update the sampling mode of the texture.
  26965. * Default is Trilinear mode.
  26966. *
  26967. * | Value | Type | Description |
  26968. * | ----- | ------------------ | ----------- |
  26969. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26970. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26971. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26972. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26973. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26974. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26975. * | 7 | NEAREST_LINEAR | |
  26976. * | 8 | NEAREST_NEAREST | |
  26977. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26978. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26979. * | 11 | LINEAR_LINEAR | |
  26980. * | 12 | LINEAR_NEAREST | |
  26981. *
  26982. * > _mag_: magnification filter (close to the viewer)
  26983. * > _min_: minification filter (far from the viewer)
  26984. * > _mip_: filter used between mip map levels
  26985. *@param samplingMode Define the new sampling mode of the texture
  26986. */
  26987. updateSamplingMode(samplingMode: number): void;
  26988. /**
  26989. * Scales the texture if is `canRescale()`
  26990. * @param ratio the resize factor we want to use to rescale
  26991. */
  26992. scale(ratio: number): void;
  26993. /**
  26994. * Get if the texture can rescale.
  26995. */
  26996. readonly canRescale: boolean;
  26997. /** @hidden */
  26998. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  26999. /** @hidden */
  27000. _rebuild(): void;
  27001. /**
  27002. * Triggers the load sequence in delayed load mode.
  27003. */
  27004. delayLoad(): void;
  27005. /**
  27006. * Clones the texture.
  27007. * @returns the cloned texture
  27008. */
  27009. clone(): Nullable<BaseTexture>;
  27010. /**
  27011. * Get the texture underlying type (INT, FLOAT...)
  27012. */
  27013. readonly textureType: number;
  27014. /**
  27015. * Get the texture underlying format (RGB, RGBA...)
  27016. */
  27017. readonly textureFormat: number;
  27018. /**
  27019. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27020. * This will returns an RGBA array buffer containing either in values (0-255) or
  27021. * float values (0-1) depending of the underlying buffer type.
  27022. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27023. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27024. * @param buffer defines a user defined buffer to fill with data (can be null)
  27025. * @returns The Array buffer containing the pixels data.
  27026. */
  27027. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27028. /**
  27029. * Release and destroy the underlying lower level texture aka internalTexture.
  27030. */
  27031. releaseInternalTexture(): void;
  27032. /**
  27033. * Get the polynomial representation of the texture data.
  27034. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27035. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27036. */
  27037. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27038. /** @hidden */
  27039. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27040. /** @hidden */
  27041. readonly _lodTextureMid: Nullable<BaseTexture>;
  27042. /** @hidden */
  27043. readonly _lodTextureLow: Nullable<BaseTexture>;
  27044. /**
  27045. * Dispose the texture and release its associated resources.
  27046. */
  27047. dispose(): void;
  27048. /**
  27049. * Serialize the texture into a JSON representation that can be parsed later on.
  27050. * @returns the JSON representation of the texture
  27051. */
  27052. serialize(): any;
  27053. /**
  27054. * Helper function to be called back once a list of texture contains only ready textures.
  27055. * @param textures Define the list of textures to wait for
  27056. * @param callback Define the callback triggered once the entire list will be ready
  27057. */
  27058. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27059. }
  27060. }
  27061. declare module "babylonjs/Materials/uniformBuffer" {
  27062. import { Nullable, FloatArray } from "babylonjs/types";
  27063. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27064. import { Engine } from "babylonjs/Engines/engine";
  27065. import { Effect } from "babylonjs/Materials/effect";
  27066. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27067. /**
  27068. * Uniform buffer objects.
  27069. *
  27070. * Handles blocks of uniform on the GPU.
  27071. *
  27072. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27073. *
  27074. * For more information, please refer to :
  27075. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27076. */
  27077. export class UniformBuffer {
  27078. private _engine;
  27079. private _buffer;
  27080. private _data;
  27081. private _bufferData;
  27082. private _dynamic?;
  27083. private _uniformLocations;
  27084. private _uniformSizes;
  27085. private _uniformLocationPointer;
  27086. private _needSync;
  27087. private _noUBO;
  27088. private _currentEffect;
  27089. private static _MAX_UNIFORM_SIZE;
  27090. private static _tempBuffer;
  27091. /**
  27092. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27093. * This is dynamic to allow compat with webgl 1 and 2.
  27094. * You will need to pass the name of the uniform as well as the value.
  27095. */
  27096. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27097. /**
  27098. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27099. * This is dynamic to allow compat with webgl 1 and 2.
  27100. * You will need to pass the name of the uniform as well as the value.
  27101. */
  27102. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27103. /**
  27104. * Lambda to Update a single float in a uniform buffer.
  27105. * This is dynamic to allow compat with webgl 1 and 2.
  27106. * You will need to pass the name of the uniform as well as the value.
  27107. */
  27108. updateFloat: (name: string, x: number) => void;
  27109. /**
  27110. * Lambda to Update a vec2 of float in a uniform buffer.
  27111. * This is dynamic to allow compat with webgl 1 and 2.
  27112. * You will need to pass the name of the uniform as well as the value.
  27113. */
  27114. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27115. /**
  27116. * Lambda to Update a vec3 of float in a uniform buffer.
  27117. * This is dynamic to allow compat with webgl 1 and 2.
  27118. * You will need to pass the name of the uniform as well as the value.
  27119. */
  27120. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27121. /**
  27122. * Lambda to Update a vec4 of float in a uniform buffer.
  27123. * This is dynamic to allow compat with webgl 1 and 2.
  27124. * You will need to pass the name of the uniform as well as the value.
  27125. */
  27126. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27127. /**
  27128. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27129. * This is dynamic to allow compat with webgl 1 and 2.
  27130. * You will need to pass the name of the uniform as well as the value.
  27131. */
  27132. updateMatrix: (name: string, mat: Matrix) => void;
  27133. /**
  27134. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27135. * This is dynamic to allow compat with webgl 1 and 2.
  27136. * You will need to pass the name of the uniform as well as the value.
  27137. */
  27138. updateVector3: (name: string, vector: Vector3) => void;
  27139. /**
  27140. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27141. * This is dynamic to allow compat with webgl 1 and 2.
  27142. * You will need to pass the name of the uniform as well as the value.
  27143. */
  27144. updateVector4: (name: string, vector: Vector4) => void;
  27145. /**
  27146. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27147. * This is dynamic to allow compat with webgl 1 and 2.
  27148. * You will need to pass the name of the uniform as well as the value.
  27149. */
  27150. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27151. /**
  27152. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27153. * This is dynamic to allow compat with webgl 1 and 2.
  27154. * You will need to pass the name of the uniform as well as the value.
  27155. */
  27156. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27157. /**
  27158. * Instantiates a new Uniform buffer objects.
  27159. *
  27160. * Handles blocks of uniform on the GPU.
  27161. *
  27162. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27163. *
  27164. * For more information, please refer to :
  27165. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27166. * @param engine Define the engine the buffer is associated with
  27167. * @param data Define the data contained in the buffer
  27168. * @param dynamic Define if the buffer is updatable
  27169. */
  27170. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27171. /**
  27172. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27173. * or just falling back on setUniformXXX calls.
  27174. */
  27175. readonly useUbo: boolean;
  27176. /**
  27177. * Indicates if the WebGL underlying uniform buffer is in sync
  27178. * with the javascript cache data.
  27179. */
  27180. readonly isSync: boolean;
  27181. /**
  27182. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27183. * Also, a dynamic UniformBuffer will disable cache verification and always
  27184. * update the underlying WebGL uniform buffer to the GPU.
  27185. * @returns if Dynamic, otherwise false
  27186. */
  27187. isDynamic(): boolean;
  27188. /**
  27189. * The data cache on JS side.
  27190. * @returns the underlying data as a float array
  27191. */
  27192. getData(): Float32Array;
  27193. /**
  27194. * The underlying WebGL Uniform buffer.
  27195. * @returns the webgl buffer
  27196. */
  27197. getBuffer(): Nullable<WebGLBuffer>;
  27198. /**
  27199. * std140 layout specifies how to align data within an UBO structure.
  27200. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27201. * for specs.
  27202. */
  27203. private _fillAlignment;
  27204. /**
  27205. * Adds an uniform in the buffer.
  27206. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27207. * for the layout to be correct !
  27208. * @param name Name of the uniform, as used in the uniform block in the shader.
  27209. * @param size Data size, or data directly.
  27210. */
  27211. addUniform(name: string, size: number | number[]): void;
  27212. /**
  27213. * Adds a Matrix 4x4 to the uniform buffer.
  27214. * @param name Name of the uniform, as used in the uniform block in the shader.
  27215. * @param mat A 4x4 matrix.
  27216. */
  27217. addMatrix(name: string, mat: Matrix): void;
  27218. /**
  27219. * Adds a vec2 to the uniform buffer.
  27220. * @param name Name of the uniform, as used in the uniform block in the shader.
  27221. * @param x Define the x component value of the vec2
  27222. * @param y Define the y component value of the vec2
  27223. */
  27224. addFloat2(name: string, x: number, y: number): void;
  27225. /**
  27226. * Adds a vec3 to the uniform buffer.
  27227. * @param name Name of the uniform, as used in the uniform block in the shader.
  27228. * @param x Define the x component value of the vec3
  27229. * @param y Define the y component value of the vec3
  27230. * @param z Define the z component value of the vec3
  27231. */
  27232. addFloat3(name: string, x: number, y: number, z: number): void;
  27233. /**
  27234. * Adds a vec3 to the uniform buffer.
  27235. * @param name Name of the uniform, as used in the uniform block in the shader.
  27236. * @param color Define the vec3 from a Color
  27237. */
  27238. addColor3(name: string, color: Color3): void;
  27239. /**
  27240. * Adds a vec4 to the uniform buffer.
  27241. * @param name Name of the uniform, as used in the uniform block in the shader.
  27242. * @param color Define the rgb components from a Color
  27243. * @param alpha Define the a component of the vec4
  27244. */
  27245. addColor4(name: string, color: Color3, alpha: number): void;
  27246. /**
  27247. * Adds a vec3 to the uniform buffer.
  27248. * @param name Name of the uniform, as used in the uniform block in the shader.
  27249. * @param vector Define the vec3 components from a Vector
  27250. */
  27251. addVector3(name: string, vector: Vector3): void;
  27252. /**
  27253. * Adds a Matrix 3x3 to the uniform buffer.
  27254. * @param name Name of the uniform, as used in the uniform block in the shader.
  27255. */
  27256. addMatrix3x3(name: string): void;
  27257. /**
  27258. * Adds a Matrix 2x2 to the uniform buffer.
  27259. * @param name Name of the uniform, as used in the uniform block in the shader.
  27260. */
  27261. addMatrix2x2(name: string): void;
  27262. /**
  27263. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27264. */
  27265. create(): void;
  27266. /** @hidden */
  27267. _rebuild(): void;
  27268. /**
  27269. * Updates the WebGL Uniform Buffer on the GPU.
  27270. * If the `dynamic` flag is set to true, no cache comparison is done.
  27271. * Otherwise, the buffer will be updated only if the cache differs.
  27272. */
  27273. update(): void;
  27274. /**
  27275. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27276. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27277. * @param data Define the flattened data
  27278. * @param size Define the size of the data.
  27279. */
  27280. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27281. private _updateMatrix3x3ForUniform;
  27282. private _updateMatrix3x3ForEffect;
  27283. private _updateMatrix2x2ForEffect;
  27284. private _updateMatrix2x2ForUniform;
  27285. private _updateFloatForEffect;
  27286. private _updateFloatForUniform;
  27287. private _updateFloat2ForEffect;
  27288. private _updateFloat2ForUniform;
  27289. private _updateFloat3ForEffect;
  27290. private _updateFloat3ForUniform;
  27291. private _updateFloat4ForEffect;
  27292. private _updateFloat4ForUniform;
  27293. private _updateMatrixForEffect;
  27294. private _updateMatrixForUniform;
  27295. private _updateVector3ForEffect;
  27296. private _updateVector3ForUniform;
  27297. private _updateVector4ForEffect;
  27298. private _updateVector4ForUniform;
  27299. private _updateColor3ForEffect;
  27300. private _updateColor3ForUniform;
  27301. private _updateColor4ForEffect;
  27302. private _updateColor4ForUniform;
  27303. /**
  27304. * Sets a sampler uniform on the effect.
  27305. * @param name Define the name of the sampler.
  27306. * @param texture Define the texture to set in the sampler
  27307. */
  27308. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27309. /**
  27310. * Directly updates the value of the uniform in the cache AND on the GPU.
  27311. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27312. * @param data Define the flattened data
  27313. */
  27314. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27315. /**
  27316. * Binds this uniform buffer to an effect.
  27317. * @param effect Define the effect to bind the buffer to
  27318. * @param name Name of the uniform block in the shader.
  27319. */
  27320. bindToEffect(effect: Effect, name: string): void;
  27321. /**
  27322. * Disposes the uniform buffer.
  27323. */
  27324. dispose(): void;
  27325. }
  27326. }
  27327. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  27328. import { Nullable } from "babylonjs/types";
  27329. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27330. /**
  27331. * This represents the required contract to create a new type of texture loader.
  27332. */
  27333. export interface IInternalTextureLoader {
  27334. /**
  27335. * Defines wether the loader supports cascade loading the different faces.
  27336. */
  27337. supportCascades: boolean;
  27338. /**
  27339. * This returns if the loader support the current file information.
  27340. * @param extension defines the file extension of the file being loaded
  27341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  27342. * @param fallback defines the fallback internal texture if any
  27343. * @param isBase64 defines whether the texture is encoded as a base64
  27344. * @param isBuffer defines whether the texture data are stored as a buffer
  27345. * @returns true if the loader can load the specified file
  27346. */
  27347. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  27348. /**
  27349. * Transform the url before loading if required.
  27350. * @param rootUrl the url of the texture
  27351. * @param textureFormatInUse defines the current compressed format in use iun the engine
  27352. * @returns the transformed texture
  27353. */
  27354. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  27355. /**
  27356. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  27357. * @param rootUrl the url of the texture
  27358. * @param textureFormatInUse defines the current compressed format in use iun the engine
  27359. * @returns the fallback texture
  27360. */
  27361. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  27362. /**
  27363. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  27364. * @param data contains the texture data
  27365. * @param texture defines the BabylonJS internal texture
  27366. * @param createPolynomials will be true if polynomials have been requested
  27367. * @param onLoad defines the callback to trigger once the texture is ready
  27368. * @param onError defines the callback to trigger in case of error
  27369. */
  27370. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  27371. /**
  27372. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  27373. * @param data contains the texture data
  27374. * @param texture defines the BabylonJS internal texture
  27375. * @param callback defines the method to call once ready to upload
  27376. */
  27377. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  27378. }
  27379. }
  27380. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  27381. import { Scene } from "babylonjs/scene";
  27382. import { Engine } from "babylonjs/Engines/engine";
  27383. import { Texture } from "babylonjs/Materials/Textures/texture";
  27384. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27385. /**
  27386. * Creation options of the multi render target texture.
  27387. */
  27388. export interface IMultiRenderTargetOptions {
  27389. /**
  27390. * Define if the texture needs to create mip maps after render.
  27391. */
  27392. generateMipMaps?: boolean;
  27393. /**
  27394. * Define the types of all the draw buffers we want to create
  27395. */
  27396. types?: number[];
  27397. /**
  27398. * Define the sampling modes of all the draw buffers we want to create
  27399. */
  27400. samplingModes?: number[];
  27401. /**
  27402. * Define if a depth buffer is required
  27403. */
  27404. generateDepthBuffer?: boolean;
  27405. /**
  27406. * Define if a stencil buffer is required
  27407. */
  27408. generateStencilBuffer?: boolean;
  27409. /**
  27410. * Define if a depth texture is required instead of a depth buffer
  27411. */
  27412. generateDepthTexture?: boolean;
  27413. /**
  27414. * Define the number of desired draw buffers
  27415. */
  27416. textureCount?: number;
  27417. /**
  27418. * Define if aspect ratio should be adapted to the texture or stay the scene one
  27419. */
  27420. doNotChangeAspectRatio?: boolean;
  27421. /**
  27422. * Define the default type of the buffers we are creating
  27423. */
  27424. defaultType?: number;
  27425. }
  27426. /**
  27427. * A multi render target, like a render target provides the ability to render to a texture.
  27428. * Unlike the render target, it can render to several draw buffers in one draw.
  27429. * This is specially interesting in deferred rendering or for any effects requiring more than
  27430. * just one color from a single pass.
  27431. */
  27432. export class MultiRenderTarget extends RenderTargetTexture {
  27433. private _internalTextures;
  27434. private _textures;
  27435. private _multiRenderTargetOptions;
  27436. /**
  27437. * Get if draw buffers are currently supported by the used hardware and browser.
  27438. */
  27439. readonly isSupported: boolean;
  27440. /**
  27441. * Get the list of textures generated by the multi render target.
  27442. */
  27443. readonly textures: Texture[];
  27444. /**
  27445. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  27446. */
  27447. readonly depthTexture: Texture;
  27448. /**
  27449. * Set the wrapping mode on U of all the textures we are rendering to.
  27450. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  27451. */
  27452. wrapU: number;
  27453. /**
  27454. * Set the wrapping mode on V of all the textures we are rendering to.
  27455. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  27456. */
  27457. wrapV: number;
  27458. /**
  27459. * Instantiate a new multi render target texture.
  27460. * A multi render target, like a render target provides the ability to render to a texture.
  27461. * Unlike the render target, it can render to several draw buffers in one draw.
  27462. * This is specially interesting in deferred rendering or for any effects requiring more than
  27463. * just one color from a single pass.
  27464. * @param name Define the name of the texture
  27465. * @param size Define the size of the buffers to render to
  27466. * @param count Define the number of target we are rendering into
  27467. * @param scene Define the scene the texture belongs to
  27468. * @param options Define the options used to create the multi render target
  27469. */
  27470. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  27471. /** @hidden */
  27472. _rebuild(): void;
  27473. private _createInternalTextures;
  27474. private _createTextures;
  27475. /**
  27476. * Define the number of samples used if MSAA is enabled.
  27477. */
  27478. samples: number;
  27479. /**
  27480. * Resize all the textures in the multi render target.
  27481. * Be carrefull as it will recreate all the data in the new texture.
  27482. * @param size Define the new size
  27483. */
  27484. resize(size: any): void;
  27485. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  27486. /**
  27487. * Dispose the render targets and their associated resources
  27488. */
  27489. dispose(): void;
  27490. /**
  27491. * Release all the underlying texture used as draw buffers.
  27492. */
  27493. releaseInternalTextures(): void;
  27494. }
  27495. }
  27496. declare module "babylonjs/Audio/analyser" {
  27497. import { Scene } from "babylonjs/scene";
  27498. /**
  27499. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27501. */
  27502. export class Analyser {
  27503. /**
  27504. * Gets or sets the smoothing
  27505. * @ignorenaming
  27506. */
  27507. SMOOTHING: number;
  27508. /**
  27509. * Gets or sets the FFT table size
  27510. * @ignorenaming
  27511. */
  27512. FFT_SIZE: number;
  27513. /**
  27514. * Gets or sets the bar graph amplitude
  27515. * @ignorenaming
  27516. */
  27517. BARGRAPHAMPLITUDE: number;
  27518. /**
  27519. * Gets or sets the position of the debug canvas
  27520. * @ignorenaming
  27521. */
  27522. DEBUGCANVASPOS: {
  27523. x: number;
  27524. y: number;
  27525. };
  27526. /**
  27527. * Gets or sets the debug canvas size
  27528. * @ignorenaming
  27529. */
  27530. DEBUGCANVASSIZE: {
  27531. width: number;
  27532. height: number;
  27533. };
  27534. private _byteFreqs;
  27535. private _byteTime;
  27536. private _floatFreqs;
  27537. private _webAudioAnalyser;
  27538. private _debugCanvas;
  27539. private _debugCanvasContext;
  27540. private _scene;
  27541. private _registerFunc;
  27542. private _audioEngine;
  27543. /**
  27544. * Creates a new analyser
  27545. * @param scene defines hosting scene
  27546. */
  27547. constructor(scene: Scene);
  27548. /**
  27549. * Get the number of data values you will have to play with for the visualization
  27550. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27551. * @returns a number
  27552. */
  27553. getFrequencyBinCount(): number;
  27554. /**
  27555. * Gets the current frequency data as a byte array
  27556. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27557. * @returns a Uint8Array
  27558. */
  27559. getByteFrequencyData(): Uint8Array;
  27560. /**
  27561. * Gets the current waveform as a byte array
  27562. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27563. * @returns a Uint8Array
  27564. */
  27565. getByteTimeDomainData(): Uint8Array;
  27566. /**
  27567. * Gets the current frequency data as a float array
  27568. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27569. * @returns a Float32Array
  27570. */
  27571. getFloatFrequencyData(): Float32Array;
  27572. /**
  27573. * Renders the debug canvas
  27574. */
  27575. drawDebugCanvas(): void;
  27576. /**
  27577. * Stops rendering the debug canvas and removes it
  27578. */
  27579. stopDebugCanvas(): void;
  27580. /**
  27581. * Connects two audio nodes
  27582. * @param inputAudioNode defines first node to connect
  27583. * @param outputAudioNode defines second node to connect
  27584. */
  27585. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27586. /**
  27587. * Releases all associated resources
  27588. */
  27589. dispose(): void;
  27590. }
  27591. }
  27592. declare module "babylonjs/Audio/audioEngine" {
  27593. import { IDisposable } from "babylonjs/scene";
  27594. import { Analyser } from "babylonjs/Audio/analyser";
  27595. import { Nullable } from "babylonjs/types";
  27596. import { Observable } from "babylonjs/Misc/observable";
  27597. /**
  27598. * This represents an audio engine and it is responsible
  27599. * to play, synchronize and analyse sounds throughout the application.
  27600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27601. */
  27602. export interface IAudioEngine extends IDisposable {
  27603. /**
  27604. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27605. */
  27606. readonly canUseWebAudio: boolean;
  27607. /**
  27608. * Gets the current AudioContext if available.
  27609. */
  27610. readonly audioContext: Nullable<AudioContext>;
  27611. /**
  27612. * The master gain node defines the global audio volume of your audio engine.
  27613. */
  27614. readonly masterGain: GainNode;
  27615. /**
  27616. * Gets whether or not mp3 are supported by your browser.
  27617. */
  27618. readonly isMP3supported: boolean;
  27619. /**
  27620. * Gets whether or not ogg are supported by your browser.
  27621. */
  27622. readonly isOGGsupported: boolean;
  27623. /**
  27624. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27625. * @ignoreNaming
  27626. */
  27627. WarnedWebAudioUnsupported: boolean;
  27628. /**
  27629. * Defines if the audio engine relies on a custom unlocked button.
  27630. * In this case, the embedded button will not be displayed.
  27631. */
  27632. useCustomUnlockedButton: boolean;
  27633. /**
  27634. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27635. */
  27636. readonly unlocked: boolean;
  27637. /**
  27638. * Event raised when audio has been unlocked on the browser.
  27639. */
  27640. onAudioUnlockedObservable: Observable<AudioEngine>;
  27641. /**
  27642. * Event raised when audio has been locked on the browser.
  27643. */
  27644. onAudioLockedObservable: Observable<AudioEngine>;
  27645. /**
  27646. * Flags the audio engine in Locked state.
  27647. * This happens due to new browser policies preventing audio to autoplay.
  27648. */
  27649. lock(): void;
  27650. /**
  27651. * Unlocks the audio engine once a user action has been done on the dom.
  27652. * This is helpful to resume play once browser policies have been satisfied.
  27653. */
  27654. unlock(): void;
  27655. }
  27656. /**
  27657. * This represents the default audio engine used in babylon.
  27658. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27660. */
  27661. export class AudioEngine implements IAudioEngine {
  27662. private _audioContext;
  27663. private _audioContextInitialized;
  27664. private _muteButton;
  27665. private _hostElement;
  27666. /**
  27667. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27668. */
  27669. canUseWebAudio: boolean;
  27670. /**
  27671. * The master gain node defines the global audio volume of your audio engine.
  27672. */
  27673. masterGain: GainNode;
  27674. /**
  27675. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27676. * @ignoreNaming
  27677. */
  27678. WarnedWebAudioUnsupported: boolean;
  27679. /**
  27680. * Gets whether or not mp3 are supported by your browser.
  27681. */
  27682. isMP3supported: boolean;
  27683. /**
  27684. * Gets whether or not ogg are supported by your browser.
  27685. */
  27686. isOGGsupported: boolean;
  27687. /**
  27688. * Gets whether audio has been unlocked on the device.
  27689. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27690. * a user interaction has happened.
  27691. */
  27692. unlocked: boolean;
  27693. /**
  27694. * Defines if the audio engine relies on a custom unlocked button.
  27695. * In this case, the embedded button will not be displayed.
  27696. */
  27697. useCustomUnlockedButton: boolean;
  27698. /**
  27699. * Event raised when audio has been unlocked on the browser.
  27700. */
  27701. onAudioUnlockedObservable: Observable<AudioEngine>;
  27702. /**
  27703. * Event raised when audio has been locked on the browser.
  27704. */
  27705. onAudioLockedObservable: Observable<AudioEngine>;
  27706. /**
  27707. * Gets the current AudioContext if available.
  27708. */
  27709. readonly audioContext: Nullable<AudioContext>;
  27710. private _connectedAnalyser;
  27711. /**
  27712. * Instantiates a new audio engine.
  27713. *
  27714. * There should be only one per page as some browsers restrict the number
  27715. * of audio contexts you can create.
  27716. * @param hostElement defines the host element where to display the mute icon if necessary
  27717. */
  27718. constructor(hostElement?: Nullable<HTMLElement>);
  27719. /**
  27720. * Flags the audio engine in Locked state.
  27721. * This happens due to new browser policies preventing audio to autoplay.
  27722. */
  27723. lock(): void;
  27724. /**
  27725. * Unlocks the audio engine once a user action has been done on the dom.
  27726. * This is helpful to resume play once browser policies have been satisfied.
  27727. */
  27728. unlock(): void;
  27729. private _resumeAudioContext;
  27730. private _initializeAudioContext;
  27731. private _tryToRun;
  27732. private _triggerRunningState;
  27733. private _triggerSuspendedState;
  27734. private _displayMuteButton;
  27735. private _moveButtonToTopLeft;
  27736. private _onResize;
  27737. private _hideMuteButton;
  27738. /**
  27739. * Destroy and release the resources associated with the audio ccontext.
  27740. */
  27741. dispose(): void;
  27742. /**
  27743. * Gets the global volume sets on the master gain.
  27744. * @returns the global volume if set or -1 otherwise
  27745. */
  27746. getGlobalVolume(): number;
  27747. /**
  27748. * Sets the global volume of your experience (sets on the master gain).
  27749. * @param newVolume Defines the new global volume of the application
  27750. */
  27751. setGlobalVolume(newVolume: number): void;
  27752. /**
  27753. * Connect the audio engine to an audio analyser allowing some amazing
  27754. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27756. * @param analyser The analyser to connect to the engine
  27757. */
  27758. connectToAnalyser(analyser: Analyser): void;
  27759. }
  27760. }
  27761. declare module "babylonjs/Loading/loadingScreen" {
  27762. /**
  27763. * Interface used to present a loading screen while loading a scene
  27764. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27765. */
  27766. export interface ILoadingScreen {
  27767. /**
  27768. * Function called to display the loading screen
  27769. */
  27770. displayLoadingUI: () => void;
  27771. /**
  27772. * Function called to hide the loading screen
  27773. */
  27774. hideLoadingUI: () => void;
  27775. /**
  27776. * Gets or sets the color to use for the background
  27777. */
  27778. loadingUIBackgroundColor: string;
  27779. /**
  27780. * Gets or sets the text to display while loading
  27781. */
  27782. loadingUIText: string;
  27783. }
  27784. /**
  27785. * Class used for the default loading screen
  27786. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27787. */
  27788. export class DefaultLoadingScreen implements ILoadingScreen {
  27789. private _renderingCanvas;
  27790. private _loadingText;
  27791. private _loadingDivBackgroundColor;
  27792. private _loadingDiv;
  27793. private _loadingTextDiv;
  27794. /**
  27795. * Creates a new default loading screen
  27796. * @param _renderingCanvas defines the canvas used to render the scene
  27797. * @param _loadingText defines the default text to display
  27798. * @param _loadingDivBackgroundColor defines the default background color
  27799. */
  27800. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27801. /**
  27802. * Function called to display the loading screen
  27803. */
  27804. displayLoadingUI(): void;
  27805. /**
  27806. * Function called to hide the loading screen
  27807. */
  27808. hideLoadingUI(): void;
  27809. /**
  27810. * Gets or sets the text to display while loading
  27811. */
  27812. loadingUIText: string;
  27813. /**
  27814. * Gets or sets the color to use for the background
  27815. */
  27816. loadingUIBackgroundColor: string;
  27817. private _resizeLoadingUI;
  27818. }
  27819. }
  27820. declare module "babylonjs/Materials/Textures/videoTexture" {
  27821. import { Observable } from "babylonjs/Misc/observable";
  27822. import { Nullable } from "babylonjs/types";
  27823. import { Scene } from "babylonjs/scene";
  27824. import { Texture } from "babylonjs/Materials/Textures/texture";
  27825. /**
  27826. * Settings for finer control over video usage
  27827. */
  27828. export interface VideoTextureSettings {
  27829. /**
  27830. * Applies `autoplay` to video, if specified
  27831. */
  27832. autoPlay?: boolean;
  27833. /**
  27834. * Applies `loop` to video, if specified
  27835. */
  27836. loop?: boolean;
  27837. /**
  27838. * Automatically updates internal texture from video at every frame in the render loop
  27839. */
  27840. autoUpdateTexture: boolean;
  27841. /**
  27842. * Image src displayed during the video loading or until the user interacts with the video.
  27843. */
  27844. poster?: string;
  27845. }
  27846. /**
  27847. * If you want to display a video in your scene, this is the special texture for that.
  27848. * This special texture works similar to other textures, with the exception of a few parameters.
  27849. * @see https://doc.babylonjs.com/how_to/video_texture
  27850. */
  27851. export class VideoTexture extends Texture {
  27852. /**
  27853. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27854. */
  27855. readonly autoUpdateTexture: boolean;
  27856. /**
  27857. * The video instance used by the texture internally
  27858. */
  27859. readonly video: HTMLVideoElement;
  27860. private _onUserActionRequestedObservable;
  27861. /**
  27862. * Event triggerd when a dom action is required by the user to play the video.
  27863. * This happens due to recent changes in browser policies preventing video to auto start.
  27864. */
  27865. readonly onUserActionRequestedObservable: Observable<Texture>;
  27866. private _generateMipMaps;
  27867. private _engine;
  27868. private _stillImageCaptured;
  27869. private _displayingPosterTexture;
  27870. private _settings;
  27871. private _createInternalTextureOnEvent;
  27872. /**
  27873. * Creates a video texture.
  27874. * If you want to display a video in your scene, this is the special texture for that.
  27875. * This special texture works similar to other textures, with the exception of a few parameters.
  27876. * @see https://doc.babylonjs.com/how_to/video_texture
  27877. * @param name optional name, will detect from video source, if not defined
  27878. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27879. * @param scene is obviously the current scene.
  27880. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27881. * @param invertY is false by default but can be used to invert video on Y axis
  27882. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27883. * @param settings allows finer control over video usage
  27884. */
  27885. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27886. private _getName;
  27887. private _getVideo;
  27888. private _createInternalTexture;
  27889. private reset;
  27890. /**
  27891. * @hidden Internal method to initiate `update`.
  27892. */
  27893. _rebuild(): void;
  27894. /**
  27895. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27896. */
  27897. update(): void;
  27898. /**
  27899. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27900. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27901. */
  27902. updateTexture(isVisible: boolean): void;
  27903. protected _updateInternalTexture: () => void;
  27904. /**
  27905. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27906. * @param url New url.
  27907. */
  27908. updateURL(url: string): void;
  27909. /**
  27910. * Dispose the texture and release its associated resources.
  27911. */
  27912. dispose(): void;
  27913. /**
  27914. * Creates a video texture straight from your WebCam video feed.
  27915. * @param scene Define the scene the texture should be created in
  27916. * @param onReady Define a callback to triggered once the texture will be ready
  27917. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27918. */
  27919. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27920. minWidth: number;
  27921. maxWidth: number;
  27922. minHeight: number;
  27923. maxHeight: number;
  27924. deviceId: string;
  27925. }): void;
  27926. }
  27927. }
  27928. declare module "babylonjs/Engines/engine" {
  27929. import { Observable } from "babylonjs/Misc/observable";
  27930. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27931. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27932. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27933. import { Camera } from "babylonjs/Cameras/camera";
  27934. import { Scene } from "babylonjs/scene";
  27935. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27936. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27937. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27938. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27939. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27940. import { Material } from "babylonjs/Materials/material";
  27941. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27942. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27943. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27944. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27945. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27946. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27947. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27948. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27949. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27950. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27951. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27952. /**
  27953. * Interface for attribute information associated with buffer instanciation
  27954. */
  27955. export class InstancingAttributeInfo {
  27956. /**
  27957. * Index/offset of the attribute in the vertex shader
  27958. */
  27959. index: number;
  27960. /**
  27961. * size of the attribute, 1, 2, 3 or 4
  27962. */
  27963. attributeSize: number;
  27964. /**
  27965. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27966. * default is FLOAT
  27967. */
  27968. attribyteType: number;
  27969. /**
  27970. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27971. */
  27972. normalized: boolean;
  27973. /**
  27974. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27975. */
  27976. offset: number;
  27977. /**
  27978. * Name of the GLSL attribute, for debugging purpose only
  27979. */
  27980. attributeName: string;
  27981. }
  27982. /**
  27983. * Define options used to create a depth texture
  27984. */
  27985. export class DepthTextureCreationOptions {
  27986. /** Specifies whether or not a stencil should be allocated in the texture */
  27987. generateStencil?: boolean;
  27988. /** Specifies whether or not bilinear filtering is enable on the texture */
  27989. bilinearFiltering?: boolean;
  27990. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27991. comparisonFunction?: number;
  27992. /** Specifies if the created texture is a cube texture */
  27993. isCube?: boolean;
  27994. }
  27995. /**
  27996. * Class used to describe the capabilities of the engine relatively to the current browser
  27997. */
  27998. export class EngineCapabilities {
  27999. /** Maximum textures units per fragment shader */
  28000. maxTexturesImageUnits: number;
  28001. /** Maximum texture units per vertex shader */
  28002. maxVertexTextureImageUnits: number;
  28003. /** Maximum textures units in the entire pipeline */
  28004. maxCombinedTexturesImageUnits: number;
  28005. /** Maximum texture size */
  28006. maxTextureSize: number;
  28007. /** Maximum cube texture size */
  28008. maxCubemapTextureSize: number;
  28009. /** Maximum render texture size */
  28010. maxRenderTextureSize: number;
  28011. /** Maximum number of vertex attributes */
  28012. maxVertexAttribs: number;
  28013. /** Maximum number of varyings */
  28014. maxVaryingVectors: number;
  28015. /** Maximum number of uniforms per vertex shader */
  28016. maxVertexUniformVectors: number;
  28017. /** Maximum number of uniforms per fragment shader */
  28018. maxFragmentUniformVectors: number;
  28019. /** Defines if standard derivates (dx/dy) are supported */
  28020. standardDerivatives: boolean;
  28021. /** Defines if s3tc texture compression is supported */
  28022. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28023. /** Defines if pvrtc texture compression is supported */
  28024. pvrtc: any;
  28025. /** Defines if etc1 texture compression is supported */
  28026. etc1: any;
  28027. /** Defines if etc2 texture compression is supported */
  28028. etc2: any;
  28029. /** Defines if astc texture compression is supported */
  28030. astc: any;
  28031. /** Defines if float textures are supported */
  28032. textureFloat: boolean;
  28033. /** Defines if vertex array objects are supported */
  28034. vertexArrayObject: boolean;
  28035. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28036. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28037. /** Gets the maximum level of anisotropy supported */
  28038. maxAnisotropy: number;
  28039. /** Defines if instancing is supported */
  28040. instancedArrays: boolean;
  28041. /** Defines if 32 bits indices are supported */
  28042. uintIndices: boolean;
  28043. /** Defines if high precision shaders are supported */
  28044. highPrecisionShaderSupported: boolean;
  28045. /** Defines if depth reading in the fragment shader is supported */
  28046. fragmentDepthSupported: boolean;
  28047. /** Defines if float texture linear filtering is supported*/
  28048. textureFloatLinearFiltering: boolean;
  28049. /** Defines if rendering to float textures is supported */
  28050. textureFloatRender: boolean;
  28051. /** Defines if half float textures are supported*/
  28052. textureHalfFloat: boolean;
  28053. /** Defines if half float texture linear filtering is supported*/
  28054. textureHalfFloatLinearFiltering: boolean;
  28055. /** Defines if rendering to half float textures is supported */
  28056. textureHalfFloatRender: boolean;
  28057. /** Defines if textureLOD shader command is supported */
  28058. textureLOD: boolean;
  28059. /** Defines if draw buffers extension is supported */
  28060. drawBuffersExtension: boolean;
  28061. /** Defines if depth textures are supported */
  28062. depthTextureExtension: boolean;
  28063. /** Defines if float color buffer are supported */
  28064. colorBufferFloat: boolean;
  28065. /** Gets disjoint timer query extension (null if not supported) */
  28066. timerQuery: EXT_disjoint_timer_query;
  28067. /** Defines if timestamp can be used with timer query */
  28068. canUseTimestampForTimerQuery: boolean;
  28069. /** Function used to let the system compiles shaders in background */
  28070. parallelShaderCompile: {
  28071. MAX_SHADER_COMPILER_THREADS_KHR: number;
  28072. maxShaderCompilerThreadsKHR: (thread: number) => void;
  28073. COMPLETION_STATUS_KHR: number;
  28074. };
  28075. }
  28076. /** Interface defining initialization parameters for Engine class */
  28077. export interface EngineOptions extends WebGLContextAttributes {
  28078. /**
  28079. * Defines if the engine should no exceed a specified device ratio
  28080. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28081. */
  28082. limitDeviceRatio?: number;
  28083. /**
  28084. * Defines if webvr should be enabled automatically
  28085. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28086. */
  28087. autoEnableWebVR?: boolean;
  28088. /**
  28089. * Defines if webgl2 should be turned off even if supported
  28090. * @see http://doc.babylonjs.com/features/webgl2
  28091. */
  28092. disableWebGL2Support?: boolean;
  28093. /**
  28094. * Defines if webaudio should be initialized as well
  28095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28096. */
  28097. audioEngine?: boolean;
  28098. /**
  28099. * Defines if animations should run using a deterministic lock step
  28100. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28101. */
  28102. deterministicLockstep?: boolean;
  28103. /** Defines the maximum steps to use with deterministic lock step mode */
  28104. lockstepMaxSteps?: number;
  28105. /**
  28106. * Defines that engine should ignore context lost events
  28107. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28108. */
  28109. doNotHandleContextLost?: boolean;
  28110. /**
  28111. * Defines that engine should ignore modifying touch action attribute and style
  28112. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28113. */
  28114. doNotHandleTouchAction?: boolean;
  28115. }
  28116. /**
  28117. * Defines the interface used by display changed events
  28118. */
  28119. export interface IDisplayChangedEventArgs {
  28120. /** Gets the vrDisplay object (if any) */
  28121. vrDisplay: Nullable<any>;
  28122. /** Gets a boolean indicating if webVR is supported */
  28123. vrSupported: boolean;
  28124. }
  28125. /**
  28126. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28127. */
  28128. export class Engine {
  28129. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28130. static ExceptionList: ({
  28131. key: string;
  28132. capture: string;
  28133. captureConstraint: number;
  28134. targets: string[];
  28135. } | {
  28136. key: string;
  28137. capture: null;
  28138. captureConstraint: null;
  28139. targets: string[];
  28140. })[];
  28141. /** Gets the list of created engines */
  28142. static readonly Instances: Engine[];
  28143. /**
  28144. * Gets the latest created engine
  28145. */
  28146. static readonly LastCreatedEngine: Nullable<Engine>;
  28147. /**
  28148. * Gets the latest created scene
  28149. */
  28150. static readonly LastCreatedScene: Nullable<Scene>;
  28151. /**
  28152. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28153. * @param flag defines which part of the materials must be marked as dirty
  28154. * @param predicate defines a predicate used to filter which materials should be affected
  28155. */
  28156. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28157. /**
  28158. * Hidden
  28159. */
  28160. static _TextureLoaders: IInternalTextureLoader[];
  28161. /** Defines that alpha blending is disabled */
  28162. static readonly ALPHA_DISABLE: number;
  28163. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28164. static readonly ALPHA_ADD: number;
  28165. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28166. static readonly ALPHA_COMBINE: number;
  28167. /** Defines that alpha blending to DEST - SRC * DEST */
  28168. static readonly ALPHA_SUBTRACT: number;
  28169. /** Defines that alpha blending to SRC * DEST */
  28170. static readonly ALPHA_MULTIPLY: number;
  28171. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28172. static readonly ALPHA_MAXIMIZED: number;
  28173. /** Defines that alpha blending to SRC + DEST */
  28174. static readonly ALPHA_ONEONE: number;
  28175. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28176. static readonly ALPHA_PREMULTIPLIED: number;
  28177. /**
  28178. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28179. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28180. */
  28181. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28182. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28183. static readonly ALPHA_INTERPOLATE: number;
  28184. /**
  28185. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28186. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28187. */
  28188. static readonly ALPHA_SCREENMODE: number;
  28189. /** Defines that the ressource is not delayed*/
  28190. static readonly DELAYLOADSTATE_NONE: number;
  28191. /** Defines that the ressource was successfully delay loaded */
  28192. static readonly DELAYLOADSTATE_LOADED: number;
  28193. /** Defines that the ressource is currently delay loading */
  28194. static readonly DELAYLOADSTATE_LOADING: number;
  28195. /** Defines that the ressource is delayed and has not started loading */
  28196. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28197. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28198. static readonly NEVER: number;
  28199. /** 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 */
  28200. static readonly ALWAYS: number;
  28201. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28202. static readonly LESS: number;
  28203. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28204. static readonly EQUAL: number;
  28205. /** 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 */
  28206. static readonly LEQUAL: number;
  28207. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28208. static readonly GREATER: number;
  28209. /** 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 */
  28210. static readonly GEQUAL: number;
  28211. /** 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 */
  28212. static readonly NOTEQUAL: number;
  28213. /** Passed to stencilOperation to specify that stencil value must be kept */
  28214. static readonly KEEP: number;
  28215. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28216. static readonly REPLACE: number;
  28217. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28218. static readonly INCR: number;
  28219. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28220. static readonly DECR: number;
  28221. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28222. static readonly INVERT: number;
  28223. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28224. static readonly INCR_WRAP: number;
  28225. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28226. static readonly DECR_WRAP: number;
  28227. /** Texture is not repeating outside of 0..1 UVs */
  28228. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28229. /** Texture is repeating outside of 0..1 UVs */
  28230. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28231. /** Texture is repeating and mirrored */
  28232. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28233. /** ALPHA */
  28234. static readonly TEXTUREFORMAT_ALPHA: number;
  28235. /** LUMINANCE */
  28236. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28237. /** LUMINANCE_ALPHA */
  28238. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28239. /** RGB */
  28240. static readonly TEXTUREFORMAT_RGB: number;
  28241. /** RGBA */
  28242. static readonly TEXTUREFORMAT_RGBA: number;
  28243. /** RED */
  28244. static readonly TEXTUREFORMAT_RED: number;
  28245. /** RED (2nd reference) */
  28246. static readonly TEXTUREFORMAT_R: number;
  28247. /** RG */
  28248. static readonly TEXTUREFORMAT_RG: number;
  28249. /** RED_INTEGER */
  28250. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28251. /** RED_INTEGER (2nd reference) */
  28252. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28253. /** RG_INTEGER */
  28254. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28255. /** RGB_INTEGER */
  28256. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28257. /** RGBA_INTEGER */
  28258. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28259. /** UNSIGNED_BYTE */
  28260. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28261. /** UNSIGNED_BYTE (2nd reference) */
  28262. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28263. /** FLOAT */
  28264. static readonly TEXTURETYPE_FLOAT: number;
  28265. /** HALF_FLOAT */
  28266. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28267. /** BYTE */
  28268. static readonly TEXTURETYPE_BYTE: number;
  28269. /** SHORT */
  28270. static readonly TEXTURETYPE_SHORT: number;
  28271. /** UNSIGNED_SHORT */
  28272. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28273. /** INT */
  28274. static readonly TEXTURETYPE_INT: number;
  28275. /** UNSIGNED_INT */
  28276. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28277. /** UNSIGNED_SHORT_4_4_4_4 */
  28278. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28279. /** UNSIGNED_SHORT_5_5_5_1 */
  28280. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28281. /** UNSIGNED_SHORT_5_6_5 */
  28282. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28283. /** UNSIGNED_INT_2_10_10_10_REV */
  28284. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28285. /** UNSIGNED_INT_24_8 */
  28286. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28287. /** UNSIGNED_INT_10F_11F_11F_REV */
  28288. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28289. /** UNSIGNED_INT_5_9_9_9_REV */
  28290. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28291. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28292. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28293. /** nearest is mag = nearest and min = nearest and mip = linear */
  28294. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28295. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28296. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28297. /** Trilinear is mag = linear and min = linear and mip = linear */
  28298. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28299. /** nearest is mag = nearest and min = nearest and mip = linear */
  28300. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28301. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28302. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28303. /** Trilinear is mag = linear and min = linear and mip = linear */
  28304. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28305. /** mag = nearest and min = nearest and mip = nearest */
  28306. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28307. /** mag = nearest and min = linear and mip = nearest */
  28308. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28309. /** mag = nearest and min = linear and mip = linear */
  28310. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28311. /** mag = nearest and min = linear and mip = none */
  28312. static readonly TEXTURE_NEAREST_LINEAR: number;
  28313. /** mag = nearest and min = nearest and mip = none */
  28314. static readonly TEXTURE_NEAREST_NEAREST: number;
  28315. /** mag = linear and min = nearest and mip = nearest */
  28316. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28317. /** mag = linear and min = nearest and mip = linear */
  28318. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28319. /** mag = linear and min = linear and mip = none */
  28320. static readonly TEXTURE_LINEAR_LINEAR: number;
  28321. /** mag = linear and min = nearest and mip = none */
  28322. static readonly TEXTURE_LINEAR_NEAREST: number;
  28323. /** Explicit coordinates mode */
  28324. static readonly TEXTURE_EXPLICIT_MODE: number;
  28325. /** Spherical coordinates mode */
  28326. static readonly TEXTURE_SPHERICAL_MODE: number;
  28327. /** Planar coordinates mode */
  28328. static readonly TEXTURE_PLANAR_MODE: number;
  28329. /** Cubic coordinates mode */
  28330. static readonly TEXTURE_CUBIC_MODE: number;
  28331. /** Projection coordinates mode */
  28332. static readonly TEXTURE_PROJECTION_MODE: number;
  28333. /** Skybox coordinates mode */
  28334. static readonly TEXTURE_SKYBOX_MODE: number;
  28335. /** Inverse Cubic coordinates mode */
  28336. static readonly TEXTURE_INVCUBIC_MODE: number;
  28337. /** Equirectangular coordinates mode */
  28338. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28339. /** Equirectangular Fixed coordinates mode */
  28340. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28341. /** Equirectangular Fixed Mirrored coordinates mode */
  28342. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28343. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28344. static readonly SCALEMODE_FLOOR: number;
  28345. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28346. static readonly SCALEMODE_NEAREST: number;
  28347. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28348. static readonly SCALEMODE_CEILING: number;
  28349. /**
  28350. * Returns the current version of the framework
  28351. */
  28352. static readonly Version: string;
  28353. /**
  28354. * Returns a string describing the current engine
  28355. */
  28356. readonly description: string;
  28357. /**
  28358. * Gets or sets the epsilon value used by collision engine
  28359. */
  28360. static CollisionsEpsilon: number;
  28361. /**
  28362. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28363. */
  28364. static ShadersRepository: string;
  28365. /**
  28366. * Method called to create the default loading screen.
  28367. * This can be overriden in your own app.
  28368. * @param canvas The rendering canvas element
  28369. * @returns The loading screen
  28370. */
  28371. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28372. /**
  28373. * Method called to create the default rescale post process on each engine.
  28374. */
  28375. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28376. /**
  28377. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28378. */
  28379. forcePOTTextures: boolean;
  28380. /**
  28381. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28382. */
  28383. isFullscreen: boolean;
  28384. /**
  28385. * Gets a boolean indicating if the pointer is currently locked
  28386. */
  28387. isPointerLock: boolean;
  28388. /**
  28389. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28390. */
  28391. cullBackFaces: boolean;
  28392. /**
  28393. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28394. */
  28395. renderEvenInBackground: boolean;
  28396. /**
  28397. * Gets or sets a boolean indicating that cache can be kept between frames
  28398. */
  28399. preventCacheWipeBetweenFrames: boolean;
  28400. /**
  28401. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28402. **/
  28403. enableOfflineSupport: boolean;
  28404. /**
  28405. * 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)
  28406. **/
  28407. disableManifestCheck: boolean;
  28408. /**
  28409. * Gets the list of created scenes
  28410. */
  28411. scenes: Scene[];
  28412. /**
  28413. * Event raised when a new scene is created
  28414. */
  28415. onNewSceneAddedObservable: Observable<Scene>;
  28416. /**
  28417. * Gets the list of created postprocesses
  28418. */
  28419. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28420. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28421. validateShaderPrograms: boolean;
  28422. /**
  28423. * Observable event triggered each time the rendering canvas is resized
  28424. */
  28425. onResizeObservable: Observable<Engine>;
  28426. /**
  28427. * Observable event triggered each time the canvas loses focus
  28428. */
  28429. onCanvasBlurObservable: Observable<Engine>;
  28430. /**
  28431. * Observable event triggered each time the canvas gains focus
  28432. */
  28433. onCanvasFocusObservable: Observable<Engine>;
  28434. /**
  28435. * Observable event triggered each time the canvas receives pointerout event
  28436. */
  28437. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28438. /**
  28439. * Observable event triggered before each texture is initialized
  28440. */
  28441. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28442. private _vrDisplay;
  28443. private _vrSupported;
  28444. private _oldSize;
  28445. private _oldHardwareScaleFactor;
  28446. private _vrExclusivePointerMode;
  28447. private _webVRInitPromise;
  28448. /**
  28449. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28450. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28451. */
  28452. readonly isInVRExclusivePointerMode: boolean;
  28453. /**
  28454. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28455. */
  28456. disableUniformBuffers: boolean;
  28457. /** @hidden */
  28458. _uniformBuffers: UniformBuffer[];
  28459. /**
  28460. * Gets a boolean indicating that the engine supports uniform buffers
  28461. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28462. */
  28463. readonly supportsUniformBuffers: boolean;
  28464. /**
  28465. * Observable raised when the engine begins a new frame
  28466. */
  28467. onBeginFrameObservable: Observable<Engine>;
  28468. /**
  28469. * If set, will be used to request the next animation frame for the render loop
  28470. */
  28471. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28472. /**
  28473. * Observable raised when the engine ends the current frame
  28474. */
  28475. onEndFrameObservable: Observable<Engine>;
  28476. /**
  28477. * Observable raised when the engine is about to compile a shader
  28478. */
  28479. onBeforeShaderCompilationObservable: Observable<Engine>;
  28480. /**
  28481. * Observable raised when the engine has jsut compiled a shader
  28482. */
  28483. onAfterShaderCompilationObservable: Observable<Engine>;
  28484. /** @hidden */
  28485. _gl: WebGLRenderingContext;
  28486. private _renderingCanvas;
  28487. private _windowIsBackground;
  28488. private _webGLVersion;
  28489. /**
  28490. * Gets a boolean indicating that only power of 2 textures are supported
  28491. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28492. */
  28493. readonly needPOTTextures: boolean;
  28494. /** @hidden */
  28495. _badOS: boolean;
  28496. /** @hidden */
  28497. _badDesktopOS: boolean;
  28498. /**
  28499. * Gets or sets a value indicating if we want to disable texture binding optimization.
  28500. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  28501. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  28502. */
  28503. disableTextureBindingOptimization: boolean;
  28504. /**
  28505. * Gets the audio engine
  28506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28507. * @ignorenaming
  28508. */
  28509. static audioEngine: IAudioEngine;
  28510. /**
  28511. * Default AudioEngine factory responsible of creating the Audio Engine.
  28512. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28513. */
  28514. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28515. /**
  28516. * Default offline support factory responsible of creating a tool used to store data locally.
  28517. * By default, this will create a Database object if the workload has been embedded.
  28518. */
  28519. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28520. private _onFocus;
  28521. private _onBlur;
  28522. private _onCanvasPointerOut;
  28523. private _onCanvasBlur;
  28524. private _onCanvasFocus;
  28525. private _onFullscreenChange;
  28526. private _onPointerLockChange;
  28527. private _onVRDisplayPointerRestricted;
  28528. private _onVRDisplayPointerUnrestricted;
  28529. private _onVrDisplayConnect;
  28530. private _onVrDisplayDisconnect;
  28531. private _onVrDisplayPresentChange;
  28532. /**
  28533. * Observable signaled when VR display mode changes
  28534. */
  28535. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28536. /**
  28537. * Observable signaled when VR request present is complete
  28538. */
  28539. onVRRequestPresentComplete: Observable<boolean>;
  28540. /**
  28541. * Observable signaled when VR request present starts
  28542. */
  28543. onVRRequestPresentStart: Observable<Engine>;
  28544. private _hardwareScalingLevel;
  28545. /** @hidden */
  28546. protected _caps: EngineCapabilities;
  28547. private _pointerLockRequested;
  28548. private _isStencilEnable;
  28549. private _colorWrite;
  28550. private _loadingScreen;
  28551. /** @hidden */
  28552. _drawCalls: PerfCounter;
  28553. /** @hidden */
  28554. _textureCollisions: PerfCounter;
  28555. private _glVersion;
  28556. private _glRenderer;
  28557. private _glVendor;
  28558. private _videoTextureSupported;
  28559. private _renderingQueueLaunched;
  28560. private _activeRenderLoops;
  28561. private _deterministicLockstep;
  28562. private _lockstepMaxSteps;
  28563. /**
  28564. * Observable signaled when a context lost event is raised
  28565. */
  28566. onContextLostObservable: Observable<Engine>;
  28567. /**
  28568. * Observable signaled when a context restored event is raised
  28569. */
  28570. onContextRestoredObservable: Observable<Engine>;
  28571. private _onContextLost;
  28572. private _onContextRestored;
  28573. private _contextWasLost;
  28574. private _doNotHandleContextLost;
  28575. /**
  28576. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28577. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28578. */
  28579. doNotHandleContextLost: boolean;
  28580. private _performanceMonitor;
  28581. private _fps;
  28582. private _deltaTime;
  28583. /**
  28584. * Turn this value on if you want to pause FPS computation when in background
  28585. */
  28586. disablePerformanceMonitorInBackground: boolean;
  28587. /**
  28588. * Gets the performance monitor attached to this engine
  28589. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28590. */
  28591. readonly performanceMonitor: PerformanceMonitor;
  28592. /** @hidden */
  28593. protected _depthCullingState: _DepthCullingState;
  28594. /** @hidden */
  28595. protected _stencilState: _StencilState;
  28596. /** @hidden */
  28597. protected _alphaState: _AlphaState;
  28598. /** @hidden */
  28599. protected _alphaMode: number;
  28600. protected _internalTexturesCache: InternalTexture[];
  28601. /** @hidden */
  28602. protected _activeChannel: number;
  28603. private _currentTextureChannel;
  28604. /** @hidden */
  28605. protected _boundTexturesCache: {
  28606. [key: string]: Nullable<InternalTexture>;
  28607. };
  28608. /** @hidden */
  28609. protected _currentEffect: Nullable<Effect>;
  28610. /** @hidden */
  28611. protected _currentProgram: Nullable<WebGLProgram>;
  28612. private _compiledEffects;
  28613. private _vertexAttribArraysEnabled;
  28614. /** @hidden */
  28615. protected _cachedViewport: Nullable<Viewport>;
  28616. private _cachedVertexArrayObject;
  28617. /** @hidden */
  28618. protected _cachedVertexBuffers: any;
  28619. /** @hidden */
  28620. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28621. /** @hidden */
  28622. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28623. /** @hidden */
  28624. protected _currentRenderTarget: Nullable<InternalTexture>;
  28625. private _uintIndicesCurrentlySet;
  28626. private _currentBoundBuffer;
  28627. /** @hidden */
  28628. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28629. private _currentBufferPointers;
  28630. private _currentInstanceLocations;
  28631. private _currentInstanceBuffers;
  28632. private _textureUnits;
  28633. private _firstBoundInternalTextureTracker;
  28634. private _lastBoundInternalTextureTracker;
  28635. private _workingCanvas;
  28636. private _workingContext;
  28637. private _rescalePostProcess;
  28638. private _dummyFramebuffer;
  28639. private _externalData;
  28640. private _bindedRenderFunction;
  28641. private _vaoRecordInProgress;
  28642. private _mustWipeVertexAttributes;
  28643. private _emptyTexture;
  28644. private _emptyCubeTexture;
  28645. private _emptyTexture3D;
  28646. /** @hidden */
  28647. _frameHandler: number;
  28648. private _nextFreeTextureSlots;
  28649. private _maxSimultaneousTextures;
  28650. private _activeRequests;
  28651. private _texturesSupported;
  28652. private _textureFormatInUse;
  28653. /**
  28654. * Gets the list of texture formats supported
  28655. */
  28656. readonly texturesSupported: Array<string>;
  28657. /**
  28658. * Gets the list of texture formats in use
  28659. */
  28660. readonly textureFormatInUse: Nullable<string>;
  28661. /**
  28662. * Gets the current viewport
  28663. */
  28664. readonly currentViewport: Nullable<Viewport>;
  28665. /**
  28666. * Gets the default empty texture
  28667. */
  28668. readonly emptyTexture: InternalTexture;
  28669. /**
  28670. * Gets the default empty 3D texture
  28671. */
  28672. readonly emptyTexture3D: InternalTexture;
  28673. /**
  28674. * Gets the default empty cube texture
  28675. */
  28676. readonly emptyCubeTexture: InternalTexture;
  28677. /**
  28678. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28679. */
  28680. readonly premultipliedAlpha: boolean;
  28681. /**
  28682. * Creates a new engine
  28683. * @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
  28684. * @param antialias defines enable antialiasing (default: false)
  28685. * @param options defines further options to be sent to the getContext() function
  28686. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28687. */
  28688. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28689. private _disableTouchAction;
  28690. private _rebuildInternalTextures;
  28691. private _rebuildEffects;
  28692. /**
  28693. * Gets a boolean indicating if all created effects are ready
  28694. * @returns true if all effects are ready
  28695. */
  28696. areAllEffectsReady(): boolean;
  28697. private _rebuildBuffers;
  28698. private _initGLContext;
  28699. /**
  28700. * Gets version of the current webGL context
  28701. */
  28702. readonly webGLVersion: number;
  28703. /**
  28704. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28705. */
  28706. readonly isStencilEnable: boolean;
  28707. private _prepareWorkingCanvas;
  28708. /**
  28709. * Reset the texture cache to empty state
  28710. */
  28711. resetTextureCache(): void;
  28712. /**
  28713. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28714. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28715. * @returns true if engine is in deterministic lock step mode
  28716. */
  28717. isDeterministicLockStep(): boolean;
  28718. /**
  28719. * Gets the max steps when engine is running in deterministic lock step
  28720. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28721. * @returns the max steps
  28722. */
  28723. getLockstepMaxSteps(): number;
  28724. /**
  28725. * Gets an object containing information about the current webGL context
  28726. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28727. */
  28728. getGlInfo(): {
  28729. vendor: string;
  28730. renderer: string;
  28731. version: string;
  28732. };
  28733. /**
  28734. * Gets current aspect ratio
  28735. * @param camera defines the camera to use to get the aspect ratio
  28736. * @param useScreen defines if screen size must be used (or the current render target if any)
  28737. * @returns a number defining the aspect ratio
  28738. */
  28739. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28740. /**
  28741. * Gets current screen aspect ratio
  28742. * @returns a number defining the aspect ratio
  28743. */
  28744. getScreenAspectRatio(): number;
  28745. /**
  28746. * Gets the current render width
  28747. * @param useScreen defines if screen size must be used (or the current render target if any)
  28748. * @returns a number defining the current render width
  28749. */
  28750. getRenderWidth(useScreen?: boolean): number;
  28751. /**
  28752. * Gets the current render height
  28753. * @param useScreen defines if screen size must be used (or the current render target if any)
  28754. * @returns a number defining the current render height
  28755. */
  28756. getRenderHeight(useScreen?: boolean): number;
  28757. /**
  28758. * Gets the HTML canvas attached with the current webGL context
  28759. * @returns a HTML canvas
  28760. */
  28761. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28762. /**
  28763. * Gets the client rect of the HTML canvas attached with the current webGL context
  28764. * @returns a client rectanglee
  28765. */
  28766. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28767. /**
  28768. * Defines the hardware scaling level.
  28769. * By default the hardware scaling level is computed from the window device ratio.
  28770. * 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.
  28771. * @param level defines the level to use
  28772. */
  28773. setHardwareScalingLevel(level: number): void;
  28774. /**
  28775. * Gets the current hardware scaling level.
  28776. * By default the hardware scaling level is computed from the window device ratio.
  28777. * 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.
  28778. * @returns a number indicating the current hardware scaling level
  28779. */
  28780. getHardwareScalingLevel(): number;
  28781. /**
  28782. * Gets the list of loaded textures
  28783. * @returns an array containing all loaded textures
  28784. */
  28785. getLoadedTexturesCache(): InternalTexture[];
  28786. /**
  28787. * Gets the object containing all engine capabilities
  28788. * @returns the EngineCapabilities object
  28789. */
  28790. getCaps(): EngineCapabilities;
  28791. /**
  28792. * Gets the current depth function
  28793. * @returns a number defining the depth function
  28794. */
  28795. getDepthFunction(): Nullable<number>;
  28796. /**
  28797. * Sets the current depth function
  28798. * @param depthFunc defines the function to use
  28799. */
  28800. setDepthFunction(depthFunc: number): void;
  28801. /**
  28802. * Sets the current depth function to GREATER
  28803. */
  28804. setDepthFunctionToGreater(): void;
  28805. /**
  28806. * Sets the current depth function to GEQUAL
  28807. */
  28808. setDepthFunctionToGreaterOrEqual(): void;
  28809. /**
  28810. * Sets the current depth function to LESS
  28811. */
  28812. setDepthFunctionToLess(): void;
  28813. /**
  28814. * Sets the current depth function to LEQUAL
  28815. */
  28816. setDepthFunctionToLessOrEqual(): void;
  28817. /**
  28818. * Gets a boolean indicating if stencil buffer is enabled
  28819. * @returns the current stencil buffer state
  28820. */
  28821. getStencilBuffer(): boolean;
  28822. /**
  28823. * Enable or disable the stencil buffer
  28824. * @param enable defines if the stencil buffer must be enabled or disabled
  28825. */
  28826. setStencilBuffer(enable: boolean): void;
  28827. /**
  28828. * Gets the current stencil mask
  28829. * @returns a number defining the new stencil mask to use
  28830. */
  28831. getStencilMask(): number;
  28832. /**
  28833. * Sets the current stencil mask
  28834. * @param mask defines the new stencil mask to use
  28835. */
  28836. setStencilMask(mask: number): void;
  28837. /**
  28838. * Gets the current stencil function
  28839. * @returns a number defining the stencil function to use
  28840. */
  28841. getStencilFunction(): number;
  28842. /**
  28843. * Gets the current stencil reference value
  28844. * @returns a number defining the stencil reference value to use
  28845. */
  28846. getStencilFunctionReference(): number;
  28847. /**
  28848. * Gets the current stencil mask
  28849. * @returns a number defining the stencil mask to use
  28850. */
  28851. getStencilFunctionMask(): number;
  28852. /**
  28853. * Sets the current stencil function
  28854. * @param stencilFunc defines the new stencil function to use
  28855. */
  28856. setStencilFunction(stencilFunc: number): void;
  28857. /**
  28858. * Sets the current stencil reference
  28859. * @param reference defines the new stencil reference to use
  28860. */
  28861. setStencilFunctionReference(reference: number): void;
  28862. /**
  28863. * Sets the current stencil mask
  28864. * @param mask defines the new stencil mask to use
  28865. */
  28866. setStencilFunctionMask(mask: number): void;
  28867. /**
  28868. * Gets the current stencil operation when stencil fails
  28869. * @returns a number defining stencil operation to use when stencil fails
  28870. */
  28871. getStencilOperationFail(): number;
  28872. /**
  28873. * Gets the current stencil operation when depth fails
  28874. * @returns a number defining stencil operation to use when depth fails
  28875. */
  28876. getStencilOperationDepthFail(): number;
  28877. /**
  28878. * Gets the current stencil operation when stencil passes
  28879. * @returns a number defining stencil operation to use when stencil passes
  28880. */
  28881. getStencilOperationPass(): number;
  28882. /**
  28883. * Sets the stencil operation to use when stencil fails
  28884. * @param operation defines the stencil operation to use when stencil fails
  28885. */
  28886. setStencilOperationFail(operation: number): void;
  28887. /**
  28888. * Sets the stencil operation to use when depth fails
  28889. * @param operation defines the stencil operation to use when depth fails
  28890. */
  28891. setStencilOperationDepthFail(operation: number): void;
  28892. /**
  28893. * Sets the stencil operation to use when stencil passes
  28894. * @param operation defines the stencil operation to use when stencil passes
  28895. */
  28896. setStencilOperationPass(operation: number): void;
  28897. /**
  28898. * Sets a boolean indicating if the dithering state is enabled or disabled
  28899. * @param value defines the dithering state
  28900. */
  28901. setDitheringState(value: boolean): void;
  28902. /**
  28903. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28904. * @param value defines the rasterizer state
  28905. */
  28906. setRasterizerState(value: boolean): void;
  28907. /**
  28908. * stop executing a render loop function and remove it from the execution array
  28909. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28910. */
  28911. stopRenderLoop(renderFunction?: () => void): void;
  28912. /** @hidden */
  28913. _renderLoop(): void;
  28914. /**
  28915. * Register and execute a render loop. The engine can have more than one render function
  28916. * @param renderFunction defines the function to continuously execute
  28917. */
  28918. runRenderLoop(renderFunction: () => void): void;
  28919. /**
  28920. * Toggle full screen mode
  28921. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28922. */
  28923. switchFullscreen(requestPointerLock: boolean): void;
  28924. /**
  28925. * Clear the current render buffer or the current render target (if any is set up)
  28926. * @param color defines the color to use
  28927. * @param backBuffer defines if the back buffer must be cleared
  28928. * @param depth defines if the depth buffer must be cleared
  28929. * @param stencil defines if the stencil buffer must be cleared
  28930. */
  28931. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28932. /**
  28933. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28934. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28935. * @param y defines the y-coordinate of the corner of the clear rectangle
  28936. * @param width defines the width of the clear rectangle
  28937. * @param height defines the height of the clear rectangle
  28938. * @param clearColor defines the clear color
  28939. */
  28940. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28941. /**
  28942. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28943. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28944. * @param y defines the y-coordinate of the corner of the clear rectangle
  28945. * @param width defines the width of the clear rectangle
  28946. * @param height defines the height of the clear rectangle
  28947. */
  28948. enableScissor(x: number, y: number, width: number, height: number): void;
  28949. /**
  28950. * Disable previously set scissor test rectangle
  28951. */
  28952. disableScissor(): void;
  28953. private _viewportCached;
  28954. /** @hidden */
  28955. _viewport(x: number, y: number, width: number, height: number): void;
  28956. /**
  28957. * Set the WebGL's viewport
  28958. * @param viewport defines the viewport element to be used
  28959. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28960. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28961. */
  28962. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28963. /**
  28964. * Directly set the WebGL Viewport
  28965. * @param x defines the x coordinate of the viewport (in screen space)
  28966. * @param y defines the y coordinate of the viewport (in screen space)
  28967. * @param width defines the width of the viewport (in screen space)
  28968. * @param height defines the height of the viewport (in screen space)
  28969. * @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
  28970. */
  28971. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28972. /**
  28973. * Begin a new frame
  28974. */
  28975. beginFrame(): void;
  28976. /**
  28977. * Enf the current frame
  28978. */
  28979. endFrame(): void;
  28980. /**
  28981. * Resize the view according to the canvas' size
  28982. */
  28983. resize(): void;
  28984. /**
  28985. * Force a specific size of the canvas
  28986. * @param width defines the new canvas' width
  28987. * @param height defines the new canvas' height
  28988. */
  28989. setSize(width: number, height: number): void;
  28990. /**
  28991. * Gets a boolean indicating if a webVR device was detected
  28992. * @returns true if a webVR device was detected
  28993. */
  28994. isVRDevicePresent(): boolean;
  28995. /**
  28996. * Gets the current webVR device
  28997. * @returns the current webVR device (or null)
  28998. */
  28999. getVRDevice(): any;
  29000. /**
  29001. * Initializes a webVR display and starts listening to display change events
  29002. * The onVRDisplayChangedObservable will be notified upon these changes
  29003. * @returns The onVRDisplayChangedObservable
  29004. */
  29005. initWebVR(): Observable<IDisplayChangedEventArgs>;
  29006. /**
  29007. * Initializes a webVR display and starts listening to display change events
  29008. * The onVRDisplayChangedObservable will be notified upon these changes
  29009. * @returns A promise containing a VRDisplay and if vr is supported
  29010. */
  29011. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  29012. /**
  29013. * Call this function to switch to webVR mode
  29014. * Will do nothing if webVR is not supported or if there is no webVR device
  29015. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29016. */
  29017. enableVR(): void;
  29018. /**
  29019. * Call this function to leave webVR mode
  29020. * Will do nothing if webVR is not supported or if there is no webVR device
  29021. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29022. */
  29023. disableVR(): void;
  29024. private _onVRFullScreenTriggered;
  29025. private _getVRDisplaysAsync;
  29026. /**
  29027. * Binds the frame buffer to the specified texture.
  29028. * @param texture The texture to render to or null for the default canvas
  29029. * @param faceIndex The face of the texture to render to in case of cube texture
  29030. * @param requiredWidth The width of the target to render to
  29031. * @param requiredHeight The height of the target to render to
  29032. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29033. * @param depthStencilTexture The depth stencil texture to use to render
  29034. * @param lodLevel defines le lod level to bind to the frame buffer
  29035. */
  29036. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29037. private bindUnboundFramebuffer;
  29038. /**
  29039. * Unbind the current render target texture from the webGL context
  29040. * @param texture defines the render target texture to unbind
  29041. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29042. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29043. */
  29044. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29045. /**
  29046. * Unbind a list of render target textures from the webGL context
  29047. * This is used only when drawBuffer extension or webGL2 are active
  29048. * @param textures defines the render target textures to unbind
  29049. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29050. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29051. */
  29052. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29053. /**
  29054. * Force the mipmap generation for the given render target texture
  29055. * @param texture defines the render target texture to use
  29056. */
  29057. generateMipMapsForCubemap(texture: InternalTexture): void;
  29058. /**
  29059. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29060. */
  29061. flushFramebuffer(): void;
  29062. /**
  29063. * Unbind the current render target and bind the default framebuffer
  29064. */
  29065. restoreDefaultFramebuffer(): void;
  29066. /**
  29067. * Create an uniform buffer
  29068. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29069. * @param elements defines the content of the uniform buffer
  29070. * @returns the webGL uniform buffer
  29071. */
  29072. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  29073. /**
  29074. * Create a dynamic uniform buffer
  29075. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29076. * @param elements defines the content of the uniform buffer
  29077. * @returns the webGL uniform buffer
  29078. */
  29079. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  29080. /**
  29081. * Update an existing uniform buffer
  29082. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29083. * @param uniformBuffer defines the target uniform buffer
  29084. * @param elements defines the content to update
  29085. * @param offset defines the offset in the uniform buffer where update should start
  29086. * @param count defines the size of the data to update
  29087. */
  29088. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29089. private _resetVertexBufferBinding;
  29090. /**
  29091. * Creates a vertex buffer
  29092. * @param data the data for the vertex buffer
  29093. * @returns the new WebGL static buffer
  29094. */
  29095. createVertexBuffer(data: DataArray): WebGLBuffer;
  29096. /**
  29097. * Creates a dynamic vertex buffer
  29098. * @param data the data for the dynamic vertex buffer
  29099. * @returns the new WebGL dynamic buffer
  29100. */
  29101. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  29102. /**
  29103. * Update a dynamic index buffer
  29104. * @param indexBuffer defines the target index buffer
  29105. * @param indices defines the data to update
  29106. * @param offset defines the offset in the target index buffer where update should start
  29107. */
  29108. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  29109. /**
  29110. * Updates a dynamic vertex buffer.
  29111. * @param vertexBuffer the vertex buffer to update
  29112. * @param data the data used to update the vertex buffer
  29113. * @param byteOffset the byte offset of the data
  29114. * @param byteLength the byte length of the data
  29115. */
  29116. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29117. private _resetIndexBufferBinding;
  29118. /**
  29119. * Creates a new index buffer
  29120. * @param indices defines the content of the index buffer
  29121. * @param updatable defines if the index buffer must be updatable
  29122. * @returns a new webGL buffer
  29123. */
  29124. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  29125. /**
  29126. * Bind a webGL buffer to the webGL context
  29127. * @param buffer defines the buffer to bind
  29128. */
  29129. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  29130. /**
  29131. * Bind an uniform buffer to the current webGL context
  29132. * @param buffer defines the buffer to bind
  29133. */
  29134. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  29135. /**
  29136. * Bind a buffer to the current webGL context at a given location
  29137. * @param buffer defines the buffer to bind
  29138. * @param location defines the index where to bind the buffer
  29139. */
  29140. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  29141. /**
  29142. * Bind a specific block at a given index in a specific shader program
  29143. * @param shaderProgram defines the shader program
  29144. * @param blockName defines the block name
  29145. * @param index defines the index where to bind the block
  29146. */
  29147. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  29148. private bindIndexBuffer;
  29149. private bindBuffer;
  29150. /**
  29151. * update the bound buffer with the given data
  29152. * @param data defines the data to update
  29153. */
  29154. updateArrayBuffer(data: Float32Array): void;
  29155. private _vertexAttribPointer;
  29156. private _bindIndexBufferWithCache;
  29157. private _bindVertexBuffersAttributes;
  29158. /**
  29159. * Records a vertex array object
  29160. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29161. * @param vertexBuffers defines the list of vertex buffers to store
  29162. * @param indexBuffer defines the index buffer to store
  29163. * @param effect defines the effect to store
  29164. * @returns the new vertex array object
  29165. */
  29166. recordVertexArrayObject(vertexBuffers: {
  29167. [key: string]: VertexBuffer;
  29168. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  29169. /**
  29170. * Bind a specific vertex array object
  29171. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29172. * @param vertexArrayObject defines the vertex array object to bind
  29173. * @param indexBuffer defines the index buffer to bind
  29174. */
  29175. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  29176. /**
  29177. * Bind webGl buffers directly to the webGL context
  29178. * @param vertexBuffer defines the vertex buffer to bind
  29179. * @param indexBuffer defines the index buffer to bind
  29180. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29181. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29182. * @param effect defines the effect associated with the vertex buffer
  29183. */
  29184. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29185. private _unbindVertexArrayObject;
  29186. /**
  29187. * Bind a list of vertex buffers to the webGL context
  29188. * @param vertexBuffers defines the list of vertex buffers to bind
  29189. * @param indexBuffer defines the index buffer to bind
  29190. * @param effect defines the effect associated with the vertex buffers
  29191. */
  29192. bindBuffers(vertexBuffers: {
  29193. [key: string]: Nullable<VertexBuffer>;
  29194. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  29195. /**
  29196. * Unbind all instance attributes
  29197. */
  29198. unbindInstanceAttributes(): void;
  29199. /**
  29200. * Release and free the memory of a vertex array object
  29201. * @param vao defines the vertex array object to delete
  29202. */
  29203. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29204. /** @hidden */
  29205. _releaseBuffer(buffer: WebGLBuffer): boolean;
  29206. /**
  29207. * Creates a webGL buffer to use with instanciation
  29208. * @param capacity defines the size of the buffer
  29209. * @returns the webGL buffer
  29210. */
  29211. createInstancesBuffer(capacity: number): WebGLBuffer;
  29212. /**
  29213. * Delete a webGL buffer used with instanciation
  29214. * @param buffer defines the webGL buffer to delete
  29215. */
  29216. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29217. /**
  29218. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29219. * @param instancesBuffer defines the webGL buffer to update and bind
  29220. * @param data defines the data to store in the buffer
  29221. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29222. */
  29223. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29224. /**
  29225. * Apply all cached states (depth, culling, stencil and alpha)
  29226. */
  29227. applyStates(): void;
  29228. /**
  29229. * Send a draw order
  29230. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29231. * @param indexStart defines the starting index
  29232. * @param indexCount defines the number of index to draw
  29233. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29234. */
  29235. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29236. /**
  29237. * Draw a list of points
  29238. * @param verticesStart defines the index of first vertex to draw
  29239. * @param verticesCount defines the count of vertices to draw
  29240. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29241. */
  29242. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29243. /**
  29244. * Draw a list of unindexed primitives
  29245. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29246. * @param verticesStart defines the index of first vertex to draw
  29247. * @param verticesCount defines the count of vertices to draw
  29248. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29249. */
  29250. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29251. /**
  29252. * Draw a list of indexed primitives
  29253. * @param fillMode defines the primitive to use
  29254. * @param indexStart defines the starting index
  29255. * @param indexCount defines the number of index to draw
  29256. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29257. */
  29258. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29259. /**
  29260. * Draw a list of unindexed primitives
  29261. * @param fillMode defines the primitive to use
  29262. * @param verticesStart defines the index of first vertex to draw
  29263. * @param verticesCount defines the count of vertices to draw
  29264. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29265. */
  29266. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29267. private _drawMode;
  29268. /** @hidden */
  29269. _releaseEffect(effect: Effect): void;
  29270. /** @hidden */
  29271. _deleteProgram(program: WebGLProgram): void;
  29272. /**
  29273. * Create a new effect (used to store vertex/fragment shaders)
  29274. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29275. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29276. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29277. * @param samplers defines an array of string used to represent textures
  29278. * @param defines defines the string containing the defines to use to compile the shaders
  29279. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29280. * @param onCompiled defines a function to call when the effect creation is successful
  29281. * @param onError defines a function to call when the effect creation has failed
  29282. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29283. * @returns the new Effect
  29284. */
  29285. 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;
  29286. private _compileShader;
  29287. private _compileRawShader;
  29288. /**
  29289. * Directly creates a webGL program
  29290. * @param vertexCode defines the vertex shader code to use
  29291. * @param fragmentCode defines the fragment shader code to use
  29292. * @param context defines the webGL context to use (if not set, the current one will be used)
  29293. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29294. * @returns the new webGL program
  29295. */
  29296. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29297. /**
  29298. * Creates a webGL program
  29299. * @param vertexCode defines the vertex shader code to use
  29300. * @param fragmentCode defines the fragment shader code to use
  29301. * @param defines defines the string containing the defines to use to compile the shaders
  29302. * @param context defines the webGL context to use (if not set, the current one will be used)
  29303. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29304. * @returns the new webGL program
  29305. */
  29306. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29307. private _createShaderProgram;
  29308. private _finalizeProgram;
  29309. /** @hidden */
  29310. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  29311. /** @hidden */
  29312. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  29313. /**
  29314. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29315. * @param shaderProgram defines the webGL program to use
  29316. * @param uniformsNames defines the list of uniform names
  29317. * @returns an array of webGL uniform locations
  29318. */
  29319. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29320. /**
  29321. * Gets the lsit of active attributes for a given webGL program
  29322. * @param shaderProgram defines the webGL program to use
  29323. * @param attributesNames defines the list of attribute names to get
  29324. * @returns an array of indices indicating the offset of each attribute
  29325. */
  29326. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  29327. /**
  29328. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29329. * @param effect defines the effect to activate
  29330. */
  29331. enableEffect(effect: Nullable<Effect>): void;
  29332. /**
  29333. * Set the value of an uniform to an array of int32
  29334. * @param uniform defines the webGL uniform location where to store the value
  29335. * @param array defines the array of int32 to store
  29336. */
  29337. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29338. /**
  29339. * Set the value of an uniform to an array of int32 (stored as vec2)
  29340. * @param uniform defines the webGL uniform location where to store the value
  29341. * @param array defines the array of int32 to store
  29342. */
  29343. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29344. /**
  29345. * Set the value of an uniform to an array of int32 (stored as vec3)
  29346. * @param uniform defines the webGL uniform location where to store the value
  29347. * @param array defines the array of int32 to store
  29348. */
  29349. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29350. /**
  29351. * Set the value of an uniform to an array of int32 (stored as vec4)
  29352. * @param uniform defines the webGL uniform location where to store the value
  29353. * @param array defines the array of int32 to store
  29354. */
  29355. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29356. /**
  29357. * Set the value of an uniform to an array of float32
  29358. * @param uniform defines the webGL uniform location where to store the value
  29359. * @param array defines the array of float32 to store
  29360. */
  29361. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29362. /**
  29363. * Set the value of an uniform to an array of float32 (stored as vec2)
  29364. * @param uniform defines the webGL uniform location where to store the value
  29365. * @param array defines the array of float32 to store
  29366. */
  29367. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29368. /**
  29369. * Set the value of an uniform to an array of float32 (stored as vec3)
  29370. * @param uniform defines the webGL uniform location where to store the value
  29371. * @param array defines the array of float32 to store
  29372. */
  29373. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29374. /**
  29375. * Set the value of an uniform to an array of float32 (stored as vec4)
  29376. * @param uniform defines the webGL uniform location where to store the value
  29377. * @param array defines the array of float32 to store
  29378. */
  29379. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29380. /**
  29381. * Set the value of an uniform to an array of number
  29382. * @param uniform defines the webGL uniform location where to store the value
  29383. * @param array defines the array of number to store
  29384. */
  29385. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29386. /**
  29387. * Set the value of an uniform to an array of number (stored as vec2)
  29388. * @param uniform defines the webGL uniform location where to store the value
  29389. * @param array defines the array of number to store
  29390. */
  29391. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29392. /**
  29393. * Set the value of an uniform to an array of number (stored as vec3)
  29394. * @param uniform defines the webGL uniform location where to store the value
  29395. * @param array defines the array of number to store
  29396. */
  29397. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29398. /**
  29399. * Set the value of an uniform to an array of number (stored as vec4)
  29400. * @param uniform defines the webGL uniform location where to store the value
  29401. * @param array defines the array of number to store
  29402. */
  29403. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29404. /**
  29405. * Set the value of an uniform to an array of float32 (stored as matrices)
  29406. * @param uniform defines the webGL uniform location where to store the value
  29407. * @param matrices defines the array of float32 to store
  29408. */
  29409. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29410. /**
  29411. * Set the value of an uniform to a matrix
  29412. * @param uniform defines the webGL uniform location where to store the value
  29413. * @param matrix defines the matrix to store
  29414. */
  29415. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29416. /**
  29417. * Set the value of an uniform to a matrix (3x3)
  29418. * @param uniform defines the webGL uniform location where to store the value
  29419. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29420. */
  29421. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29422. /**
  29423. * Set the value of an uniform to a matrix (2x2)
  29424. * @param uniform defines the webGL uniform location where to store the value
  29425. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29426. */
  29427. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29428. /**
  29429. * Set the value of an uniform to a number (int)
  29430. * @param uniform defines the webGL uniform location where to store the value
  29431. * @param value defines the int number to store
  29432. */
  29433. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29434. /**
  29435. * Set the value of an uniform to a number (float)
  29436. * @param uniform defines the webGL uniform location where to store the value
  29437. * @param value defines the float number to store
  29438. */
  29439. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29440. /**
  29441. * Set the value of an uniform to a vec2
  29442. * @param uniform defines the webGL uniform location where to store the value
  29443. * @param x defines the 1st component of the value
  29444. * @param y defines the 2nd component of the value
  29445. */
  29446. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29447. /**
  29448. * Set the value of an uniform to a vec3
  29449. * @param uniform defines the webGL uniform location where to store the value
  29450. * @param x defines the 1st component of the value
  29451. * @param y defines the 2nd component of the value
  29452. * @param z defines the 3rd component of the value
  29453. */
  29454. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29455. /**
  29456. * Set the value of an uniform to a boolean
  29457. * @param uniform defines the webGL uniform location where to store the value
  29458. * @param bool defines the boolean to store
  29459. */
  29460. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29461. /**
  29462. * Set the value of an uniform to a vec4
  29463. * @param uniform defines the webGL uniform location where to store the value
  29464. * @param x defines the 1st component of the value
  29465. * @param y defines the 2nd component of the value
  29466. * @param z defines the 3rd component of the value
  29467. * @param w defines the 4th component of the value
  29468. */
  29469. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29470. /**
  29471. * Set the value of an uniform to a Color3
  29472. * @param uniform defines the webGL uniform location where to store the value
  29473. * @param color3 defines the color to store
  29474. */
  29475. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29476. /**
  29477. * Set the value of an uniform to a Color3 and an alpha value
  29478. * @param uniform defines the webGL uniform location where to store the value
  29479. * @param color3 defines the color to store
  29480. * @param alpha defines the alpha component to store
  29481. */
  29482. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29483. /**
  29484. * Sets a Color4 on a uniform variable
  29485. * @param uniform defines the uniform location
  29486. * @param color4 defines the value to be set
  29487. */
  29488. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29489. /**
  29490. * Set various states to the webGL context
  29491. * @param culling defines backface culling state
  29492. * @param zOffset defines the value to apply to zOffset (0 by default)
  29493. * @param force defines if states must be applied even if cache is up to date
  29494. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29495. */
  29496. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29497. /**
  29498. * Set the z offset to apply to current rendering
  29499. * @param value defines the offset to apply
  29500. */
  29501. setZOffset(value: number): void;
  29502. /**
  29503. * Gets the current value of the zOffset
  29504. * @returns the current zOffset state
  29505. */
  29506. getZOffset(): number;
  29507. /**
  29508. * Enable or disable depth buffering
  29509. * @param enable defines the state to set
  29510. */
  29511. setDepthBuffer(enable: boolean): void;
  29512. /**
  29513. * Gets a boolean indicating if depth writing is enabled
  29514. * @returns the current depth writing state
  29515. */
  29516. getDepthWrite(): boolean;
  29517. /**
  29518. * Enable or disable depth writing
  29519. * @param enable defines the state to set
  29520. */
  29521. setDepthWrite(enable: boolean): void;
  29522. /**
  29523. * Enable or disable color writing
  29524. * @param enable defines the state to set
  29525. */
  29526. setColorWrite(enable: boolean): void;
  29527. /**
  29528. * Gets a boolean indicating if color writing is enabled
  29529. * @returns the current color writing state
  29530. */
  29531. getColorWrite(): boolean;
  29532. /**
  29533. * Sets alpha constants used by some alpha blending modes
  29534. * @param r defines the red component
  29535. * @param g defines the green component
  29536. * @param b defines the blue component
  29537. * @param a defines the alpha component
  29538. */
  29539. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29540. /**
  29541. * Sets the current alpha mode
  29542. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29543. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29544. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29545. */
  29546. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29547. /**
  29548. * Gets the current alpha mode
  29549. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29550. * @returns the current alpha mode
  29551. */
  29552. getAlphaMode(): number;
  29553. /**
  29554. * Clears the list of texture accessible through engine.
  29555. * This can help preventing texture load conflict due to name collision.
  29556. */
  29557. clearInternalTexturesCache(): void;
  29558. /**
  29559. * Force the entire cache to be cleared
  29560. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29561. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29562. */
  29563. wipeCaches(bruteForce?: boolean): void;
  29564. /**
  29565. * Set the compressed texture format to use, based on the formats you have, and the formats
  29566. * supported by the hardware / browser.
  29567. *
  29568. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29569. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29570. * to API arguments needed to compressed textures. This puts the burden on the container
  29571. * generator to house the arcane code for determining these for current & future formats.
  29572. *
  29573. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29574. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29575. *
  29576. * Note: The result of this call is not taken into account when a texture is base64.
  29577. *
  29578. * @param formatsAvailable defines the list of those format families you have created
  29579. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29580. *
  29581. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29582. * @returns The extension selected.
  29583. */
  29584. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29585. private _getSamplingParameters;
  29586. private _partialLoadImg;
  29587. private _cascadeLoadImgs;
  29588. /** @hidden */
  29589. _createTexture(): WebGLTexture;
  29590. /**
  29591. * Usually called from Texture.ts.
  29592. * Passed information to create a WebGLTexture
  29593. * @param urlArg defines a value which contains one of the following:
  29594. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29595. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29596. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29597. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29598. * @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)
  29599. * @param scene needed for loading to the correct scene
  29600. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29601. * @param onLoad optional callback to be called upon successful completion
  29602. * @param onError optional callback to be called upon failure
  29603. * @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
  29604. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29605. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29606. * @param forcedExtension defines the extension to use to pick the right loader
  29607. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29608. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29609. */
  29610. 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;
  29611. private _rescaleTexture;
  29612. /**
  29613. * Update a raw texture
  29614. * @param texture defines the texture to update
  29615. * @param data defines the data to store in the texture
  29616. * @param format defines the format of the data
  29617. * @param invertY defines if data must be stored with Y axis inverted
  29618. * @param compression defines the compression used (null by default)
  29619. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29620. */
  29621. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29622. /**
  29623. * Creates a raw texture
  29624. * @param data defines the data to store in the texture
  29625. * @param width defines the width of the texture
  29626. * @param height defines the height of the texture
  29627. * @param format defines the format of the data
  29628. * @param generateMipMaps defines if the engine should generate the mip levels
  29629. * @param invertY defines if data must be stored with Y axis inverted
  29630. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29631. * @param compression defines the compression used (null by default)
  29632. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29633. * @returns the raw texture inside an InternalTexture
  29634. */
  29635. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29636. private _unpackFlipYCached;
  29637. /**
  29638. * In case you are sharing the context with other applications, it might
  29639. * be interested to not cache the unpack flip y state to ensure a consistent
  29640. * value would be set.
  29641. */
  29642. enableUnpackFlipYCached: boolean;
  29643. /** @hidden */
  29644. _unpackFlipY(value: boolean): void;
  29645. /** @hidden */
  29646. _getUnpackAlignement(): number;
  29647. /**
  29648. * Creates a dynamic texture
  29649. * @param width defines the width of the texture
  29650. * @param height defines the height of the texture
  29651. * @param generateMipMaps defines if the engine should generate the mip levels
  29652. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29653. * @returns the dynamic texture inside an InternalTexture
  29654. */
  29655. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29656. /**
  29657. * Update the sampling mode of a given texture
  29658. * @param samplingMode defines the required sampling mode
  29659. * @param texture defines the texture to update
  29660. */
  29661. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29662. /**
  29663. * Update the content of a dynamic texture
  29664. * @param texture defines the texture to update
  29665. * @param canvas defines the canvas containing the source
  29666. * @param invertY defines if data must be stored with Y axis inverted
  29667. * @param premulAlpha defines if alpha is stored as premultiplied
  29668. * @param format defines the format of the data
  29669. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29670. */
  29671. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29672. /**
  29673. * Update a video texture
  29674. * @param texture defines the texture to update
  29675. * @param video defines the video element to use
  29676. * @param invertY defines if data must be stored with Y axis inverted
  29677. */
  29678. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29679. /**
  29680. * Updates a depth texture Comparison Mode and Function.
  29681. * If the comparison Function is equal to 0, the mode will be set to none.
  29682. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29683. * @param texture The texture to set the comparison function for
  29684. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29685. */
  29686. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29687. private _setupDepthStencilTexture;
  29688. /**
  29689. * Creates a depth stencil texture.
  29690. * This is only available in WebGL 2 or with the depth texture extension available.
  29691. * @param size The size of face edge in the texture.
  29692. * @param options The options defining the texture.
  29693. * @returns The texture
  29694. */
  29695. createDepthStencilTexture(size: number | {
  29696. width: number;
  29697. height: number;
  29698. }, options: DepthTextureCreationOptions): InternalTexture;
  29699. /**
  29700. * Creates a depth stencil texture.
  29701. * This is only available in WebGL 2 or with the depth texture extension available.
  29702. * @param size The size of face edge in the texture.
  29703. * @param options The options defining the texture.
  29704. * @returns The texture
  29705. */
  29706. private _createDepthStencilTexture;
  29707. /**
  29708. * Creates a depth stencil cube texture.
  29709. * This is only available in WebGL 2.
  29710. * @param size The size of face edge in the cube texture.
  29711. * @param options The options defining the cube texture.
  29712. * @returns The cube texture
  29713. */
  29714. private _createDepthStencilCubeTexture;
  29715. /**
  29716. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29717. * @param renderTarget The render target to set the frame buffer for
  29718. */
  29719. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29720. /**
  29721. * Creates a new render target texture
  29722. * @param size defines the size of the texture
  29723. * @param options defines the options used to create the texture
  29724. * @returns a new render target texture stored in an InternalTexture
  29725. */
  29726. createRenderTargetTexture(size: number | {
  29727. width: number;
  29728. height: number;
  29729. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29730. /**
  29731. * Create a multi render target texture
  29732. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29733. * @param size defines the size of the texture
  29734. * @param options defines the creation options
  29735. * @returns the cube texture as an InternalTexture
  29736. */
  29737. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29738. private _setupFramebufferDepthAttachments;
  29739. /**
  29740. * Updates the sample count of a render target texture
  29741. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29742. * @param texture defines the texture to update
  29743. * @param samples defines the sample count to set
  29744. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29745. */
  29746. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29747. /**
  29748. * Update the sample count for a given multiple render target texture
  29749. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29750. * @param textures defines the textures to update
  29751. * @param samples defines the sample count to set
  29752. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29753. */
  29754. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29755. /** @hidden */
  29756. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29757. /** @hidden */
  29758. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29759. /** @hidden */
  29760. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29761. /** @hidden */
  29762. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29763. /**
  29764. * Creates a new render target cube texture
  29765. * @param size defines the size of the texture
  29766. * @param options defines the options used to create the texture
  29767. * @returns a new render target cube texture stored in an InternalTexture
  29768. */
  29769. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29770. /**
  29771. * Creates a cube texture
  29772. * @param rootUrl defines the url where the files to load is located
  29773. * @param scene defines the current scene
  29774. * @param files defines the list of files to load (1 per face)
  29775. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29776. * @param onLoad defines an optional callback raised when the texture is loaded
  29777. * @param onError defines an optional callback raised if there is an issue to load the texture
  29778. * @param format defines the format of the data
  29779. * @param forcedExtension defines the extension to use to pick the right loader
  29780. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29781. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29782. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29783. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29784. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29785. * @returns the cube texture as an InternalTexture
  29786. */
  29787. 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;
  29788. /**
  29789. * @hidden
  29790. */
  29791. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29792. /**
  29793. * Update a raw cube texture
  29794. * @param texture defines the texture to udpdate
  29795. * @param data defines the data to store
  29796. * @param format defines the data format
  29797. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29798. * @param invertY defines if data must be stored with Y axis inverted
  29799. * @param compression defines the compression used (null by default)
  29800. * @param level defines which level of the texture to update
  29801. */
  29802. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29803. /**
  29804. * Creates a new raw cube texture
  29805. * @param data defines the array of data to use to create each face
  29806. * @param size defines the size of the textures
  29807. * @param format defines the format of the data
  29808. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29809. * @param generateMipMaps defines if the engine should generate the mip levels
  29810. * @param invertY defines if data must be stored with Y axis inverted
  29811. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29812. * @param compression defines the compression used (null by default)
  29813. * @returns the cube texture as an InternalTexture
  29814. */
  29815. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29816. /**
  29817. * Creates a new raw cube texture from a specified url
  29818. * @param url defines the url where the data is located
  29819. * @param scene defines the current scene
  29820. * @param size defines the size of the textures
  29821. * @param format defines the format of the data
  29822. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29823. * @param noMipmap defines if the engine should avoid generating the mip levels
  29824. * @param callback defines a callback used to extract texture data from loaded data
  29825. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29826. * @param onLoad defines a callback called when texture is loaded
  29827. * @param onError defines a callback called if there is an error
  29828. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29829. * @param invertY defines if data must be stored with Y axis inverted
  29830. * @returns the cube texture as an InternalTexture
  29831. */
  29832. 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;
  29833. /**
  29834. * Update a raw 3D texture
  29835. * @param texture defines the texture to update
  29836. * @param data defines the data to store
  29837. * @param format defines the data format
  29838. * @param invertY defines if data must be stored with Y axis inverted
  29839. * @param compression defines the used compression (can be null)
  29840. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29841. */
  29842. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29843. /**
  29844. * Creates a new raw 3D texture
  29845. * @param data defines the data used to create the texture
  29846. * @param width defines the width of the texture
  29847. * @param height defines the height of the texture
  29848. * @param depth defines the depth of the texture
  29849. * @param format defines the format of the texture
  29850. * @param generateMipMaps defines if the engine must generate mip levels
  29851. * @param invertY defines if data must be stored with Y axis inverted
  29852. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29853. * @param compression defines the compressed used (can be null)
  29854. * @param textureType defines the compressed used (can be null)
  29855. * @returns a new raw 3D texture (stored in an InternalTexture)
  29856. */
  29857. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29858. private _prepareWebGLTextureContinuation;
  29859. private _prepareWebGLTexture;
  29860. private _convertRGBtoRGBATextureData;
  29861. /** @hidden */
  29862. _releaseFramebufferObjects(texture: InternalTexture): void;
  29863. /** @hidden */
  29864. _releaseTexture(texture: InternalTexture): void;
  29865. private setProgram;
  29866. private _boundUniforms;
  29867. /**
  29868. * Binds an effect to the webGL context
  29869. * @param effect defines the effect to bind
  29870. */
  29871. bindSamplers(effect: Effect): void;
  29872. private _moveBoundTextureOnTop;
  29873. private _getCorrectTextureChannel;
  29874. private _linkTrackers;
  29875. private _removeDesignatedSlot;
  29876. private _activateCurrentTexture;
  29877. /** @hidden */
  29878. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29879. /** @hidden */
  29880. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29881. /**
  29882. * Sets a texture to the webGL context from a postprocess
  29883. * @param channel defines the channel to use
  29884. * @param postProcess defines the source postprocess
  29885. */
  29886. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29887. /**
  29888. * Binds the output of the passed in post process to the texture channel specified
  29889. * @param channel The channel the texture should be bound to
  29890. * @param postProcess The post process which's output should be bound
  29891. */
  29892. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29893. /**
  29894. * Unbind all textures from the webGL context
  29895. */
  29896. unbindAllTextures(): void;
  29897. /**
  29898. * Sets a texture to the according uniform.
  29899. * @param channel The texture channel
  29900. * @param uniform The uniform to set
  29901. * @param texture The texture to apply
  29902. */
  29903. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29904. /**
  29905. * Sets a depth stencil texture from a render target to the according uniform.
  29906. * @param channel The texture channel
  29907. * @param uniform The uniform to set
  29908. * @param texture The render target texture containing the depth stencil texture to apply
  29909. */
  29910. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29911. private _bindSamplerUniformToChannel;
  29912. private _getTextureWrapMode;
  29913. private _setTexture;
  29914. /**
  29915. * Sets an array of texture to the webGL context
  29916. * @param channel defines the channel where the texture array must be set
  29917. * @param uniform defines the associated uniform location
  29918. * @param textures defines the array of textures to bind
  29919. */
  29920. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29921. /** @hidden */
  29922. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29923. private _setTextureParameterFloat;
  29924. private _setTextureParameterInteger;
  29925. /**
  29926. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29927. * @param x defines the x coordinate of the rectangle where pixels must be read
  29928. * @param y defines the y coordinate of the rectangle where pixels must be read
  29929. * @param width defines the width of the rectangle where pixels must be read
  29930. * @param height defines the height of the rectangle where pixels must be read
  29931. * @returns a Uint8Array containing RGBA colors
  29932. */
  29933. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29934. /**
  29935. * Add an externaly attached data from its key.
  29936. * This method call will fail and return false, if such key already exists.
  29937. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29938. * @param key the unique key that identifies the data
  29939. * @param data the data object to associate to the key for this Engine instance
  29940. * @return true if no such key were already present and the data was added successfully, false otherwise
  29941. */
  29942. addExternalData<T>(key: string, data: T): boolean;
  29943. /**
  29944. * Get an externaly attached data from its key
  29945. * @param key the unique key that identifies the data
  29946. * @return the associated data, if present (can be null), or undefined if not present
  29947. */
  29948. getExternalData<T>(key: string): T;
  29949. /**
  29950. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29951. * @param key the unique key that identifies the data
  29952. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29953. * @return the associated data, can be null if the factory returned null.
  29954. */
  29955. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29956. /**
  29957. * Remove an externaly attached data from the Engine instance
  29958. * @param key the unique key that identifies the data
  29959. * @return true if the data was successfully removed, false if it doesn't exist
  29960. */
  29961. removeExternalData(key: string): boolean;
  29962. /**
  29963. * Unbind all vertex attributes from the webGL context
  29964. */
  29965. unbindAllAttributes(): void;
  29966. /**
  29967. * 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
  29968. */
  29969. releaseEffects(): void;
  29970. /**
  29971. * Dispose and release all associated resources
  29972. */
  29973. dispose(): void;
  29974. /**
  29975. * Display the loading screen
  29976. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29977. */
  29978. displayLoadingUI(): void;
  29979. /**
  29980. * Hide the loading screen
  29981. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29982. */
  29983. hideLoadingUI(): void;
  29984. /**
  29985. * Gets the current loading screen object
  29986. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29987. */
  29988. /**
  29989. * Sets the current loading screen object
  29990. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29991. */
  29992. loadingScreen: ILoadingScreen;
  29993. /**
  29994. * Sets the current loading screen text
  29995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29996. */
  29997. loadingUIText: string;
  29998. /**
  29999. * Sets the current loading screen background color
  30000. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30001. */
  30002. loadingUIBackgroundColor: string;
  30003. /**
  30004. * Attach a new callback raised when context lost event is fired
  30005. * @param callback defines the callback to call
  30006. */
  30007. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30008. /**
  30009. * Attach a new callback raised when context restored event is fired
  30010. * @param callback defines the callback to call
  30011. */
  30012. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30013. /**
  30014. * Gets the source code of the vertex shader associated with a specific webGL program
  30015. * @param program defines the program to use
  30016. * @returns a string containing the source code of the vertex shader associated with the program
  30017. */
  30018. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30019. /**
  30020. * Gets the source code of the fragment shader associated with a specific webGL program
  30021. * @param program defines the program to use
  30022. * @returns a string containing the source code of the fragment shader associated with the program
  30023. */
  30024. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30025. /**
  30026. * Get the current error code of the webGL context
  30027. * @returns the error code
  30028. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30029. */
  30030. getError(): number;
  30031. /**
  30032. * Gets the current framerate
  30033. * @returns a number representing the framerate
  30034. */
  30035. getFps(): number;
  30036. /**
  30037. * Gets the time spent between current and previous frame
  30038. * @returns a number representing the delta time in ms
  30039. */
  30040. getDeltaTime(): number;
  30041. private _measureFps;
  30042. /** @hidden */
  30043. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30044. private _canRenderToFloatFramebuffer;
  30045. private _canRenderToHalfFloatFramebuffer;
  30046. private _canRenderToFramebuffer;
  30047. /** @hidden */
  30048. _getWebGLTextureType(type: number): number;
  30049. private _getInternalFormat;
  30050. /** @hidden */
  30051. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30052. /** @hidden */
  30053. _getRGBAMultiSampleBufferFormat(type: number): number;
  30054. /** @hidden */
  30055. _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;
  30056. /** @hidden */
  30057. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30058. private _partialLoadFile;
  30059. private _cascadeLoadFiles;
  30060. /**
  30061. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30062. * @returns true if the engine can be created
  30063. * @ignorenaming
  30064. */
  30065. static isSupported(): boolean;
  30066. }
  30067. }
  30068. declare module "babylonjs/Materials/effect" {
  30069. import { Observable } from "babylonjs/Misc/observable";
  30070. import { Nullable } from "babylonjs/types";
  30071. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  30072. import { Engine } from "babylonjs/Engines/engine";
  30073. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30075. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30076. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30078. /**
  30079. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30080. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30081. */
  30082. export class EffectFallbacks {
  30083. private _defines;
  30084. private _currentRank;
  30085. private _maxRank;
  30086. private _mesh;
  30087. /**
  30088. * Removes the fallback from the bound mesh.
  30089. */
  30090. unBindMesh(): void;
  30091. /**
  30092. * Adds a fallback on the specified property.
  30093. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30094. * @param define The name of the define in the shader
  30095. */
  30096. addFallback(rank: number, define: string): void;
  30097. /**
  30098. * Sets the mesh to use CPU skinning when needing to fallback.
  30099. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30100. * @param mesh The mesh to use the fallbacks.
  30101. */
  30102. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30103. /**
  30104. * Checks to see if more fallbacks are still availible.
  30105. */
  30106. readonly isMoreFallbacks: boolean;
  30107. /**
  30108. * Removes the defines that shoould be removed when falling back.
  30109. * @param currentDefines defines the current define statements for the shader.
  30110. * @param effect defines the current effect we try to compile
  30111. * @returns The resulting defines with defines of the current rank removed.
  30112. */
  30113. reduce(currentDefines: string, effect: Effect): string;
  30114. }
  30115. /**
  30116. * Options to be used when creating an effect.
  30117. */
  30118. export class EffectCreationOptions {
  30119. /**
  30120. * Atrributes that will be used in the shader.
  30121. */
  30122. attributes: string[];
  30123. /**
  30124. * Uniform varible names that will be set in the shader.
  30125. */
  30126. uniformsNames: string[];
  30127. /**
  30128. * Uniform buffer varible names that will be set in the shader.
  30129. */
  30130. uniformBuffersNames: string[];
  30131. /**
  30132. * Sampler texture variable names that will be set in the shader.
  30133. */
  30134. samplers: string[];
  30135. /**
  30136. * Define statements that will be set in the shader.
  30137. */
  30138. defines: any;
  30139. /**
  30140. * Possible fallbacks for this effect to improve performance when needed.
  30141. */
  30142. fallbacks: Nullable<EffectFallbacks>;
  30143. /**
  30144. * Callback that will be called when the shader is compiled.
  30145. */
  30146. onCompiled: Nullable<(effect: Effect) => void>;
  30147. /**
  30148. * Callback that will be called if an error occurs during shader compilation.
  30149. */
  30150. onError: Nullable<(effect: Effect, errors: string) => void>;
  30151. /**
  30152. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30153. */
  30154. indexParameters: any;
  30155. /**
  30156. * Max number of lights that can be used in the shader.
  30157. */
  30158. maxSimultaneousLights: number;
  30159. /**
  30160. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30161. */
  30162. transformFeedbackVaryings: Nullable<string[]>;
  30163. }
  30164. /**
  30165. * Effect containing vertex and fragment shader that can be executed on an object.
  30166. */
  30167. export class Effect {
  30168. /**
  30169. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30170. */
  30171. static ShadersRepository: string;
  30172. /**
  30173. * Name of the effect.
  30174. */
  30175. name: any;
  30176. /**
  30177. * String container all the define statements that should be set on the shader.
  30178. */
  30179. defines: string;
  30180. /**
  30181. * Callback that will be called when the shader is compiled.
  30182. */
  30183. onCompiled: Nullable<(effect: Effect) => void>;
  30184. /**
  30185. * Callback that will be called if an error occurs during shader compilation.
  30186. */
  30187. onError: Nullable<(effect: Effect, errors: string) => void>;
  30188. /**
  30189. * Callback that will be called when effect is bound.
  30190. */
  30191. onBind: Nullable<(effect: Effect) => void>;
  30192. /**
  30193. * Unique ID of the effect.
  30194. */
  30195. uniqueId: number;
  30196. /**
  30197. * Observable that will be called when the shader is compiled.
  30198. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30199. */
  30200. onCompileObservable: Observable<Effect>;
  30201. /**
  30202. * Observable that will be called if an error occurs during shader compilation.
  30203. */
  30204. onErrorObservable: Observable<Effect>;
  30205. /** @hidden */
  30206. _onBindObservable: Nullable<Observable<Effect>>;
  30207. /**
  30208. * Observable that will be called when effect is bound.
  30209. */
  30210. readonly onBindObservable: Observable<Effect>;
  30211. /** @hidden */
  30212. _bonesComputationForcedToCPU: boolean;
  30213. private static _uniqueIdSeed;
  30214. private _engine;
  30215. private _uniformBuffersNames;
  30216. private _uniformsNames;
  30217. private _samplers;
  30218. private _isReady;
  30219. private _compilationError;
  30220. private _attributesNames;
  30221. private _attributes;
  30222. private _uniforms;
  30223. /**
  30224. * Key for the effect.
  30225. * @hidden
  30226. */
  30227. _key: string;
  30228. private _indexParameters;
  30229. private _fallbacks;
  30230. private _vertexSourceCode;
  30231. private _fragmentSourceCode;
  30232. private _vertexSourceCodeOverride;
  30233. private _fragmentSourceCodeOverride;
  30234. private _transformFeedbackVaryings;
  30235. /**
  30236. * Compiled shader to webGL program.
  30237. * @hidden
  30238. */
  30239. _program: WebGLProgram;
  30240. private _valueCache;
  30241. private static _baseCache;
  30242. /**
  30243. * Instantiates an effect.
  30244. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30245. * @param baseName Name of the effect.
  30246. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30247. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30248. * @param samplers List of sampler variables that will be passed to the shader.
  30249. * @param engine Engine to be used to render the effect
  30250. * @param defines Define statements to be added to the shader.
  30251. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30252. * @param onCompiled Callback that will be called when the shader is compiled.
  30253. * @param onError Callback that will be called if an error occurs during shader compilation.
  30254. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30255. */
  30256. 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);
  30257. /**
  30258. * Unique key for this effect
  30259. */
  30260. readonly key: string;
  30261. /**
  30262. * If the effect has been compiled and prepared.
  30263. * @returns if the effect is compiled and prepared.
  30264. */
  30265. isReady(): boolean;
  30266. /**
  30267. * The engine the effect was initialized with.
  30268. * @returns the engine.
  30269. */
  30270. getEngine(): Engine;
  30271. /**
  30272. * The compiled webGL program for the effect
  30273. * @returns the webGL program.
  30274. */
  30275. getProgram(): WebGLProgram;
  30276. /**
  30277. * The set of names of attribute variables for the shader.
  30278. * @returns An array of attribute names.
  30279. */
  30280. getAttributesNames(): string[];
  30281. /**
  30282. * Returns the attribute at the given index.
  30283. * @param index The index of the attribute.
  30284. * @returns The location of the attribute.
  30285. */
  30286. getAttributeLocation(index: number): number;
  30287. /**
  30288. * Returns the attribute based on the name of the variable.
  30289. * @param name of the attribute to look up.
  30290. * @returns the attribute location.
  30291. */
  30292. getAttributeLocationByName(name: string): number;
  30293. /**
  30294. * The number of attributes.
  30295. * @returns the numnber of attributes.
  30296. */
  30297. getAttributesCount(): number;
  30298. /**
  30299. * Gets the index of a uniform variable.
  30300. * @param uniformName of the uniform to look up.
  30301. * @returns the index.
  30302. */
  30303. getUniformIndex(uniformName: string): number;
  30304. /**
  30305. * Returns the attribute based on the name of the variable.
  30306. * @param uniformName of the uniform to look up.
  30307. * @returns the location of the uniform.
  30308. */
  30309. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30310. /**
  30311. * Returns an array of sampler variable names
  30312. * @returns The array of sampler variable neames.
  30313. */
  30314. getSamplers(): string[];
  30315. /**
  30316. * The error from the last compilation.
  30317. * @returns the error string.
  30318. */
  30319. getCompilationError(): string;
  30320. /**
  30321. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30322. * @param func The callback to be used.
  30323. */
  30324. executeWhenCompiled(func: (effect: Effect) => void): void;
  30325. private _checkIsReady;
  30326. /** @hidden */
  30327. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30328. /** @hidden */
  30329. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30330. /** @hidden */
  30331. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30332. private _processShaderConversion;
  30333. private _processIncludes;
  30334. private _processPrecision;
  30335. /**
  30336. * Recompiles the webGL program
  30337. * @param vertexSourceCode The source code for the vertex shader.
  30338. * @param fragmentSourceCode The source code for the fragment shader.
  30339. * @param onCompiled Callback called when completed.
  30340. * @param onError Callback called on error.
  30341. * @hidden
  30342. */
  30343. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  30344. /**
  30345. * Gets the uniform locations of the the specified variable names
  30346. * @param names THe names of the variables to lookup.
  30347. * @returns Array of locations in the same order as variable names.
  30348. */
  30349. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  30350. /**
  30351. * Prepares the effect
  30352. * @hidden
  30353. */
  30354. _prepareEffect(): void;
  30355. /**
  30356. * Checks if the effect is supported. (Must be called after compilation)
  30357. */
  30358. readonly isSupported: boolean;
  30359. /**
  30360. * Binds a texture to the engine to be used as output of the shader.
  30361. * @param channel Name of the output variable.
  30362. * @param texture Texture to bind.
  30363. * @hidden
  30364. */
  30365. _bindTexture(channel: string, texture: InternalTexture): void;
  30366. /**
  30367. * Sets a texture on the engine to be used in the shader.
  30368. * @param channel Name of the sampler variable.
  30369. * @param texture Texture to set.
  30370. */
  30371. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30372. /**
  30373. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30374. * @param channel Name of the sampler variable.
  30375. * @param texture Texture to set.
  30376. */
  30377. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30378. /**
  30379. * Sets an array of textures on the engine to be used in the shader.
  30380. * @param channel Name of the variable.
  30381. * @param textures Textures to set.
  30382. */
  30383. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30384. /**
  30385. * 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)
  30386. * @param channel Name of the sampler variable.
  30387. * @param postProcess Post process to get the input texture from.
  30388. */
  30389. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30390. /**
  30391. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30392. * 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)
  30393. * @param channel Name of the sampler variable.
  30394. * @param postProcess Post process to get the output texture from.
  30395. */
  30396. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30397. /** @hidden */
  30398. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30399. /** @hidden */
  30400. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30401. /** @hidden */
  30402. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30403. /** @hidden */
  30404. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30405. /**
  30406. * Binds a buffer to a uniform.
  30407. * @param buffer Buffer to bind.
  30408. * @param name Name of the uniform variable to bind to.
  30409. */
  30410. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  30411. /**
  30412. * Binds block to a uniform.
  30413. * @param blockName Name of the block to bind.
  30414. * @param index Index to bind.
  30415. */
  30416. bindUniformBlock(blockName: string, index: number): void;
  30417. /**
  30418. * Sets an interger value on a uniform variable.
  30419. * @param uniformName Name of the variable.
  30420. * @param value Value to be set.
  30421. * @returns this effect.
  30422. */
  30423. setInt(uniformName: string, value: number): Effect;
  30424. /**
  30425. * Sets an int array on a uniform variable.
  30426. * @param uniformName Name of the variable.
  30427. * @param array array to be set.
  30428. * @returns this effect.
  30429. */
  30430. setIntArray(uniformName: string, array: Int32Array): Effect;
  30431. /**
  30432. * 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)
  30433. * @param uniformName Name of the variable.
  30434. * @param array array to be set.
  30435. * @returns this effect.
  30436. */
  30437. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30438. /**
  30439. * 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)
  30440. * @param uniformName Name of the variable.
  30441. * @param array array to be set.
  30442. * @returns this effect.
  30443. */
  30444. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30445. /**
  30446. * 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)
  30447. * @param uniformName Name of the variable.
  30448. * @param array array to be set.
  30449. * @returns this effect.
  30450. */
  30451. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30452. /**
  30453. * Sets an float array on a uniform variable.
  30454. * @param uniformName Name of the variable.
  30455. * @param array array to be set.
  30456. * @returns this effect.
  30457. */
  30458. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30459. /**
  30460. * 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)
  30461. * @param uniformName Name of the variable.
  30462. * @param array array to be set.
  30463. * @returns this effect.
  30464. */
  30465. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30466. /**
  30467. * 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)
  30468. * @param uniformName Name of the variable.
  30469. * @param array array to be set.
  30470. * @returns this effect.
  30471. */
  30472. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30473. /**
  30474. * 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)
  30475. * @param uniformName Name of the variable.
  30476. * @param array array to be set.
  30477. * @returns this effect.
  30478. */
  30479. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30480. /**
  30481. * Sets an array on a uniform variable.
  30482. * @param uniformName Name of the variable.
  30483. * @param array array to be set.
  30484. * @returns this effect.
  30485. */
  30486. setArray(uniformName: string, array: number[]): Effect;
  30487. /**
  30488. * 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)
  30489. * @param uniformName Name of the variable.
  30490. * @param array array to be set.
  30491. * @returns this effect.
  30492. */
  30493. setArray2(uniformName: string, array: number[]): Effect;
  30494. /**
  30495. * 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)
  30496. * @param uniformName Name of the variable.
  30497. * @param array array to be set.
  30498. * @returns this effect.
  30499. */
  30500. setArray3(uniformName: string, array: number[]): Effect;
  30501. /**
  30502. * 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)
  30503. * @param uniformName Name of the variable.
  30504. * @param array array to be set.
  30505. * @returns this effect.
  30506. */
  30507. setArray4(uniformName: string, array: number[]): Effect;
  30508. /**
  30509. * Sets matrices on a uniform variable.
  30510. * @param uniformName Name of the variable.
  30511. * @param matrices matrices to be set.
  30512. * @returns this effect.
  30513. */
  30514. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30515. /**
  30516. * Sets matrix on a uniform variable.
  30517. * @param uniformName Name of the variable.
  30518. * @param matrix matrix to be set.
  30519. * @returns this effect.
  30520. */
  30521. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30522. /**
  30523. * 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)
  30524. * @param uniformName Name of the variable.
  30525. * @param matrix matrix to be set.
  30526. * @returns this effect.
  30527. */
  30528. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30529. /**
  30530. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30531. * @param uniformName Name of the variable.
  30532. * @param matrix matrix to be set.
  30533. * @returns this effect.
  30534. */
  30535. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30536. /**
  30537. * Sets a float on a uniform variable.
  30538. * @param uniformName Name of the variable.
  30539. * @param value value to be set.
  30540. * @returns this effect.
  30541. */
  30542. setFloat(uniformName: string, value: number): Effect;
  30543. /**
  30544. * Sets a boolean on a uniform variable.
  30545. * @param uniformName Name of the variable.
  30546. * @param bool value to be set.
  30547. * @returns this effect.
  30548. */
  30549. setBool(uniformName: string, bool: boolean): Effect;
  30550. /**
  30551. * Sets a Vector2 on a uniform variable.
  30552. * @param uniformName Name of the variable.
  30553. * @param vector2 vector2 to be set.
  30554. * @returns this effect.
  30555. */
  30556. setVector2(uniformName: string, vector2: Vector2): Effect;
  30557. /**
  30558. * Sets a float2 on a uniform variable.
  30559. * @param uniformName Name of the variable.
  30560. * @param x First float in float2.
  30561. * @param y Second float in float2.
  30562. * @returns this effect.
  30563. */
  30564. setFloat2(uniformName: string, x: number, y: number): Effect;
  30565. /**
  30566. * Sets a Vector3 on a uniform variable.
  30567. * @param uniformName Name of the variable.
  30568. * @param vector3 Value to be set.
  30569. * @returns this effect.
  30570. */
  30571. setVector3(uniformName: string, vector3: Vector3): Effect;
  30572. /**
  30573. * Sets a float3 on a uniform variable.
  30574. * @param uniformName Name of the variable.
  30575. * @param x First float in float3.
  30576. * @param y Second float in float3.
  30577. * @param z Third float in float3.
  30578. * @returns this effect.
  30579. */
  30580. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30581. /**
  30582. * Sets a Vector4 on a uniform variable.
  30583. * @param uniformName Name of the variable.
  30584. * @param vector4 Value to be set.
  30585. * @returns this effect.
  30586. */
  30587. setVector4(uniformName: string, vector4: Vector4): Effect;
  30588. /**
  30589. * Sets a float4 on a uniform variable.
  30590. * @param uniformName Name of the variable.
  30591. * @param x First float in float4.
  30592. * @param y Second float in float4.
  30593. * @param z Third float in float4.
  30594. * @param w Fourth float in float4.
  30595. * @returns this effect.
  30596. */
  30597. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30598. /**
  30599. * Sets a Color3 on a uniform variable.
  30600. * @param uniformName Name of the variable.
  30601. * @param color3 Value to be set.
  30602. * @returns this effect.
  30603. */
  30604. setColor3(uniformName: string, color3: Color3): Effect;
  30605. /**
  30606. * Sets a Color4 on a uniform variable.
  30607. * @param uniformName Name of the variable.
  30608. * @param color3 Value to be set.
  30609. * @param alpha Alpha value to be set.
  30610. * @returns this effect.
  30611. */
  30612. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30613. /**
  30614. * Sets a Color4 on a uniform variable
  30615. * @param uniformName defines the name of the variable
  30616. * @param color4 defines the value to be set
  30617. * @returns this effect.
  30618. */
  30619. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30620. /**
  30621. * This function will add a new shader to the shader store
  30622. * @param name the name of the shader
  30623. * @param pixelShader optional pixel shader content
  30624. * @param vertexShader optional vertex shader content
  30625. */
  30626. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30627. /**
  30628. * Store of each shader (The can be looked up using effect.key)
  30629. */
  30630. static ShadersStore: {
  30631. [key: string]: string;
  30632. };
  30633. /**
  30634. * Store of each included file for a shader (The can be looked up using effect.key)
  30635. */
  30636. static IncludesShadersStore: {
  30637. [key: string]: string;
  30638. };
  30639. /**
  30640. * Resets the cache of effects.
  30641. */
  30642. static ResetCache(): void;
  30643. }
  30644. }
  30645. declare module "babylonjs/Materials/colorCurves" {
  30646. import { Effect } from "babylonjs/Materials/effect";
  30647. /**
  30648. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30649. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30650. * 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;
  30651. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30652. */
  30653. export class ColorCurves {
  30654. private _dirty;
  30655. private _tempColor;
  30656. private _globalCurve;
  30657. private _highlightsCurve;
  30658. private _midtonesCurve;
  30659. private _shadowsCurve;
  30660. private _positiveCurve;
  30661. private _negativeCurve;
  30662. private _globalHue;
  30663. private _globalDensity;
  30664. private _globalSaturation;
  30665. private _globalExposure;
  30666. /**
  30667. * Gets the global Hue value.
  30668. * 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).
  30669. */
  30670. /**
  30671. * Sets the global Hue value.
  30672. * 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).
  30673. */
  30674. globalHue: number;
  30675. /**
  30676. * Gets the global Density value.
  30677. * 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.
  30678. * Values less than zero provide a filter of opposite hue.
  30679. */
  30680. /**
  30681. * Sets the global Density value.
  30682. * 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.
  30683. * Values less than zero provide a filter of opposite hue.
  30684. */
  30685. globalDensity: number;
  30686. /**
  30687. * Gets the global Saturation value.
  30688. * 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.
  30689. */
  30690. /**
  30691. * Sets the global Saturation value.
  30692. * 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.
  30693. */
  30694. globalSaturation: number;
  30695. /**
  30696. * Gets the global Exposure value.
  30697. * 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.
  30698. */
  30699. /**
  30700. * Sets the global Exposure value.
  30701. * 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.
  30702. */
  30703. globalExposure: number;
  30704. private _highlightsHue;
  30705. private _highlightsDensity;
  30706. private _highlightsSaturation;
  30707. private _highlightsExposure;
  30708. /**
  30709. * Gets the highlights Hue value.
  30710. * 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).
  30711. */
  30712. /**
  30713. * Sets the highlights Hue value.
  30714. * 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).
  30715. */
  30716. highlightsHue: number;
  30717. /**
  30718. * Gets the highlights Density value.
  30719. * 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.
  30720. * Values less than zero provide a filter of opposite hue.
  30721. */
  30722. /**
  30723. * Sets the highlights Density value.
  30724. * 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.
  30725. * Values less than zero provide a filter of opposite hue.
  30726. */
  30727. highlightsDensity: number;
  30728. /**
  30729. * Gets the highlights Saturation value.
  30730. * 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.
  30731. */
  30732. /**
  30733. * Sets the highlights Saturation value.
  30734. * 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.
  30735. */
  30736. highlightsSaturation: number;
  30737. /**
  30738. * Gets the highlights Exposure value.
  30739. * 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.
  30740. */
  30741. /**
  30742. * Sets the highlights Exposure value.
  30743. * 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.
  30744. */
  30745. highlightsExposure: number;
  30746. private _midtonesHue;
  30747. private _midtonesDensity;
  30748. private _midtonesSaturation;
  30749. private _midtonesExposure;
  30750. /**
  30751. * Gets the midtones Hue value.
  30752. * 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).
  30753. */
  30754. /**
  30755. * Sets the midtones Hue value.
  30756. * 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).
  30757. */
  30758. midtonesHue: number;
  30759. /**
  30760. * Gets the midtones Density value.
  30761. * 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.
  30762. * Values less than zero provide a filter of opposite hue.
  30763. */
  30764. /**
  30765. * Sets the midtones Density value.
  30766. * 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.
  30767. * Values less than zero provide a filter of opposite hue.
  30768. */
  30769. midtonesDensity: number;
  30770. /**
  30771. * Gets the midtones Saturation value.
  30772. * 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.
  30773. */
  30774. /**
  30775. * Sets the midtones Saturation value.
  30776. * 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.
  30777. */
  30778. midtonesSaturation: number;
  30779. /**
  30780. * Gets the midtones Exposure value.
  30781. * 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.
  30782. */
  30783. /**
  30784. * Sets the midtones Exposure value.
  30785. * 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.
  30786. */
  30787. midtonesExposure: number;
  30788. private _shadowsHue;
  30789. private _shadowsDensity;
  30790. private _shadowsSaturation;
  30791. private _shadowsExposure;
  30792. /**
  30793. * Gets the shadows Hue value.
  30794. * 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).
  30795. */
  30796. /**
  30797. * Sets the shadows Hue value.
  30798. * 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).
  30799. */
  30800. shadowsHue: number;
  30801. /**
  30802. * Gets the shadows Density value.
  30803. * 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.
  30804. * Values less than zero provide a filter of opposite hue.
  30805. */
  30806. /**
  30807. * Sets the shadows Density value.
  30808. * 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.
  30809. * Values less than zero provide a filter of opposite hue.
  30810. */
  30811. shadowsDensity: number;
  30812. /**
  30813. * Gets the shadows Saturation value.
  30814. * 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.
  30815. */
  30816. /**
  30817. * Sets the shadows Saturation value.
  30818. * 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.
  30819. */
  30820. shadowsSaturation: number;
  30821. /**
  30822. * Gets the shadows Exposure value.
  30823. * 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.
  30824. */
  30825. /**
  30826. * Sets the shadows Exposure value.
  30827. * 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.
  30828. */
  30829. shadowsExposure: number;
  30830. /**
  30831. * Returns the class name
  30832. * @returns The class name
  30833. */
  30834. getClassName(): string;
  30835. /**
  30836. * Binds the color curves to the shader.
  30837. * @param colorCurves The color curve to bind
  30838. * @param effect The effect to bind to
  30839. * @param positiveUniform The positive uniform shader parameter
  30840. * @param neutralUniform The neutral uniform shader parameter
  30841. * @param negativeUniform The negative uniform shader parameter
  30842. */
  30843. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30844. /**
  30845. * Prepare the list of uniforms associated with the ColorCurves effects.
  30846. * @param uniformsList The list of uniforms used in the effect
  30847. */
  30848. static PrepareUniforms(uniformsList: string[]): void;
  30849. /**
  30850. * Returns color grading data based on a hue, density, saturation and exposure value.
  30851. * @param filterHue The hue of the color filter.
  30852. * @param filterDensity The density of the color filter.
  30853. * @param saturation The saturation.
  30854. * @param exposure The exposure.
  30855. * @param result The result data container.
  30856. */
  30857. private getColorGradingDataToRef;
  30858. /**
  30859. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30860. * @param value The input slider value in range [-100,100].
  30861. * @returns Adjusted value.
  30862. */
  30863. private static applyColorGradingSliderNonlinear;
  30864. /**
  30865. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30866. * @param hue The hue (H) input.
  30867. * @param saturation The saturation (S) input.
  30868. * @param brightness The brightness (B) input.
  30869. * @result An RGBA color represented as Vector4.
  30870. */
  30871. private static fromHSBToRef;
  30872. /**
  30873. * Returns a value clamped between min and max
  30874. * @param value The value to clamp
  30875. * @param min The minimum of value
  30876. * @param max The maximum of value
  30877. * @returns The clamped value.
  30878. */
  30879. private static clamp;
  30880. /**
  30881. * Clones the current color curve instance.
  30882. * @return The cloned curves
  30883. */
  30884. clone(): ColorCurves;
  30885. /**
  30886. * Serializes the current color curve instance to a json representation.
  30887. * @return a JSON representation
  30888. */
  30889. serialize(): any;
  30890. /**
  30891. * Parses the color curve from a json representation.
  30892. * @param source the JSON source to parse
  30893. * @return The parsed curves
  30894. */
  30895. static Parse(source: any): ColorCurves;
  30896. }
  30897. }
  30898. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30899. import { Observable } from "babylonjs/Misc/observable";
  30900. import { Nullable } from "babylonjs/types";
  30901. import { Color4 } from "babylonjs/Maths/math";
  30902. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30903. import { Effect } from "babylonjs/Materials/effect";
  30904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30905. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30906. /**
  30907. * Interface to follow in your material defines to integrate easily the
  30908. * Image proccessing functions.
  30909. * @hidden
  30910. */
  30911. export interface IImageProcessingConfigurationDefines {
  30912. IMAGEPROCESSING: boolean;
  30913. VIGNETTE: boolean;
  30914. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30915. VIGNETTEBLENDMODEOPAQUE: boolean;
  30916. TONEMAPPING: boolean;
  30917. TONEMAPPING_ACES: boolean;
  30918. CONTRAST: boolean;
  30919. EXPOSURE: boolean;
  30920. COLORCURVES: boolean;
  30921. COLORGRADING: boolean;
  30922. COLORGRADING3D: boolean;
  30923. SAMPLER3DGREENDEPTH: boolean;
  30924. SAMPLER3DBGRMAP: boolean;
  30925. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30926. }
  30927. /**
  30928. * @hidden
  30929. */
  30930. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30931. IMAGEPROCESSING: boolean;
  30932. VIGNETTE: boolean;
  30933. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30934. VIGNETTEBLENDMODEOPAQUE: boolean;
  30935. TONEMAPPING: boolean;
  30936. TONEMAPPING_ACES: boolean;
  30937. CONTRAST: boolean;
  30938. COLORCURVES: boolean;
  30939. COLORGRADING: boolean;
  30940. COLORGRADING3D: boolean;
  30941. SAMPLER3DGREENDEPTH: boolean;
  30942. SAMPLER3DBGRMAP: boolean;
  30943. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30944. EXPOSURE: boolean;
  30945. constructor();
  30946. }
  30947. /**
  30948. * This groups together the common properties used for image processing either in direct forward pass
  30949. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30950. * or not.
  30951. */
  30952. export class ImageProcessingConfiguration {
  30953. /**
  30954. * Default tone mapping applied in BabylonJS.
  30955. */
  30956. static readonly TONEMAPPING_STANDARD: number;
  30957. /**
  30958. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30959. * to other engines rendering to increase portability.
  30960. */
  30961. static readonly TONEMAPPING_ACES: number;
  30962. /**
  30963. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30964. */
  30965. colorCurves: Nullable<ColorCurves>;
  30966. private _colorCurvesEnabled;
  30967. /**
  30968. * Gets wether the color curves effect is enabled.
  30969. */
  30970. /**
  30971. * Sets wether the color curves effect is enabled.
  30972. */
  30973. colorCurvesEnabled: boolean;
  30974. private _colorGradingTexture;
  30975. /**
  30976. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30977. */
  30978. /**
  30979. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30980. */
  30981. colorGradingTexture: Nullable<BaseTexture>;
  30982. private _colorGradingEnabled;
  30983. /**
  30984. * Gets wether the color grading effect is enabled.
  30985. */
  30986. /**
  30987. * Sets wether the color grading effect is enabled.
  30988. */
  30989. colorGradingEnabled: boolean;
  30990. private _colorGradingWithGreenDepth;
  30991. /**
  30992. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30993. */
  30994. /**
  30995. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30996. */
  30997. colorGradingWithGreenDepth: boolean;
  30998. private _colorGradingBGR;
  30999. /**
  31000. * Gets wether the color grading texture contains BGR values.
  31001. */
  31002. /**
  31003. * Sets wether the color grading texture contains BGR values.
  31004. */
  31005. colorGradingBGR: boolean;
  31006. /** @hidden */
  31007. _exposure: number;
  31008. /**
  31009. * Gets the Exposure used in the effect.
  31010. */
  31011. /**
  31012. * Sets the Exposure used in the effect.
  31013. */
  31014. exposure: number;
  31015. private _toneMappingEnabled;
  31016. /**
  31017. * Gets wether the tone mapping effect is enabled.
  31018. */
  31019. /**
  31020. * Sets wether the tone mapping effect is enabled.
  31021. */
  31022. toneMappingEnabled: boolean;
  31023. private _toneMappingType;
  31024. /**
  31025. * Gets the type of tone mapping effect.
  31026. */
  31027. /**
  31028. * Sets the type of tone mapping effect used in BabylonJS.
  31029. */
  31030. toneMappingType: number;
  31031. protected _contrast: number;
  31032. /**
  31033. * Gets the contrast used in the effect.
  31034. */
  31035. /**
  31036. * Sets the contrast used in the effect.
  31037. */
  31038. contrast: number;
  31039. /**
  31040. * Vignette stretch size.
  31041. */
  31042. vignetteStretch: number;
  31043. /**
  31044. * Vignette centre X Offset.
  31045. */
  31046. vignetteCentreX: number;
  31047. /**
  31048. * Vignette centre Y Offset.
  31049. */
  31050. vignetteCentreY: number;
  31051. /**
  31052. * Vignette weight or intensity of the vignette effect.
  31053. */
  31054. vignetteWeight: number;
  31055. /**
  31056. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31057. * if vignetteEnabled is set to true.
  31058. */
  31059. vignetteColor: Color4;
  31060. /**
  31061. * Camera field of view used by the Vignette effect.
  31062. */
  31063. vignetteCameraFov: number;
  31064. private _vignetteBlendMode;
  31065. /**
  31066. * Gets the vignette blend mode allowing different kind of effect.
  31067. */
  31068. /**
  31069. * Sets the vignette blend mode allowing different kind of effect.
  31070. */
  31071. vignetteBlendMode: number;
  31072. private _vignetteEnabled;
  31073. /**
  31074. * Gets wether the vignette effect is enabled.
  31075. */
  31076. /**
  31077. * Sets wether the vignette effect is enabled.
  31078. */
  31079. vignetteEnabled: boolean;
  31080. private _applyByPostProcess;
  31081. /**
  31082. * Gets wether the image processing is applied through a post process or not.
  31083. */
  31084. /**
  31085. * Sets wether the image processing is applied through a post process or not.
  31086. */
  31087. applyByPostProcess: boolean;
  31088. private _isEnabled;
  31089. /**
  31090. * Gets wether the image processing is enabled or not.
  31091. */
  31092. /**
  31093. * Sets wether the image processing is enabled or not.
  31094. */
  31095. isEnabled: boolean;
  31096. /**
  31097. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31098. */
  31099. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31100. /**
  31101. * Method called each time the image processing information changes requires to recompile the effect.
  31102. */
  31103. protected _updateParameters(): void;
  31104. /**
  31105. * Gets the current class name.
  31106. * @return "ImageProcessingConfiguration"
  31107. */
  31108. getClassName(): string;
  31109. /**
  31110. * Prepare the list of uniforms associated with the Image Processing effects.
  31111. * @param uniforms The list of uniforms used in the effect
  31112. * @param defines the list of defines currently in use
  31113. */
  31114. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31115. /**
  31116. * Prepare the list of samplers associated with the Image Processing effects.
  31117. * @param samplersList The list of uniforms used in the effect
  31118. * @param defines the list of defines currently in use
  31119. */
  31120. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31121. /**
  31122. * Prepare the list of defines associated to the shader.
  31123. * @param defines the list of defines to complete
  31124. * @param forPostProcess Define if we are currently in post process mode or not
  31125. */
  31126. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31127. /**
  31128. * Returns true if all the image processing information are ready.
  31129. * @returns True if ready, otherwise, false
  31130. */
  31131. isReady(): boolean;
  31132. /**
  31133. * Binds the image processing to the shader.
  31134. * @param effect The effect to bind to
  31135. * @param aspectRatio Define the current aspect ratio of the effect
  31136. */
  31137. bind(effect: Effect, aspectRatio?: number): void;
  31138. /**
  31139. * Clones the current image processing instance.
  31140. * @return The cloned image processing
  31141. */
  31142. clone(): ImageProcessingConfiguration;
  31143. /**
  31144. * Serializes the current image processing instance to a json representation.
  31145. * @return a JSON representation
  31146. */
  31147. serialize(): any;
  31148. /**
  31149. * Parses the image processing from a json representation.
  31150. * @param source the JSON source to parse
  31151. * @return The parsed image processing
  31152. */
  31153. static Parse(source: any): ImageProcessingConfiguration;
  31154. private static _VIGNETTEMODE_MULTIPLY;
  31155. private static _VIGNETTEMODE_OPAQUE;
  31156. /**
  31157. * Used to apply the vignette as a mix with the pixel color.
  31158. */
  31159. static readonly VIGNETTEMODE_MULTIPLY: number;
  31160. /**
  31161. * Used to apply the vignette as a replacement of the pixel color.
  31162. */
  31163. static readonly VIGNETTEMODE_OPAQUE: number;
  31164. }
  31165. }
  31166. declare module "babylonjs/Materials/fresnelParameters" {
  31167. import { Color3 } from "babylonjs/Maths/math";
  31168. /**
  31169. * This represents all the required information to add a fresnel effect on a material:
  31170. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31171. */
  31172. export class FresnelParameters {
  31173. private _isEnabled;
  31174. /**
  31175. * Define if the fresnel effect is enable or not.
  31176. */
  31177. isEnabled: boolean;
  31178. /**
  31179. * Define the color used on edges (grazing angle)
  31180. */
  31181. leftColor: Color3;
  31182. /**
  31183. * Define the color used on center
  31184. */
  31185. rightColor: Color3;
  31186. /**
  31187. * Define bias applied to computed fresnel term
  31188. */
  31189. bias: number;
  31190. /**
  31191. * Defined the power exponent applied to fresnel term
  31192. */
  31193. power: number;
  31194. /**
  31195. * Clones the current fresnel and its valuues
  31196. * @returns a clone fresnel configuration
  31197. */
  31198. clone(): FresnelParameters;
  31199. /**
  31200. * Serializes the current fresnel parameters to a JSON representation.
  31201. * @return the JSON serialization
  31202. */
  31203. serialize(): any;
  31204. /**
  31205. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31206. * @param parsedFresnelParameters Define the JSON representation
  31207. * @returns the parsed parameters
  31208. */
  31209. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31210. }
  31211. }
  31212. declare module "babylonjs/Misc/decorators" {
  31213. import { Nullable } from "babylonjs/types";
  31214. import { Scene } from "babylonjs/scene";
  31215. import { IAnimatable } from "babylonjs/Misc/tools";
  31216. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31217. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31218. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31219. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31220. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31221. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31222. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31223. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31224. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31225. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31226. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31227. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31228. /**
  31229. * Decorator used to define property that can be serialized as reference to a camera
  31230. * @param sourceName defines the name of the property to decorate
  31231. */
  31232. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31233. /**
  31234. * Class used to help serialization objects
  31235. */
  31236. export class SerializationHelper {
  31237. /** hidden */
  31238. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31239. /** hidden */
  31240. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31241. /** hidden */
  31242. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31243. /** hidden */
  31244. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31245. /**
  31246. * Appends the serialized animations from the source animations
  31247. * @param source Source containing the animations
  31248. * @param destination Target to store the animations
  31249. */
  31250. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31251. /**
  31252. * Static function used to serialized a specific entity
  31253. * @param entity defines the entity to serialize
  31254. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31255. * @returns a JSON compatible object representing the serialization of the entity
  31256. */
  31257. static Serialize<T>(entity: T, serializationObject?: any): any;
  31258. /**
  31259. * Creates a new entity from a serialization data object
  31260. * @param creationFunction defines a function used to instanciated the new entity
  31261. * @param source defines the source serialization data
  31262. * @param scene defines the hosting scene
  31263. * @param rootUrl defines the root url for resources
  31264. * @returns a new entity
  31265. */
  31266. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31267. /**
  31268. * Clones an object
  31269. * @param creationFunction defines the function used to instanciate the new object
  31270. * @param source defines the source object
  31271. * @returns the cloned object
  31272. */
  31273. static Clone<T>(creationFunction: () => T, source: T): T;
  31274. /**
  31275. * Instanciates a new object based on a source one (some data will be shared between both object)
  31276. * @param creationFunction defines the function used to instanciate the new object
  31277. * @param source defines the source object
  31278. * @returns the new object
  31279. */
  31280. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31281. }
  31282. }
  31283. declare module "babylonjs/Shaders/pass.fragment" {
  31284. /** @hidden */
  31285. export var passPixelShader: {
  31286. name: string;
  31287. shader: string;
  31288. };
  31289. }
  31290. declare module "babylonjs/Shaders/passCube.fragment" {
  31291. /** @hidden */
  31292. export var passCubePixelShader: {
  31293. name: string;
  31294. shader: string;
  31295. };
  31296. }
  31297. declare module "babylonjs/PostProcesses/passPostProcess" {
  31298. import { Nullable } from "babylonjs/types";
  31299. import { Camera } from "babylonjs/Cameras/camera";
  31300. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  31301. import { Engine } from "babylonjs/Engines/engine";
  31302. import "babylonjs/Shaders/pass.fragment";
  31303. import "babylonjs/Shaders/passCube.fragment";
  31304. /**
  31305. * PassPostProcess which produces an output the same as it's input
  31306. */
  31307. export class PassPostProcess extends PostProcess {
  31308. /**
  31309. * Creates the PassPostProcess
  31310. * @param name The name of the effect.
  31311. * @param options The required width/height ratio to downsize to before computing the render pass.
  31312. * @param camera The camera to apply the render pass to.
  31313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31314. * @param engine The engine which the post process will be applied. (default: current engine)
  31315. * @param reusable If the post process can be reused on the same frame. (default: false)
  31316. * @param textureType The type of texture to be used when performing the post processing.
  31317. * @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)
  31318. */
  31319. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31320. }
  31321. /**
  31322. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  31323. */
  31324. export class PassCubePostProcess extends PostProcess {
  31325. private _face;
  31326. /**
  31327. * Gets or sets the cube face to display.
  31328. * * 0 is +X
  31329. * * 1 is -X
  31330. * * 2 is +Y
  31331. * * 3 is -Y
  31332. * * 4 is +Z
  31333. * * 5 is -Z
  31334. */
  31335. face: number;
  31336. /**
  31337. * Creates the PassCubePostProcess
  31338. * @param name The name of the effect.
  31339. * @param options The required width/height ratio to downsize to before computing the render pass.
  31340. * @param camera The camera to apply the render pass to.
  31341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31342. * @param engine The engine which the post process will be applied. (default: current engine)
  31343. * @param reusable If the post process can be reused on the same frame. (default: false)
  31344. * @param textureType The type of texture to be used when performing the post processing.
  31345. * @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)
  31346. */
  31347. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  31348. }
  31349. }
  31350. declare module "babylonjs/Shaders/anaglyph.fragment" {
  31351. /** @hidden */
  31352. export var anaglyphPixelShader: {
  31353. name: string;
  31354. shader: string;
  31355. };
  31356. }
  31357. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  31358. import { Engine } from "babylonjs/Engines/engine";
  31359. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  31360. import { Camera } from "babylonjs/Cameras/camera";
  31361. import "babylonjs/Shaders/anaglyph.fragment";
  31362. /**
  31363. * Postprocess used to generate anaglyphic rendering
  31364. */
  31365. export class AnaglyphPostProcess extends PostProcess {
  31366. private _passedProcess;
  31367. /**
  31368. * Creates a new AnaglyphPostProcess
  31369. * @param name defines postprocess name
  31370. * @param options defines creation options or target ratio scale
  31371. * @param rigCameras defines cameras using this postprocess
  31372. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  31373. * @param engine defines hosting engine
  31374. * @param reusable defines if the postprocess will be reused multiple times per frame
  31375. */
  31376. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  31377. }
  31378. }
  31379. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  31380. /** @hidden */
  31381. export var stereoscopicInterlacePixelShader: {
  31382. name: string;
  31383. shader: string;
  31384. };
  31385. }
  31386. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  31387. import { Camera } from "babylonjs/Cameras/camera";
  31388. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31389. import { Engine } from "babylonjs/Engines/engine";
  31390. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  31391. /**
  31392. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  31393. */
  31394. export class StereoscopicInterlacePostProcess extends PostProcess {
  31395. private _stepSize;
  31396. private _passedProcess;
  31397. /**
  31398. * Initializes a StereoscopicInterlacePostProcess
  31399. * @param name The name of the effect.
  31400. * @param rigCameras The rig cameras to be appled to the post process
  31401. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  31402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  31403. * @param engine The engine which the post process will be applied. (default: current engine)
  31404. * @param reusable If the post process can be reused on the same frame. (default: false)
  31405. */
  31406. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  31407. }
  31408. }
  31409. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  31410. import { Matrix } from "babylonjs/Maths/math";
  31411. /**
  31412. * This represents all the required metrics to create a VR camera.
  31413. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  31414. */
  31415. export class VRCameraMetrics {
  31416. /**
  31417. * Define the horizontal resolution off the screen.
  31418. */
  31419. hResolution: number;
  31420. /**
  31421. * Define the vertical resolution off the screen.
  31422. */
  31423. vResolution: number;
  31424. /**
  31425. * Define the horizontal screen size.
  31426. */
  31427. hScreenSize: number;
  31428. /**
  31429. * Define the vertical screen size.
  31430. */
  31431. vScreenSize: number;
  31432. /**
  31433. * Define the vertical screen center position.
  31434. */
  31435. vScreenCenter: number;
  31436. /**
  31437. * Define the distance of the eyes to the screen.
  31438. */
  31439. eyeToScreenDistance: number;
  31440. /**
  31441. * Define the distance between both lenses
  31442. */
  31443. lensSeparationDistance: number;
  31444. /**
  31445. * Define the distance between both viewer's eyes.
  31446. */
  31447. interpupillaryDistance: number;
  31448. /**
  31449. * Define the distortion factor of the VR postprocess.
  31450. * Please, touch with care.
  31451. */
  31452. distortionK: number[];
  31453. /**
  31454. * Define the chromatic aberration correction factors for the VR post process.
  31455. */
  31456. chromaAbCorrection: number[];
  31457. /**
  31458. * Define the scale factor of the post process.
  31459. * The smaller the better but the slower.
  31460. */
  31461. postProcessScaleFactor: number;
  31462. /**
  31463. * Define an offset for the lens center.
  31464. */
  31465. lensCenterOffset: number;
  31466. /**
  31467. * Define if the current vr camera should compensate the distortion of the lense or not.
  31468. */
  31469. compensateDistortion: boolean;
  31470. /**
  31471. * Gets the rendering aspect ratio based on the provided resolutions.
  31472. */
  31473. readonly aspectRatio: number;
  31474. /**
  31475. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  31476. */
  31477. readonly aspectRatioFov: number;
  31478. /**
  31479. * @hidden
  31480. */
  31481. readonly leftHMatrix: Matrix;
  31482. /**
  31483. * @hidden
  31484. */
  31485. readonly rightHMatrix: Matrix;
  31486. /**
  31487. * @hidden
  31488. */
  31489. readonly leftPreViewMatrix: Matrix;
  31490. /**
  31491. * @hidden
  31492. */
  31493. readonly rightPreViewMatrix: Matrix;
  31494. /**
  31495. * Get the default VRMetrics based on the most generic setup.
  31496. * @returns the default vr metrics
  31497. */
  31498. static GetDefault(): VRCameraMetrics;
  31499. }
  31500. }
  31501. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  31502. /** @hidden */
  31503. export var vrDistortionCorrectionPixelShader: {
  31504. name: string;
  31505. shader: string;
  31506. };
  31507. }
  31508. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  31509. import { Camera } from "babylonjs/Cameras/camera";
  31510. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  31511. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31512. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  31513. /**
  31514. * VRDistortionCorrectionPostProcess used for mobile VR
  31515. */
  31516. export class VRDistortionCorrectionPostProcess extends PostProcess {
  31517. private _isRightEye;
  31518. private _distortionFactors;
  31519. private _postProcessScaleFactor;
  31520. private _lensCenterOffset;
  31521. private _scaleIn;
  31522. private _scaleFactor;
  31523. private _lensCenter;
  31524. /**
  31525. * Initializes the VRDistortionCorrectionPostProcess
  31526. * @param name The name of the effect.
  31527. * @param camera The camera to apply the render pass to.
  31528. * @param isRightEye If this is for the right eye distortion
  31529. * @param vrMetrics All the required metrics for the VR camera
  31530. */
  31531. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  31532. }
  31533. }
  31534. declare module "babylonjs/Cameras/camera" {
  31535. import { SmartArray } from "babylonjs/Misc/smartArray";
  31536. import { Observable } from "babylonjs/Misc/observable";
  31537. import { Nullable } from "babylonjs/types";
  31538. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31539. import { Scene } from "babylonjs/scene";
  31540. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31541. import { Node } from "babylonjs/node";
  31542. import { Mesh } from "babylonjs/Meshes/mesh";
  31543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31544. import { Ray } from "babylonjs/Culling/ray";
  31545. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31546. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31547. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31548. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31549. /**
  31550. * This is the base class of all the camera used in the application.
  31551. * @see http://doc.babylonjs.com/features/cameras
  31552. */
  31553. export class Camera extends Node {
  31554. /** @hidden */
  31555. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31556. /**
  31557. * This is the default projection mode used by the cameras.
  31558. * It helps recreating a feeling of perspective and better appreciate depth.
  31559. * This is the best way to simulate real life cameras.
  31560. */
  31561. static readonly PERSPECTIVE_CAMERA: number;
  31562. /**
  31563. * This helps creating camera with an orthographic mode.
  31564. * 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.
  31565. */
  31566. static readonly ORTHOGRAPHIC_CAMERA: number;
  31567. /**
  31568. * This is the default FOV mode for perspective cameras.
  31569. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31570. */
  31571. static readonly FOVMODE_VERTICAL_FIXED: number;
  31572. /**
  31573. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31574. */
  31575. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31576. /**
  31577. * This specifies ther is no need for a camera rig.
  31578. * Basically only one eye is rendered corresponding to the camera.
  31579. */
  31580. static readonly RIG_MODE_NONE: number;
  31581. /**
  31582. * Simulates a camera Rig with one blue eye and one red eye.
  31583. * This can be use with 3d blue and red glasses.
  31584. */
  31585. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31586. /**
  31587. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31588. */
  31589. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31590. /**
  31591. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31592. */
  31593. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31594. /**
  31595. * Defines that both eyes of the camera will be rendered over under each other.
  31596. */
  31597. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31598. /**
  31599. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31600. */
  31601. static readonly RIG_MODE_VR: number;
  31602. /**
  31603. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31604. */
  31605. static readonly RIG_MODE_WEBVR: number;
  31606. /**
  31607. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31608. */
  31609. static readonly RIG_MODE_CUSTOM: number;
  31610. /**
  31611. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31612. */
  31613. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31614. /**
  31615. * @hidden
  31616. * Might be removed once multiview will be a thing
  31617. */
  31618. static UseAlternateWebVRRendering: boolean;
  31619. /**
  31620. * Define the input manager associated with the camera.
  31621. */
  31622. inputs: CameraInputsManager<Camera>;
  31623. /**
  31624. * Define the current local position of the camera in the scene
  31625. */
  31626. position: Vector3;
  31627. /**
  31628. * The vector the camera should consider as up.
  31629. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31630. */
  31631. upVector: Vector3;
  31632. /**
  31633. * Define the current limit on the left side for an orthographic camera
  31634. * In scene unit
  31635. */
  31636. orthoLeft: Nullable<number>;
  31637. /**
  31638. * Define the current limit on the right side for an orthographic camera
  31639. * In scene unit
  31640. */
  31641. orthoRight: Nullable<number>;
  31642. /**
  31643. * Define the current limit on the bottom side for an orthographic camera
  31644. * In scene unit
  31645. */
  31646. orthoBottom: Nullable<number>;
  31647. /**
  31648. * Define the current limit on the top side for an orthographic camera
  31649. * In scene unit
  31650. */
  31651. orthoTop: Nullable<number>;
  31652. /**
  31653. * Field Of View is set in Radians. (default is 0.8)
  31654. */
  31655. fov: number;
  31656. /**
  31657. * Define the minimum distance the camera can see from.
  31658. * This is important to note that the depth buffer are not infinite and the closer it starts
  31659. * the more your scene might encounter depth fighting issue.
  31660. */
  31661. minZ: number;
  31662. /**
  31663. * Define the maximum distance the camera can see to.
  31664. * This is important to note that the depth buffer are not infinite and the further it end
  31665. * the more your scene might encounter depth fighting issue.
  31666. */
  31667. maxZ: number;
  31668. /**
  31669. * Define the default inertia of the camera.
  31670. * This helps giving a smooth feeling to the camera movement.
  31671. */
  31672. inertia: number;
  31673. /**
  31674. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31675. */
  31676. mode: number;
  31677. /**
  31678. * Define wether the camera is intermediate.
  31679. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31680. */
  31681. isIntermediate: boolean;
  31682. /**
  31683. * Define the viewport of the camera.
  31684. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31685. */
  31686. viewport: Viewport;
  31687. /**
  31688. * Restricts the camera to viewing objects with the same layerMask.
  31689. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31690. */
  31691. layerMask: number;
  31692. /**
  31693. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31694. */
  31695. fovMode: number;
  31696. /**
  31697. * Rig mode of the camera.
  31698. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31699. * This is normally controlled byt the camera themselves as internal use.
  31700. */
  31701. cameraRigMode: number;
  31702. /**
  31703. * Defines the distance between both "eyes" in case of a RIG
  31704. */
  31705. interaxialDistance: number;
  31706. /**
  31707. * Defines if stereoscopic rendering is done side by side or over under.
  31708. */
  31709. isStereoscopicSideBySide: boolean;
  31710. /**
  31711. * 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
  31712. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31713. * else in the scene.
  31714. */
  31715. customRenderTargets: RenderTargetTexture[];
  31716. /**
  31717. * When set, the camera will render to this render target instead of the default canvas
  31718. */
  31719. outputRenderTarget: Nullable<RenderTargetTexture>;
  31720. /**
  31721. * Observable triggered when the camera view matrix has changed.
  31722. */
  31723. onViewMatrixChangedObservable: Observable<Camera>;
  31724. /**
  31725. * Observable triggered when the camera Projection matrix has changed.
  31726. */
  31727. onProjectionMatrixChangedObservable: Observable<Camera>;
  31728. /**
  31729. * Observable triggered when the inputs have been processed.
  31730. */
  31731. onAfterCheckInputsObservable: Observable<Camera>;
  31732. /**
  31733. * Observable triggered when reset has been called and applied to the camera.
  31734. */
  31735. onRestoreStateObservable: Observable<Camera>;
  31736. /** @hidden */
  31737. _cameraRigParams: any;
  31738. /** @hidden */
  31739. _rigCameras: Camera[];
  31740. /** @hidden */
  31741. _rigPostProcess: Nullable<PostProcess>;
  31742. protected _webvrViewMatrix: Matrix;
  31743. /** @hidden */
  31744. _skipRendering: boolean;
  31745. /** @hidden */
  31746. _alternateCamera: Camera;
  31747. /** @hidden */
  31748. _projectionMatrix: Matrix;
  31749. /** @hidden */
  31750. _postProcesses: Nullable<PostProcess>[];
  31751. /** @hidden */
  31752. _activeMeshes: SmartArray<AbstractMesh>;
  31753. protected _globalPosition: Vector3;
  31754. /** hidden */
  31755. _computedViewMatrix: Matrix;
  31756. private _doNotComputeProjectionMatrix;
  31757. private _transformMatrix;
  31758. private _frustumPlanes;
  31759. private _refreshFrustumPlanes;
  31760. private _storedFov;
  31761. private _stateStored;
  31762. /**
  31763. * Instantiates a new camera object.
  31764. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31765. * @see http://doc.babylonjs.com/features/cameras
  31766. * @param name Defines the name of the camera in the scene
  31767. * @param position Defines the position of the camera
  31768. * @param scene Defines the scene the camera belongs too
  31769. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31770. */
  31771. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31772. /**
  31773. * Store current camera state (fov, position, etc..)
  31774. * @returns the camera
  31775. */
  31776. storeState(): Camera;
  31777. /**
  31778. * Restores the camera state values if it has been stored. You must call storeState() first
  31779. */
  31780. protected _restoreStateValues(): boolean;
  31781. /**
  31782. * Restored camera state. You must call storeState() first.
  31783. * @returns true if restored and false otherwise
  31784. */
  31785. restoreState(): boolean;
  31786. /**
  31787. * Gets the class name of the camera.
  31788. * @returns the class name
  31789. */
  31790. getClassName(): string;
  31791. /** @hidden */
  31792. readonly _isCamera: boolean;
  31793. /**
  31794. * Gets a string representation of the camera useful for debug purpose.
  31795. * @param fullDetails Defines that a more verboe level of logging is required
  31796. * @returns the string representation
  31797. */
  31798. toString(fullDetails?: boolean): string;
  31799. /**
  31800. * Gets the current world space position of the camera.
  31801. */
  31802. readonly globalPosition: Vector3;
  31803. /**
  31804. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31805. * @returns the active meshe list
  31806. */
  31807. getActiveMeshes(): SmartArray<AbstractMesh>;
  31808. /**
  31809. * Check wether a mesh is part of the current active mesh list of the camera
  31810. * @param mesh Defines the mesh to check
  31811. * @returns true if active, false otherwise
  31812. */
  31813. isActiveMesh(mesh: Mesh): boolean;
  31814. /**
  31815. * Is this camera ready to be used/rendered
  31816. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31817. * @return true if the camera is ready
  31818. */
  31819. isReady(completeCheck?: boolean): boolean;
  31820. /** @hidden */
  31821. _initCache(): void;
  31822. /** @hidden */
  31823. _updateCache(ignoreParentClass?: boolean): void;
  31824. /** @hidden */
  31825. _isSynchronized(): boolean;
  31826. /** @hidden */
  31827. _isSynchronizedViewMatrix(): boolean;
  31828. /** @hidden */
  31829. _isSynchronizedProjectionMatrix(): boolean;
  31830. /**
  31831. * Attach the input controls to a specific dom element to get the input from.
  31832. * @param element Defines the element the controls should be listened from
  31833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31834. */
  31835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31836. /**
  31837. * Detach the current controls from the specified dom element.
  31838. * @param element Defines the element to stop listening the inputs from
  31839. */
  31840. detachControl(element: HTMLElement): void;
  31841. /**
  31842. * Update the camera state according to the different inputs gathered during the frame.
  31843. */
  31844. update(): void;
  31845. /** @hidden */
  31846. _checkInputs(): void;
  31847. /** @hidden */
  31848. readonly rigCameras: Camera[];
  31849. /**
  31850. * Gets the post process used by the rig cameras
  31851. */
  31852. readonly rigPostProcess: Nullable<PostProcess>;
  31853. /**
  31854. * Internal, gets the first post proces.
  31855. * @returns the first post process to be run on this camera.
  31856. */
  31857. _getFirstPostProcess(): Nullable<PostProcess>;
  31858. private _cascadePostProcessesToRigCams;
  31859. /**
  31860. * Attach a post process to the camera.
  31861. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31862. * @param postProcess The post process to attach to the camera
  31863. * @param insertAt The position of the post process in case several of them are in use in the scene
  31864. * @returns the position the post process has been inserted at
  31865. */
  31866. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31867. /**
  31868. * Detach a post process to the camera.
  31869. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31870. * @param postProcess The post process to detach from the camera
  31871. */
  31872. detachPostProcess(postProcess: PostProcess): void;
  31873. /**
  31874. * Gets the current world matrix of the camera
  31875. */
  31876. getWorldMatrix(): Matrix;
  31877. /** @hidden */
  31878. protected _getViewMatrix(): Matrix;
  31879. /**
  31880. * Gets the current view matrix of the camera.
  31881. * @param force forces the camera to recompute the matrix without looking at the cached state
  31882. * @returns the view matrix
  31883. */
  31884. getViewMatrix(force?: boolean): Matrix;
  31885. /**
  31886. * Freeze the projection matrix.
  31887. * It will prevent the cache check of the camera projection compute and can speed up perf
  31888. * if no parameter of the camera are meant to change
  31889. * @param projection Defines manually a projection if necessary
  31890. */
  31891. freezeProjectionMatrix(projection?: Matrix): void;
  31892. /**
  31893. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31894. */
  31895. unfreezeProjectionMatrix(): void;
  31896. /**
  31897. * Gets the current projection matrix of the camera.
  31898. * @param force forces the camera to recompute the matrix without looking at the cached state
  31899. * @returns the projection matrix
  31900. */
  31901. getProjectionMatrix(force?: boolean): Matrix;
  31902. /**
  31903. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31904. * @returns a Matrix
  31905. */
  31906. getTransformationMatrix(): Matrix;
  31907. private _updateFrustumPlanes;
  31908. /**
  31909. * Checks if a cullable object (mesh...) is in the camera frustum
  31910. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31911. * @param target The object to check
  31912. * @returns true if the object is in frustum otherwise false
  31913. */
  31914. isInFrustum(target: ICullable): boolean;
  31915. /**
  31916. * Checks if a cullable object (mesh...) is in the camera frustum
  31917. * Unlike isInFrustum this cheks the full bounding box
  31918. * @param target The object to check
  31919. * @returns true if the object is in frustum otherwise false
  31920. */
  31921. isCompletelyInFrustum(target: ICullable): boolean;
  31922. /**
  31923. * Gets a ray in the forward direction from the camera.
  31924. * @param length Defines the length of the ray to create
  31925. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31926. * @param origin Defines the start point of the ray which defaults to the camera position
  31927. * @returns the forward ray
  31928. */
  31929. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31930. /**
  31931. * Releases resources associated with this node.
  31932. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31933. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31934. */
  31935. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31936. /**
  31937. * Gets the left camera of a rig setup in case of Rigged Camera
  31938. */
  31939. readonly leftCamera: Nullable<FreeCamera>;
  31940. /**
  31941. * Gets the right camera of a rig setup in case of Rigged Camera
  31942. */
  31943. readonly rightCamera: Nullable<FreeCamera>;
  31944. /**
  31945. * Gets the left camera target of a rig setup in case of Rigged Camera
  31946. * @returns the target position
  31947. */
  31948. getLeftTarget(): Nullable<Vector3>;
  31949. /**
  31950. * Gets the right camera target of a rig setup in case of Rigged Camera
  31951. * @returns the target position
  31952. */
  31953. getRightTarget(): Nullable<Vector3>;
  31954. /**
  31955. * @hidden
  31956. */
  31957. setCameraRigMode(mode: number, rigParams: any): void;
  31958. private _getVRProjectionMatrix;
  31959. protected _updateCameraRotationMatrix(): void;
  31960. protected _updateWebVRCameraRotationMatrix(): void;
  31961. /**
  31962. * This function MUST be overwritten by the different WebVR cameras available.
  31963. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31964. */
  31965. protected _getWebVRProjectionMatrix(): Matrix;
  31966. /**
  31967. * This function MUST be overwritten by the different WebVR cameras available.
  31968. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31969. */
  31970. protected _getWebVRViewMatrix(): Matrix;
  31971. /** @hidden */
  31972. setCameraRigParameter(name: string, value: any): void;
  31973. /**
  31974. * needs to be overridden by children so sub has required properties to be copied
  31975. * @hidden
  31976. */
  31977. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31978. /**
  31979. * May need to be overridden by children
  31980. * @hidden
  31981. */
  31982. _updateRigCameras(): void;
  31983. /** @hidden */
  31984. _setupInputs(): void;
  31985. /**
  31986. * Serialiaze the camera setup to a json represention
  31987. * @returns the JSON representation
  31988. */
  31989. serialize(): any;
  31990. /**
  31991. * Clones the current camera.
  31992. * @param name The cloned camera name
  31993. * @returns the cloned camera
  31994. */
  31995. clone(name: string): Camera;
  31996. /**
  31997. * Gets the direction of the camera relative to a given local axis.
  31998. * @param localAxis Defines the reference axis to provide a relative direction.
  31999. * @return the direction
  32000. */
  32001. getDirection(localAxis: Vector3): Vector3;
  32002. /**
  32003. * Gets the direction of the camera relative to a given local axis into a passed vector.
  32004. * @param localAxis Defines the reference axis to provide a relative direction.
  32005. * @param result Defines the vector to store the result in
  32006. */
  32007. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  32008. /**
  32009. * Gets a camera constructor for a given camera type
  32010. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  32011. * @param name The name of the camera the result will be able to instantiate
  32012. * @param scene The scene the result will construct the camera in
  32013. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  32014. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  32015. * @returns a factory method to construc the camera
  32016. */
  32017. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  32018. /**
  32019. * Compute the world matrix of the camera.
  32020. * @returns the camera workd matrix
  32021. */
  32022. computeWorldMatrix(): Matrix;
  32023. /**
  32024. * Parse a JSON and creates the camera from the parsed information
  32025. * @param parsedCamera The JSON to parse
  32026. * @param scene The scene to instantiate the camera in
  32027. * @returns the newly constructed camera
  32028. */
  32029. static Parse(parsedCamera: any, scene: Scene): Camera;
  32030. }
  32031. }
  32032. declare module "babylonjs/Misc/tools" {
  32033. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  32034. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  32035. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32036. import { Observable } from "babylonjs/Misc/observable";
  32037. import { DomManagement } from "babylonjs/Misc/domManagement";
  32038. import { Camera } from "babylonjs/Cameras/camera";
  32039. import { Engine } from "babylonjs/Engines/engine";
  32040. import { Animation } from "babylonjs/Animations/animation";
  32041. /**
  32042. * Interface for any object that can request an animation frame
  32043. */
  32044. export interface ICustomAnimationFrameRequester {
  32045. /**
  32046. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32047. */
  32048. renderFunction?: Function;
  32049. /**
  32050. * Called to request the next frame to render to
  32051. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32052. */
  32053. requestAnimationFrame: Function;
  32054. /**
  32055. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32056. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32057. */
  32058. requestID?: number;
  32059. }
  32060. /**
  32061. * Interface containing an array of animations
  32062. */
  32063. export interface IAnimatable {
  32064. /**
  32065. * Array of animations
  32066. */
  32067. animations: Array<Animation>;
  32068. }
  32069. /** Interface used by value gradients (color, factor, ...) */
  32070. export interface IValueGradient {
  32071. /**
  32072. * Gets or sets the gradient value (between 0 and 1)
  32073. */
  32074. gradient: number;
  32075. }
  32076. /** Class used to store color4 gradient */
  32077. export class ColorGradient implements IValueGradient {
  32078. /**
  32079. * Gets or sets the gradient value (between 0 and 1)
  32080. */
  32081. gradient: number;
  32082. /**
  32083. * Gets or sets first associated color
  32084. */
  32085. color1: Color4;
  32086. /**
  32087. * Gets or sets second associated color
  32088. */
  32089. color2?: Color4;
  32090. /**
  32091. * Will get a color picked randomly between color1 and color2.
  32092. * If color2 is undefined then color1 will be used
  32093. * @param result defines the target Color4 to store the result in
  32094. */
  32095. getColorToRef(result: Color4): void;
  32096. }
  32097. /** Class used to store color 3 gradient */
  32098. export class Color3Gradient implements IValueGradient {
  32099. /**
  32100. * Gets or sets the gradient value (between 0 and 1)
  32101. */
  32102. gradient: number;
  32103. /**
  32104. * Gets or sets the associated color
  32105. */
  32106. color: Color3;
  32107. }
  32108. /** Class used to store factor gradient */
  32109. export class FactorGradient implements IValueGradient {
  32110. /**
  32111. * Gets or sets the gradient value (between 0 and 1)
  32112. */
  32113. gradient: number;
  32114. /**
  32115. * Gets or sets first associated factor
  32116. */
  32117. factor1: number;
  32118. /**
  32119. * Gets or sets second associated factor
  32120. */
  32121. factor2?: number;
  32122. /**
  32123. * Will get a number picked randomly between factor1 and factor2.
  32124. * If factor2 is undefined then factor1 will be used
  32125. * @returns the picked number
  32126. */
  32127. getFactor(): number;
  32128. }
  32129. /**
  32130. * @ignore
  32131. * Application error to support additional information when loading a file
  32132. */
  32133. export class LoadFileError extends Error {
  32134. /** defines the optional XHR request */
  32135. request?: XMLHttpRequest | undefined;
  32136. private static _setPrototypeOf;
  32137. /**
  32138. * Creates a new LoadFileError
  32139. * @param message defines the message of the error
  32140. * @param request defines the optional XHR request
  32141. */
  32142. constructor(message: string,
  32143. /** defines the optional XHR request */
  32144. request?: XMLHttpRequest | undefined);
  32145. }
  32146. /**
  32147. * Class used to define a retry strategy when error happens while loading assets
  32148. */
  32149. export class RetryStrategy {
  32150. /**
  32151. * Function used to defines an exponential back off strategy
  32152. * @param maxRetries defines the maximum number of retries (3 by default)
  32153. * @param baseInterval defines the interval between retries
  32154. * @returns the strategy function to use
  32155. */
  32156. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  32157. }
  32158. /**
  32159. * File request interface
  32160. */
  32161. export interface IFileRequest {
  32162. /**
  32163. * Raised when the request is complete (success or error).
  32164. */
  32165. onCompleteObservable: Observable<IFileRequest>;
  32166. /**
  32167. * Aborts the request for a file.
  32168. */
  32169. abort: () => void;
  32170. }
  32171. /**
  32172. * Class containing a set of static utilities functions
  32173. */
  32174. export class Tools {
  32175. /**
  32176. * Gets or sets the base URL to use to load assets
  32177. */
  32178. static BaseUrl: string;
  32179. /**
  32180. * Enable/Disable Custom HTTP Request Headers globally.
  32181. * default = false
  32182. * @see CustomRequestHeaders
  32183. */
  32184. static UseCustomRequestHeaders: boolean;
  32185. /**
  32186. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32187. * i.e. when loading files, where the server/service expects an Authorization header.
  32188. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  32189. */
  32190. static CustomRequestHeaders: {
  32191. [key: string]: string;
  32192. };
  32193. /**
  32194. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32195. */
  32196. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  32197. /**
  32198. * Default behaviour for cors in the application.
  32199. * It can be a string if the expected behavior is identical in the entire app.
  32200. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32201. */
  32202. static CorsBehavior: string | ((url: string | string[]) => string);
  32203. /**
  32204. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32205. * @ignorenaming
  32206. */
  32207. static UseFallbackTexture: boolean;
  32208. /**
  32209. * Use this object to register external classes like custom textures or material
  32210. * to allow the laoders to instantiate them
  32211. */
  32212. static RegisteredExternalClasses: {
  32213. [key: string]: Object;
  32214. };
  32215. /**
  32216. * Texture content used if a texture cannot loaded
  32217. * @ignorenaming
  32218. */
  32219. static fallbackTexture: string;
  32220. /**
  32221. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32222. * @param u defines the coordinate on X axis
  32223. * @param v defines the coordinate on Y axis
  32224. * @param width defines the width of the source data
  32225. * @param height defines the height of the source data
  32226. * @param pixels defines the source byte array
  32227. * @param color defines the output color
  32228. */
  32229. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32230. /**
  32231. * Interpolates between a and b via alpha
  32232. * @param a The lower value (returned when alpha = 0)
  32233. * @param b The upper value (returned when alpha = 1)
  32234. * @param alpha The interpolation-factor
  32235. * @return The mixed value
  32236. */
  32237. static Mix(a: number, b: number, alpha: number): number;
  32238. /**
  32239. * Tries to instantiate a new object from a given class name
  32240. * @param className defines the class name to instantiate
  32241. * @returns the new object or null if the system was not able to do the instantiation
  32242. */
  32243. static Instantiate(className: string): any;
  32244. /**
  32245. * Provides a slice function that will work even on IE
  32246. * @param data defines the array to slice
  32247. * @param start defines the start of the data (optional)
  32248. * @param end defines the end of the data (optional)
  32249. * @returns the new sliced array
  32250. */
  32251. static Slice<T>(data: T, start?: number, end?: number): T;
  32252. /**
  32253. * Polyfill for setImmediate
  32254. * @param action defines the action to execute after the current execution block
  32255. */
  32256. static SetImmediate(action: () => void): void;
  32257. /**
  32258. * Function indicating if a number is an exponent of 2
  32259. * @param value defines the value to test
  32260. * @returns true if the value is an exponent of 2
  32261. */
  32262. static IsExponentOfTwo(value: number): boolean;
  32263. private static _tmpFloatArray;
  32264. /**
  32265. * Returns the nearest 32-bit single precision float representation of a Number
  32266. * @param value A Number. If the parameter is of a different type, it will get converted
  32267. * to a number or to NaN if it cannot be converted
  32268. * @returns number
  32269. */
  32270. static FloatRound(value: number): number;
  32271. /**
  32272. * Find the next highest power of two.
  32273. * @param x Number to start search from.
  32274. * @return Next highest power of two.
  32275. */
  32276. static CeilingPOT(x: number): number;
  32277. /**
  32278. * Find the next lowest power of two.
  32279. * @param x Number to start search from.
  32280. * @return Next lowest power of two.
  32281. */
  32282. static FloorPOT(x: number): number;
  32283. /**
  32284. * Find the nearest power of two.
  32285. * @param x Number to start search from.
  32286. * @return Next nearest power of two.
  32287. */
  32288. static NearestPOT(x: number): number;
  32289. /**
  32290. * Get the closest exponent of two
  32291. * @param value defines the value to approximate
  32292. * @param max defines the maximum value to return
  32293. * @param mode defines how to define the closest value
  32294. * @returns closest exponent of two of the given value
  32295. */
  32296. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32297. /**
  32298. * Extracts the filename from a path
  32299. * @param path defines the path to use
  32300. * @returns the filename
  32301. */
  32302. static GetFilename(path: string): string;
  32303. /**
  32304. * Extracts the "folder" part of a path (everything before the filename).
  32305. * @param uri The URI to extract the info from
  32306. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32307. * @returns The "folder" part of the path
  32308. */
  32309. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32310. /**
  32311. * Extracts text content from a DOM element hierarchy
  32312. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32313. */
  32314. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32315. /**
  32316. * Convert an angle in radians to degrees
  32317. * @param angle defines the angle to convert
  32318. * @returns the angle in degrees
  32319. */
  32320. static ToDegrees(angle: number): number;
  32321. /**
  32322. * Convert an angle in degrees to radians
  32323. * @param angle defines the angle to convert
  32324. * @returns the angle in radians
  32325. */
  32326. static ToRadians(angle: number): number;
  32327. /**
  32328. * Encode a buffer to a base64 string
  32329. * @param buffer defines the buffer to encode
  32330. * @returns the encoded string
  32331. */
  32332. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32333. /**
  32334. * Extracts minimum and maximum values from a list of indexed positions
  32335. * @param positions defines the positions to use
  32336. * @param indices defines the indices to the positions
  32337. * @param indexStart defines the start index
  32338. * @param indexCount defines the end index
  32339. * @param bias defines bias value to add to the result
  32340. * @return minimum and maximum values
  32341. */
  32342. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32343. minimum: Vector3;
  32344. maximum: Vector3;
  32345. };
  32346. /**
  32347. * Extracts minimum and maximum values from a list of positions
  32348. * @param positions defines the positions to use
  32349. * @param start defines the start index in the positions array
  32350. * @param count defines the number of positions to handle
  32351. * @param bias defines bias value to add to the result
  32352. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32353. * @return minimum and maximum values
  32354. */
  32355. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32356. minimum: Vector3;
  32357. maximum: Vector3;
  32358. };
  32359. /**
  32360. * Returns an array if obj is not an array
  32361. * @param obj defines the object to evaluate as an array
  32362. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32363. * @returns either obj directly if obj is an array or a new array containing obj
  32364. */
  32365. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32366. /**
  32367. * Gets the pointer prefix to use
  32368. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32369. */
  32370. static GetPointerPrefix(): string;
  32371. /**
  32372. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32373. * @param func - the function to be called
  32374. * @param requester - the object that will request the next frame. Falls back to window.
  32375. * @returns frame number
  32376. */
  32377. static QueueNewFrame(func: () => void, requester?: any): number;
  32378. /**
  32379. * Ask the browser to promote the current element to fullscreen rendering mode
  32380. * @param element defines the DOM element to promote
  32381. */
  32382. static RequestFullscreen(element: HTMLElement): void;
  32383. /**
  32384. * Asks the browser to exit fullscreen mode
  32385. */
  32386. static ExitFullscreen(): void;
  32387. /**
  32388. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32389. * @param url define the url we are trying
  32390. * @param element define the dom element where to configure the cors policy
  32391. */
  32392. static SetCorsBehavior(url: string | string[], element: {
  32393. crossOrigin: string | null;
  32394. }): void;
  32395. /**
  32396. * Removes unwanted characters from an url
  32397. * @param url defines the url to clean
  32398. * @returns the cleaned url
  32399. */
  32400. static CleanUrl(url: string): string;
  32401. /**
  32402. * Gets or sets a function used to pre-process url before using them to load assets
  32403. */
  32404. static PreprocessUrl: (url: string) => string;
  32405. /**
  32406. * Loads an image as an HTMLImageElement.
  32407. * @param input url string, ArrayBuffer, or Blob to load
  32408. * @param onLoad callback called when the image successfully loads
  32409. * @param onError callback called when the image fails to load
  32410. * @param offlineProvider offline provider for caching
  32411. * @returns the HTMLImageElement of the loaded image
  32412. */
  32413. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32414. /**
  32415. * Loads a file
  32416. * @param url url string, ArrayBuffer, or Blob to load
  32417. * @param onSuccess callback called when the file successfully loads
  32418. * @param onProgress callback called while file is loading (if the server supports this mode)
  32419. * @param offlineProvider defines the offline provider for caching
  32420. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32421. * @param onError callback called when the file fails to load
  32422. * @returns a file request object
  32423. */
  32424. 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;
  32425. /**
  32426. * Load a script (identified by an url). When the url returns, the
  32427. * content of this file is added into a new script element, attached to the DOM (body element)
  32428. * @param scriptUrl defines the url of the script to laod
  32429. * @param onSuccess defines the callback called when the script is loaded
  32430. * @param onError defines the callback to call if an error occurs
  32431. */
  32432. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  32433. /**
  32434. * Loads a file from a blob
  32435. * @param fileToLoad defines the blob to use
  32436. * @param callback defines the callback to call when data is loaded
  32437. * @param progressCallback defines the callback to call during loading process
  32438. * @returns a file request object
  32439. */
  32440. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32441. /**
  32442. * Loads a file
  32443. * @param fileToLoad defines the file to load
  32444. * @param callback defines the callback to call when data is loaded
  32445. * @param progressCallBack defines the callback to call during loading process
  32446. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32447. * @returns a file request object
  32448. */
  32449. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32450. /**
  32451. * Creates a data url from a given string content
  32452. * @param content defines the content to convert
  32453. * @returns the new data url link
  32454. */
  32455. static FileAsURL(content: string): string;
  32456. /**
  32457. * Format the given number to a specific decimal format
  32458. * @param value defines the number to format
  32459. * @param decimals defines the number of decimals to use
  32460. * @returns the formatted string
  32461. */
  32462. static Format(value: number, decimals?: number): string;
  32463. /**
  32464. * Checks if a given vector is inside a specific range
  32465. * @param v defines the vector to test
  32466. * @param min defines the minimum range
  32467. * @param max defines the maximum range
  32468. */
  32469. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32470. /**
  32471. * Tries to copy an object by duplicating every property
  32472. * @param source defines the source object
  32473. * @param destination defines the target object
  32474. * @param doNotCopyList defines a list of properties to avoid
  32475. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32476. */
  32477. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32478. /**
  32479. * Gets a boolean indicating if the given object has no own property
  32480. * @param obj defines the object to test
  32481. * @returns true if object has no own property
  32482. */
  32483. static IsEmpty(obj: any): boolean;
  32484. /**
  32485. * Function used to register events at window level
  32486. * @param events defines the events to register
  32487. */
  32488. static RegisterTopRootEvents(events: {
  32489. name: string;
  32490. handler: Nullable<(e: FocusEvent) => any>;
  32491. }[]): void;
  32492. /**
  32493. * Function used to unregister events from window level
  32494. * @param events defines the events to unregister
  32495. */
  32496. static UnregisterTopRootEvents(events: {
  32497. name: string;
  32498. handler: Nullable<(e: FocusEvent) => any>;
  32499. }[]): void;
  32500. /**
  32501. * Dumps the current bound framebuffer
  32502. * @param width defines the rendering width
  32503. * @param height defines the rendering height
  32504. * @param engine defines the hosting engine
  32505. * @param successCallback defines the callback triggered once the data are available
  32506. * @param mimeType defines the mime type of the result
  32507. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32508. */
  32509. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32510. /**
  32511. * Converts the canvas data to blob.
  32512. * This acts as a polyfill for browsers not supporting the to blob function.
  32513. * @param canvas Defines the canvas to extract the data from
  32514. * @param successCallback Defines the callback triggered once the data are available
  32515. * @param mimeType Defines the mime type of the result
  32516. */
  32517. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32518. /**
  32519. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32520. * @param successCallback defines the callback triggered once the data are available
  32521. * @param mimeType defines the mime type of the result
  32522. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32523. */
  32524. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32525. /**
  32526. * Downloads a blob in the browser
  32527. * @param blob defines the blob to download
  32528. * @param fileName defines the name of the downloaded file
  32529. */
  32530. static Download(blob: Blob, fileName: string): void;
  32531. /**
  32532. * Captures a screenshot of the current rendering
  32533. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32534. * @param engine defines the rendering engine
  32535. * @param camera defines the source camera
  32536. * @param size This parameter can be set to a single number or to an object with the
  32537. * following (optional) properties: precision, width, height. If a single number is passed,
  32538. * it will be used for both width and height. If an object is passed, the screenshot size
  32539. * will be derived from the parameters. The precision property is a multiplier allowing
  32540. * rendering at a higher or lower resolution
  32541. * @param successCallback defines the callback receives a single parameter which contains the
  32542. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32543. * src parameter of an <img> to display it
  32544. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32545. * Check your browser for supported MIME types
  32546. */
  32547. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32548. /**
  32549. * Generates an image screenshot from the specified camera.
  32550. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32551. * @param engine The engine to use for rendering
  32552. * @param camera The camera to use for rendering
  32553. * @param size This parameter can be set to a single number or to an object with the
  32554. * following (optional) properties: precision, width, height. If a single number is passed,
  32555. * it will be used for both width and height. If an object is passed, the screenshot size
  32556. * will be derived from the parameters. The precision property is a multiplier allowing
  32557. * rendering at a higher or lower resolution
  32558. * @param successCallback The callback receives a single parameter which contains the
  32559. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32560. * src parameter of an <img> to display it
  32561. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32562. * Check your browser for supported MIME types
  32563. * @param samples Texture samples (default: 1)
  32564. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32565. * @param fileName A name for for the downloaded file.
  32566. */
  32567. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32568. /**
  32569. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32570. * Be aware Math.random() could cause collisions, but:
  32571. * "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"
  32572. * @returns a pseudo random id
  32573. */
  32574. static RandomId(): string;
  32575. /**
  32576. * Test if the given uri is a base64 string
  32577. * @param uri The uri to test
  32578. * @return True if the uri is a base64 string or false otherwise
  32579. */
  32580. static IsBase64(uri: string): boolean;
  32581. /**
  32582. * Decode the given base64 uri.
  32583. * @param uri The uri to decode
  32584. * @return The decoded base64 data.
  32585. */
  32586. static DecodeBase64(uri: string): ArrayBuffer;
  32587. /**
  32588. * No log
  32589. */
  32590. static readonly NoneLogLevel: number;
  32591. /**
  32592. * Only message logs
  32593. */
  32594. static readonly MessageLogLevel: number;
  32595. /**
  32596. * Only warning logs
  32597. */
  32598. static readonly WarningLogLevel: number;
  32599. /**
  32600. * Only error logs
  32601. */
  32602. static readonly ErrorLogLevel: number;
  32603. /**
  32604. * All logs
  32605. */
  32606. static readonly AllLogLevel: number;
  32607. /**
  32608. * Gets a value indicating the number of loading errors
  32609. * @ignorenaming
  32610. */
  32611. static readonly errorsCount: number;
  32612. /**
  32613. * Callback called when a new log is added
  32614. */
  32615. static OnNewCacheEntry: (entry: string) => void;
  32616. /**
  32617. * Log a message to the console
  32618. * @param message defines the message to log
  32619. */
  32620. static Log(message: string): void;
  32621. /**
  32622. * Write a warning message to the console
  32623. * @param message defines the message to log
  32624. */
  32625. static Warn(message: string): void;
  32626. /**
  32627. * Write an error message to the console
  32628. * @param message defines the message to log
  32629. */
  32630. static Error(message: string): void;
  32631. /**
  32632. * Gets current log cache (list of logs)
  32633. */
  32634. static readonly LogCache: string;
  32635. /**
  32636. * Clears the log cache
  32637. */
  32638. static ClearLogCache(): void;
  32639. /**
  32640. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32641. */
  32642. static LogLevels: number;
  32643. /**
  32644. * Checks if the loaded document was accessed via `file:`-Protocol.
  32645. * @returns boolean
  32646. */
  32647. static IsFileURL(): boolean;
  32648. /**
  32649. * Checks if the window object exists
  32650. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32651. */
  32652. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32653. /**
  32654. * No performance log
  32655. */
  32656. static readonly PerformanceNoneLogLevel: number;
  32657. /**
  32658. * Use user marks to log performance
  32659. */
  32660. static readonly PerformanceUserMarkLogLevel: number;
  32661. /**
  32662. * Log performance to the console
  32663. */
  32664. static readonly PerformanceConsoleLogLevel: number;
  32665. private static _performance;
  32666. /**
  32667. * Sets the current performance log level
  32668. */
  32669. static PerformanceLogLevel: number;
  32670. private static _StartPerformanceCounterDisabled;
  32671. private static _EndPerformanceCounterDisabled;
  32672. private static _StartUserMark;
  32673. private static _EndUserMark;
  32674. private static _StartPerformanceConsole;
  32675. private static _EndPerformanceConsole;
  32676. /**
  32677. * Injects the @see CustomRequestHeaders into the given request
  32678. * @param request the request that should be used for injection
  32679. */
  32680. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  32681. /**
  32682. * Starts a performance counter
  32683. */
  32684. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32685. /**
  32686. * Ends a specific performance coutner
  32687. */
  32688. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32689. /**
  32690. * Gets either window.performance.now() if supported or Date.now() else
  32691. */
  32692. static readonly Now: number;
  32693. /**
  32694. * This method will return the name of the class used to create the instance of the given object.
  32695. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32696. * @param object the object to get the class name from
  32697. * @param isType defines if the object is actually a type
  32698. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32699. */
  32700. static GetClassName(object: any, isType?: boolean): string;
  32701. /**
  32702. * Gets the first element of an array satisfying a given predicate
  32703. * @param array defines the array to browse
  32704. * @param predicate defines the predicate to use
  32705. * @returns null if not found or the element
  32706. */
  32707. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32708. /**
  32709. * This method will return the name of the full name of the class, including its owning module (if any).
  32710. * 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).
  32711. * @param object the object to get the class name from
  32712. * @param isType defines if the object is actually a type
  32713. * @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.
  32714. * @ignorenaming
  32715. */
  32716. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32717. /**
  32718. * Returns a promise that resolves after the given amount of time.
  32719. * @param delay Number of milliseconds to delay
  32720. * @returns Promise that resolves after the given amount of time
  32721. */
  32722. static DelayAsync(delay: number): Promise<void>;
  32723. /**
  32724. * Gets the current gradient from an array of IValueGradient
  32725. * @param ratio defines the current ratio to get
  32726. * @param gradients defines the array of IValueGradient
  32727. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32728. */
  32729. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32730. }
  32731. /**
  32732. * This class is used to track a performance counter which is number based.
  32733. * The user has access to many properties which give statistics of different nature.
  32734. *
  32735. * The implementer can track two kinds of Performance Counter: time and count.
  32736. * 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.
  32737. * 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.
  32738. */
  32739. export class PerfCounter {
  32740. /**
  32741. * Gets or sets a global boolean to turn on and off all the counters
  32742. */
  32743. static Enabled: boolean;
  32744. /**
  32745. * Returns the smallest value ever
  32746. */
  32747. readonly min: number;
  32748. /**
  32749. * Returns the biggest value ever
  32750. */
  32751. readonly max: number;
  32752. /**
  32753. * Returns the average value since the performance counter is running
  32754. */
  32755. readonly average: number;
  32756. /**
  32757. * Returns the average value of the last second the counter was monitored
  32758. */
  32759. readonly lastSecAverage: number;
  32760. /**
  32761. * Returns the current value
  32762. */
  32763. readonly current: number;
  32764. /**
  32765. * Gets the accumulated total
  32766. */
  32767. readonly total: number;
  32768. /**
  32769. * Gets the total value count
  32770. */
  32771. readonly count: number;
  32772. /**
  32773. * Creates a new counter
  32774. */
  32775. constructor();
  32776. /**
  32777. * Call this method to start monitoring a new frame.
  32778. * 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.
  32779. */
  32780. fetchNewFrame(): void;
  32781. /**
  32782. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32783. * @param newCount the count value to add to the monitored count
  32784. * @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.
  32785. */
  32786. addCount(newCount: number, fetchResult: boolean): void;
  32787. /**
  32788. * Start monitoring this performance counter
  32789. */
  32790. beginMonitoring(): void;
  32791. /**
  32792. * Compute the time lapsed since the previous beginMonitoring() call.
  32793. * @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
  32794. */
  32795. endMonitoring(newFrame?: boolean): void;
  32796. private _fetchResult;
  32797. private _startMonitoringTime;
  32798. private _min;
  32799. private _max;
  32800. private _average;
  32801. private _current;
  32802. private _totalValueCount;
  32803. private _totalAccumulated;
  32804. private _lastSecAverage;
  32805. private _lastSecAccumulated;
  32806. private _lastSecTime;
  32807. private _lastSecValueCount;
  32808. }
  32809. /**
  32810. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32811. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32812. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32813. * @param name The name of the class, case should be preserved
  32814. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32815. */
  32816. export function className(name: string, module?: string): (target: Object) => void;
  32817. /**
  32818. * An implementation of a loop for asynchronous functions.
  32819. */
  32820. export class AsyncLoop {
  32821. /**
  32822. * Defines the number of iterations for the loop
  32823. */
  32824. iterations: number;
  32825. /**
  32826. * Defines the current index of the loop.
  32827. */
  32828. index: number;
  32829. private _done;
  32830. private _fn;
  32831. private _successCallback;
  32832. /**
  32833. * Constructor.
  32834. * @param iterations the number of iterations.
  32835. * @param func the function to run each iteration
  32836. * @param successCallback the callback that will be called upon succesful execution
  32837. * @param offset starting offset.
  32838. */
  32839. constructor(
  32840. /**
  32841. * Defines the number of iterations for the loop
  32842. */
  32843. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32844. /**
  32845. * Execute the next iteration. Must be called after the last iteration was finished.
  32846. */
  32847. executeNext(): void;
  32848. /**
  32849. * Break the loop and run the success callback.
  32850. */
  32851. breakLoop(): void;
  32852. /**
  32853. * Create and run an async loop.
  32854. * @param iterations the number of iterations.
  32855. * @param fn the function to run each iteration
  32856. * @param successCallback the callback that will be called upon succesful execution
  32857. * @param offset starting offset.
  32858. * @returns the created async loop object
  32859. */
  32860. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32861. /**
  32862. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32863. * @param iterations total number of iterations
  32864. * @param syncedIterations number of synchronous iterations in each async iteration.
  32865. * @param fn the function to call each iteration.
  32866. * @param callback a success call back that will be called when iterating stops.
  32867. * @param breakFunction a break condition (optional)
  32868. * @param timeout timeout settings for the setTimeout function. default - 0.
  32869. * @returns the created async loop object
  32870. */
  32871. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32872. }
  32873. }
  32874. declare module "babylonjs/Animations/animationGroup" {
  32875. import { Animatable } from "babylonjs/Animations/animatable";
  32876. import { Animation } from "babylonjs/Animations/animation";
  32877. import { Scene, IDisposable } from "babylonjs/scene";
  32878. import { Observable } from "babylonjs/Misc/observable";
  32879. import { Nullable } from "babylonjs/types";
  32880. /**
  32881. * This class defines the direct association between an animation and a target
  32882. */
  32883. export class TargetedAnimation {
  32884. /**
  32885. * Animation to perform
  32886. */
  32887. animation: Animation;
  32888. /**
  32889. * Target to animate
  32890. */
  32891. target: any;
  32892. }
  32893. /**
  32894. * Use this class to create coordinated animations on multiple targets
  32895. */
  32896. export class AnimationGroup implements IDisposable {
  32897. /** The name of the animation group */
  32898. name: string;
  32899. private _scene;
  32900. private _targetedAnimations;
  32901. private _animatables;
  32902. private _from;
  32903. private _to;
  32904. private _isStarted;
  32905. private _isPaused;
  32906. private _speedRatio;
  32907. /**
  32908. * Gets or sets the unique id of the node
  32909. */
  32910. uniqueId: number;
  32911. /**
  32912. * This observable will notify when one animation have ended
  32913. */
  32914. onAnimationEndObservable: Observable<TargetedAnimation>;
  32915. /**
  32916. * Observer raised when one animation loops
  32917. */
  32918. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32919. /**
  32920. * This observable will notify when all animations have ended.
  32921. */
  32922. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32923. /**
  32924. * This observable will notify when all animations have paused.
  32925. */
  32926. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32927. /**
  32928. * This observable will notify when all animations are playing.
  32929. */
  32930. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32931. /**
  32932. * Gets the first frame
  32933. */
  32934. readonly from: number;
  32935. /**
  32936. * Gets the last frame
  32937. */
  32938. readonly to: number;
  32939. /**
  32940. * Define if the animations are started
  32941. */
  32942. readonly isStarted: boolean;
  32943. /**
  32944. * Gets a value indicating that the current group is playing
  32945. */
  32946. readonly isPlaying: boolean;
  32947. /**
  32948. * Gets or sets the speed ratio to use for all animations
  32949. */
  32950. /**
  32951. * Gets or sets the speed ratio to use for all animations
  32952. */
  32953. speedRatio: number;
  32954. /**
  32955. * Gets the targeted animations for this animation group
  32956. */
  32957. readonly targetedAnimations: Array<TargetedAnimation>;
  32958. /**
  32959. * returning the list of animatables controlled by this animation group.
  32960. */
  32961. readonly animatables: Array<Animatable>;
  32962. /**
  32963. * Instantiates a new Animation Group.
  32964. * This helps managing several animations at once.
  32965. * @see http://doc.babylonjs.com/how_to/group
  32966. * @param name Defines the name of the group
  32967. * @param scene Defines the scene the group belongs to
  32968. */
  32969. constructor(
  32970. /** The name of the animation group */
  32971. name: string, scene?: Nullable<Scene>);
  32972. /**
  32973. * Add an animation (with its target) in the group
  32974. * @param animation defines the animation we want to add
  32975. * @param target defines the target of the animation
  32976. * @returns the TargetedAnimation object
  32977. */
  32978. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32979. /**
  32980. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32981. * It can add constant keys at begin or end
  32982. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32983. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32984. * @returns the animation group
  32985. */
  32986. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32987. /**
  32988. * Start all animations on given targets
  32989. * @param loop defines if animations must loop
  32990. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32991. * @param from defines the from key (optional)
  32992. * @param to defines the to key (optional)
  32993. * @returns the current animation group
  32994. */
  32995. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32996. /**
  32997. * Pause all animations
  32998. * @returns the animation group
  32999. */
  33000. pause(): AnimationGroup;
  33001. /**
  33002. * Play all animations to initial state
  33003. * This function will start() the animations if they were not started or will restart() them if they were paused
  33004. * @param loop defines if animations must loop
  33005. * @returns the animation group
  33006. */
  33007. play(loop?: boolean): AnimationGroup;
  33008. /**
  33009. * Reset all animations to initial state
  33010. * @returns the animation group
  33011. */
  33012. reset(): AnimationGroup;
  33013. /**
  33014. * Restart animations from key 0
  33015. * @returns the animation group
  33016. */
  33017. restart(): AnimationGroup;
  33018. /**
  33019. * Stop all animations
  33020. * @returns the animation group
  33021. */
  33022. stop(): AnimationGroup;
  33023. /**
  33024. * Set animation weight for all animatables
  33025. * @param weight defines the weight to use
  33026. * @return the animationGroup
  33027. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33028. */
  33029. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33030. /**
  33031. * Synchronize and normalize all animatables with a source animatable
  33032. * @param root defines the root animatable to synchronize with
  33033. * @return the animationGroup
  33034. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33035. */
  33036. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33037. /**
  33038. * Goes to a specific frame in this animation group
  33039. * @param frame the frame number to go to
  33040. * @return the animationGroup
  33041. */
  33042. goToFrame(frame: number): AnimationGroup;
  33043. /**
  33044. * Dispose all associated resources
  33045. */
  33046. dispose(): void;
  33047. private _checkAnimationGroupEnded;
  33048. /**
  33049. * Returns a new AnimationGroup object parsed from the source provided.
  33050. * @param parsedAnimationGroup defines the source
  33051. * @param scene defines the scene that will receive the animationGroup
  33052. * @returns a new AnimationGroup
  33053. */
  33054. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33055. /**
  33056. * Returns the string "AnimationGroup"
  33057. * @returns "AnimationGroup"
  33058. */
  33059. getClassName(): string;
  33060. /**
  33061. * Creates a detailled string about the object
  33062. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33063. * @returns a string representing the object
  33064. */
  33065. toString(fullDetails?: boolean): string;
  33066. }
  33067. }
  33068. declare module "babylonjs/Collisions/collisionCoordinator" {
  33069. import { Nullable } from "babylonjs/types";
  33070. import { Scene } from "babylonjs/scene";
  33071. import { Vector3 } from "babylonjs/Maths/math";
  33072. import { Collider } from "babylonjs/Collisions/collider";
  33073. import { Geometry } from "babylonjs/Meshes/geometry";
  33074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33075. /** @hidden */
  33076. export interface ICollisionCoordinator {
  33077. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33078. init(scene: Scene): void;
  33079. destroy(): void;
  33080. onMeshAdded(mesh: AbstractMesh): void;
  33081. onMeshUpdated(mesh: AbstractMesh): void;
  33082. onMeshRemoved(mesh: AbstractMesh): void;
  33083. onGeometryAdded(geometry: Geometry): void;
  33084. onGeometryUpdated(geometry: Geometry): void;
  33085. onGeometryDeleted(geometry: Geometry): void;
  33086. }
  33087. /** @hidden */
  33088. export class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  33089. private _scene;
  33090. private _scaledPosition;
  33091. private _scaledVelocity;
  33092. private _finalPosition;
  33093. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33094. init(scene: Scene): void;
  33095. destroy(): void;
  33096. onMeshAdded(mesh: AbstractMesh): void;
  33097. onMeshUpdated(mesh: AbstractMesh): void;
  33098. onMeshRemoved(mesh: AbstractMesh): void;
  33099. onGeometryAdded(geometry: Geometry): void;
  33100. onGeometryUpdated(geometry: Geometry): void;
  33101. onGeometryDeleted(geometry: Geometry): void;
  33102. private _collideWithWorld;
  33103. }
  33104. }
  33105. declare module "babylonjs/scene" {
  33106. import { Nullable } from "babylonjs/types";
  33107. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  33108. import { Observable } from "babylonjs/Misc/observable";
  33109. import { SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33110. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  33111. import { Geometry } from "babylonjs/Meshes/geometry";
  33112. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33113. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33115. import { Mesh } from "babylonjs/Meshes/mesh";
  33116. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33117. import { Bone } from "babylonjs/Bones/bone";
  33118. import { Skeleton } from "babylonjs/Bones/skeleton";
  33119. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33120. import { Camera } from "babylonjs/Cameras/camera";
  33121. import { AbstractScene } from "babylonjs/abstractScene";
  33122. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33123. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33124. import { Material } from "babylonjs/Materials/material";
  33125. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33126. import { Effect } from "babylonjs/Materials/effect";
  33127. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33128. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33129. import { Animation } from "babylonjs/Animations/animation";
  33130. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33131. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33132. import { Animatable } from "babylonjs/Animations/animatable";
  33133. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33134. import { Light } from "babylonjs/Lights/light";
  33135. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33136. import { Collider } from "babylonjs/Collisions/collider";
  33137. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33138. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33139. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33140. import { ActionManager } from "babylonjs/Actions/actionManager";
  33141. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33142. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33143. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33144. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33145. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  33146. import { Engine } from "babylonjs/Engines/engine";
  33147. import { Ray } from "babylonjs/Culling/ray";
  33148. import { Node } from "babylonjs/node";
  33149. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33150. /**
  33151. * Define an interface for all classes that will hold resources
  33152. */
  33153. export interface IDisposable {
  33154. /**
  33155. * Releases all held resources
  33156. */
  33157. dispose(): void;
  33158. }
  33159. /** Interface defining initialization parameters for Scene class */
  33160. export interface SceneOptions {
  33161. /**
  33162. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33163. * It will improve performance when the number of geometries becomes important.
  33164. */
  33165. useGeometryUniqueIdsMap?: boolean;
  33166. /**
  33167. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33168. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33169. */
  33170. useMaterialMeshMap?: boolean;
  33171. /**
  33172. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33173. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33174. */
  33175. useClonedMeshhMap?: boolean;
  33176. }
  33177. /**
  33178. * Represents a scene to be rendered by the engine.
  33179. * @see http://doc.babylonjs.com/features/scene
  33180. */
  33181. export class Scene extends AbstractScene implements IAnimatable {
  33182. private static _uniqueIdCounter;
  33183. /** The fog is deactivated */
  33184. static readonly FOGMODE_NONE: number;
  33185. /** The fog density is following an exponential function */
  33186. static readonly FOGMODE_EXP: number;
  33187. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33188. static readonly FOGMODE_EXP2: number;
  33189. /** The fog density is following a linear function. */
  33190. static readonly FOGMODE_LINEAR: number;
  33191. /**
  33192. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33193. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33194. */
  33195. static MinDeltaTime: number;
  33196. /**
  33197. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33198. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33199. */
  33200. static MaxDeltaTime: number;
  33201. /**
  33202. * Factory used to create the default material.
  33203. * @param name The name of the material to create
  33204. * @param scene The scene to create the material for
  33205. * @returns The default material
  33206. */
  33207. static DefaultMaterialFactory(scene: Scene): Material;
  33208. /** @hidden */
  33209. readonly _isScene: boolean;
  33210. /**
  33211. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33212. */
  33213. autoClear: boolean;
  33214. /**
  33215. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33216. */
  33217. autoClearDepthAndStencil: boolean;
  33218. /**
  33219. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33220. */
  33221. clearColor: Color4;
  33222. /**
  33223. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33224. */
  33225. ambientColor: Color3;
  33226. /** @hidden */
  33227. _environmentBRDFTexture: BaseTexture;
  33228. /** @hidden */
  33229. protected _environmentTexture: Nullable<BaseTexture>;
  33230. /**
  33231. * Texture used in all pbr material as the reflection texture.
  33232. * As in the majority of the scene they are the same (exception for multi room and so on),
  33233. * this is easier to reference from here than from all the materials.
  33234. */
  33235. /**
  33236. * Texture used in all pbr material as the reflection texture.
  33237. * As in the majority of the scene they are the same (exception for multi room and so on),
  33238. * this is easier to set here than in all the materials.
  33239. */
  33240. environmentTexture: Nullable<BaseTexture>;
  33241. /** @hidden */
  33242. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33243. /**
  33244. * Default image processing configuration used either in the rendering
  33245. * Forward main pass or through the imageProcessingPostProcess if present.
  33246. * As in the majority of the scene they are the same (exception for multi camera),
  33247. * this is easier to reference from here than from all the materials and post process.
  33248. *
  33249. * No setter as we it is a shared configuration, you can set the values instead.
  33250. */
  33251. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33252. private _forceWireframe;
  33253. /**
  33254. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33255. */
  33256. forceWireframe: boolean;
  33257. private _forcePointsCloud;
  33258. /**
  33259. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33260. */
  33261. forcePointsCloud: boolean;
  33262. /**
  33263. * Gets or sets the active clipplane 1
  33264. */
  33265. clipPlane: Nullable<Plane>;
  33266. /**
  33267. * Gets or sets the active clipplane 2
  33268. */
  33269. clipPlane2: Nullable<Plane>;
  33270. /**
  33271. * Gets or sets the active clipplane 3
  33272. */
  33273. clipPlane3: Nullable<Plane>;
  33274. /**
  33275. * Gets or sets the active clipplane 4
  33276. */
  33277. clipPlane4: Nullable<Plane>;
  33278. /**
  33279. * Gets or sets a boolean indicating if animations are enabled
  33280. */
  33281. animationsEnabled: boolean;
  33282. private _animationPropertiesOverride;
  33283. /**
  33284. * Gets or sets the animation properties override
  33285. */
  33286. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33287. /**
  33288. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33289. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33290. */
  33291. useConstantAnimationDeltaTime: boolean;
  33292. /**
  33293. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33294. * Please note that it requires to run a ray cast through the scene on every frame
  33295. */
  33296. constantlyUpdateMeshUnderPointer: boolean;
  33297. /**
  33298. * Defines the HTML cursor to use when hovering over interactive elements
  33299. */
  33300. hoverCursor: string;
  33301. /**
  33302. * Defines the HTML default cursor to use (empty by default)
  33303. */
  33304. defaultCursor: string;
  33305. /**
  33306. * This is used to call preventDefault() on pointer down
  33307. * in order to block unwanted artifacts like system double clicks
  33308. */
  33309. preventDefaultOnPointerDown: boolean;
  33310. /**
  33311. * This is used to call preventDefault() on pointer up
  33312. * in order to block unwanted artifacts like system double clicks
  33313. */
  33314. preventDefaultOnPointerUp: boolean;
  33315. /**
  33316. * Gets or sets user defined metadata
  33317. */
  33318. metadata: any;
  33319. /**
  33320. * For internal use only. Please do not use.
  33321. */
  33322. reservedDataStore: any;
  33323. /**
  33324. * Gets the name of the plugin used to load this scene (null by default)
  33325. */
  33326. loadingPluginName: string;
  33327. /**
  33328. * Use this array to add regular expressions used to disable offline support for specific urls
  33329. */
  33330. disableOfflineSupportExceptionRules: RegExp[];
  33331. /**
  33332. * An event triggered when the scene is disposed.
  33333. */
  33334. onDisposeObservable: Observable<Scene>;
  33335. private _onDisposeObserver;
  33336. /** Sets a function to be executed when this scene is disposed. */
  33337. onDispose: () => void;
  33338. /**
  33339. * An event triggered before rendering the scene (right after animations and physics)
  33340. */
  33341. onBeforeRenderObservable: Observable<Scene>;
  33342. private _onBeforeRenderObserver;
  33343. /** Sets a function to be executed before rendering this scene */
  33344. beforeRender: Nullable<() => void>;
  33345. /**
  33346. * An event triggered after rendering the scene
  33347. */
  33348. onAfterRenderObservable: Observable<Scene>;
  33349. private _onAfterRenderObserver;
  33350. /** Sets a function to be executed after rendering this scene */
  33351. afterRender: Nullable<() => void>;
  33352. /**
  33353. * An event triggered before animating the scene
  33354. */
  33355. onBeforeAnimationsObservable: Observable<Scene>;
  33356. /**
  33357. * An event triggered after animations processing
  33358. */
  33359. onAfterAnimationsObservable: Observable<Scene>;
  33360. /**
  33361. * An event triggered before draw calls are ready to be sent
  33362. */
  33363. onBeforeDrawPhaseObservable: Observable<Scene>;
  33364. /**
  33365. * An event triggered after draw calls have been sent
  33366. */
  33367. onAfterDrawPhaseObservable: Observable<Scene>;
  33368. /**
  33369. * An event triggered when the scene is ready
  33370. */
  33371. onReadyObservable: Observable<Scene>;
  33372. /**
  33373. * An event triggered before rendering a camera
  33374. */
  33375. onBeforeCameraRenderObservable: Observable<Camera>;
  33376. private _onBeforeCameraRenderObserver;
  33377. /** Sets a function to be executed before rendering a camera*/
  33378. beforeCameraRender: () => void;
  33379. /**
  33380. * An event triggered after rendering a camera
  33381. */
  33382. onAfterCameraRenderObservable: Observable<Camera>;
  33383. private _onAfterCameraRenderObserver;
  33384. /** Sets a function to be executed after rendering a camera*/
  33385. afterCameraRender: () => void;
  33386. /**
  33387. * An event triggered when active meshes evaluation is about to start
  33388. */
  33389. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33390. /**
  33391. * An event triggered when active meshes evaluation is done
  33392. */
  33393. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33394. /**
  33395. * An event triggered when particles rendering is about to start
  33396. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33397. */
  33398. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33399. /**
  33400. * An event triggered when particles rendering is done
  33401. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33402. */
  33403. onAfterParticlesRenderingObservable: Observable<Scene>;
  33404. /**
  33405. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33406. */
  33407. onDataLoadedObservable: Observable<Scene>;
  33408. /**
  33409. * An event triggered when a camera is created
  33410. */
  33411. onNewCameraAddedObservable: Observable<Camera>;
  33412. /**
  33413. * An event triggered when a camera is removed
  33414. */
  33415. onCameraRemovedObservable: Observable<Camera>;
  33416. /**
  33417. * An event triggered when a light is created
  33418. */
  33419. onNewLightAddedObservable: Observable<Light>;
  33420. /**
  33421. * An event triggered when a light is removed
  33422. */
  33423. onLightRemovedObservable: Observable<Light>;
  33424. /**
  33425. * An event triggered when a geometry is created
  33426. */
  33427. onNewGeometryAddedObservable: Observable<Geometry>;
  33428. /**
  33429. * An event triggered when a geometry is removed
  33430. */
  33431. onGeometryRemovedObservable: Observable<Geometry>;
  33432. /**
  33433. * An event triggered when a transform node is created
  33434. */
  33435. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33436. /**
  33437. * An event triggered when a transform node is removed
  33438. */
  33439. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33440. /**
  33441. * An event triggered when a mesh is created
  33442. */
  33443. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33444. /**
  33445. * An event triggered when a mesh is removed
  33446. */
  33447. onMeshRemovedObservable: Observable<AbstractMesh>;
  33448. /**
  33449. * An event triggered when a material is created
  33450. */
  33451. onNewMaterialAddedObservable: Observable<Material>;
  33452. /**
  33453. * An event triggered when a material is removed
  33454. */
  33455. onMaterialRemovedObservable: Observable<Material>;
  33456. /**
  33457. * An event triggered when a texture is created
  33458. */
  33459. onNewTextureAddedObservable: Observable<BaseTexture>;
  33460. /**
  33461. * An event triggered when a texture is removed
  33462. */
  33463. onTextureRemovedObservable: Observable<BaseTexture>;
  33464. /**
  33465. * An event triggered when render targets are about to be rendered
  33466. * Can happen multiple times per frame.
  33467. */
  33468. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33469. /**
  33470. * An event triggered when render targets were rendered.
  33471. * Can happen multiple times per frame.
  33472. */
  33473. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33474. /**
  33475. * An event triggered before calculating deterministic simulation step
  33476. */
  33477. onBeforeStepObservable: Observable<Scene>;
  33478. /**
  33479. * An event triggered after calculating deterministic simulation step
  33480. */
  33481. onAfterStepObservable: Observable<Scene>;
  33482. /**
  33483. * An event triggered when the activeCamera property is updated
  33484. */
  33485. onActiveCameraChanged: Observable<Scene>;
  33486. /**
  33487. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33488. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33489. * 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)
  33490. */
  33491. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33492. /**
  33493. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33494. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33495. * 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)
  33496. */
  33497. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33498. /**
  33499. * This Observable will when a mesh has been imported into the scene.
  33500. */
  33501. onMeshImportedObservable: Observable<AbstractMesh>;
  33502. private _registeredForLateAnimationBindings;
  33503. /**
  33504. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33505. */
  33506. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33507. /**
  33508. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33509. */
  33510. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33511. /**
  33512. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33513. */
  33514. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33515. private _onPointerMove;
  33516. private _onPointerDown;
  33517. private _onPointerUp;
  33518. /** Callback called when a pointer move is detected */
  33519. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33520. /** Callback called when a pointer down is detected */
  33521. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33522. /** Callback called when a pointer up is detected */
  33523. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33524. /** Callback called when a pointer pick is detected */
  33525. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33526. /**
  33527. * 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).
  33528. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33529. */
  33530. onPrePointerObservable: Observable<PointerInfoPre>;
  33531. /**
  33532. * Observable event triggered each time an input event is received from the rendering canvas
  33533. */
  33534. onPointerObservable: Observable<PointerInfo>;
  33535. /**
  33536. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33537. */
  33538. readonly unTranslatedPointer: Vector2;
  33539. /** The distance in pixel that you have to move to prevent some events */
  33540. static DragMovementThreshold: number;
  33541. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33542. static LongPressDelay: number;
  33543. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33544. static DoubleClickDelay: number;
  33545. /** If you need to check double click without raising a single click at first click, enable this flag */
  33546. static ExclusiveDoubleClickMode: boolean;
  33547. private _initClickEvent;
  33548. private _initActionManager;
  33549. private _delayedSimpleClick;
  33550. private _delayedSimpleClickTimeout;
  33551. private _previousDelayedSimpleClickTimeout;
  33552. private _meshPickProceed;
  33553. private _previousButtonPressed;
  33554. private _currentPickResult;
  33555. private _previousPickResult;
  33556. private _totalPointersPressed;
  33557. private _doubleClickOccured;
  33558. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33559. cameraToUseForPointers: Nullable<Camera>;
  33560. private _pointerX;
  33561. private _pointerY;
  33562. private _unTranslatedPointerX;
  33563. private _unTranslatedPointerY;
  33564. private _startingPointerPosition;
  33565. private _previousStartingPointerPosition;
  33566. private _startingPointerTime;
  33567. private _previousStartingPointerTime;
  33568. private _pointerCaptures;
  33569. private _timeAccumulator;
  33570. private _currentStepId;
  33571. private _currentInternalStep;
  33572. /** @hidden */
  33573. _mirroredCameraPosition: Nullable<Vector3>;
  33574. /**
  33575. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33576. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33577. */
  33578. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33579. /**
  33580. * Observable event triggered each time an keyboard event is received from the hosting window
  33581. */
  33582. onKeyboardObservable: Observable<KeyboardInfo>;
  33583. private _onKeyDown;
  33584. private _onKeyUp;
  33585. private _onCanvasFocusObserver;
  33586. private _onCanvasBlurObserver;
  33587. private _useRightHandedSystem;
  33588. /**
  33589. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33590. */
  33591. useRightHandedSystem: boolean;
  33592. /**
  33593. * Sets the step Id used by deterministic lock step
  33594. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33595. * @param newStepId defines the step Id
  33596. */
  33597. setStepId(newStepId: number): void;
  33598. /**
  33599. * Gets the step Id used by deterministic lock step
  33600. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33601. * @returns the step Id
  33602. */
  33603. getStepId(): number;
  33604. /**
  33605. * Gets the internal step used by deterministic lock step
  33606. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33607. * @returns the internal step
  33608. */
  33609. getInternalStep(): number;
  33610. private _fogEnabled;
  33611. /**
  33612. * Gets or sets a boolean indicating if fog is enabled on this scene
  33613. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33614. * (Default is true)
  33615. */
  33616. fogEnabled: boolean;
  33617. private _fogMode;
  33618. /**
  33619. * Gets or sets the fog mode to use
  33620. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33621. * | mode | value |
  33622. * | --- | --- |
  33623. * | FOGMODE_NONE | 0 |
  33624. * | FOGMODE_EXP | 1 |
  33625. * | FOGMODE_EXP2 | 2 |
  33626. * | FOGMODE_LINEAR | 3 |
  33627. */
  33628. fogMode: number;
  33629. /**
  33630. * Gets or sets the fog color to use
  33631. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33632. * (Default is Color3(0.2, 0.2, 0.3))
  33633. */
  33634. fogColor: Color3;
  33635. /**
  33636. * Gets or sets the fog density to use
  33637. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33638. * (Default is 0.1)
  33639. */
  33640. fogDensity: number;
  33641. /**
  33642. * Gets or sets the fog start distance to use
  33643. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33644. * (Default is 0)
  33645. */
  33646. fogStart: number;
  33647. /**
  33648. * Gets or sets the fog end distance to use
  33649. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33650. * (Default is 1000)
  33651. */
  33652. fogEnd: number;
  33653. private _shadowsEnabled;
  33654. /**
  33655. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33656. */
  33657. shadowsEnabled: boolean;
  33658. private _lightsEnabled;
  33659. /**
  33660. * Gets or sets a boolean indicating if lights are enabled on this scene
  33661. */
  33662. lightsEnabled: boolean;
  33663. /** All of the active cameras added to this scene. */
  33664. activeCameras: Camera[];
  33665. private _activeCamera;
  33666. /** Gets or sets the current active camera */
  33667. activeCamera: Nullable<Camera>;
  33668. private _defaultMaterial;
  33669. /** The default material used on meshes when no material is affected */
  33670. /** The default material used on meshes when no material is affected */
  33671. defaultMaterial: Material;
  33672. private _texturesEnabled;
  33673. /**
  33674. * Gets or sets a boolean indicating if textures are enabled on this scene
  33675. */
  33676. texturesEnabled: boolean;
  33677. /**
  33678. * Gets or sets a boolean indicating if particles are enabled on this scene
  33679. */
  33680. particlesEnabled: boolean;
  33681. /**
  33682. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33683. */
  33684. spritesEnabled: boolean;
  33685. private _skeletonsEnabled;
  33686. /**
  33687. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33688. */
  33689. skeletonsEnabled: boolean;
  33690. /**
  33691. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33692. */
  33693. lensFlaresEnabled: boolean;
  33694. /**
  33695. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33696. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33697. */
  33698. collisionsEnabled: boolean;
  33699. /** @hidden */
  33700. collisionCoordinator: ICollisionCoordinator;
  33701. /**
  33702. * Defines the gravity applied to this scene (used only for collisions)
  33703. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33704. */
  33705. gravity: Vector3;
  33706. /**
  33707. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33708. */
  33709. postProcessesEnabled: boolean;
  33710. /**
  33711. * The list of postprocesses added to the scene
  33712. */
  33713. postProcesses: PostProcess[];
  33714. /**
  33715. * Gets the current postprocess manager
  33716. */
  33717. postProcessManager: PostProcessManager;
  33718. /**
  33719. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33720. */
  33721. renderTargetsEnabled: boolean;
  33722. /**
  33723. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33724. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33725. */
  33726. dumpNextRenderTargets: boolean;
  33727. /**
  33728. * The list of user defined render targets added to the scene
  33729. */
  33730. customRenderTargets: RenderTargetTexture[];
  33731. /**
  33732. * Defines if texture loading must be delayed
  33733. * If true, textures will only be loaded when they need to be rendered
  33734. */
  33735. useDelayedTextureLoading: boolean;
  33736. /**
  33737. * Gets the list of meshes imported to the scene through SceneLoader
  33738. */
  33739. importedMeshesFiles: String[];
  33740. /**
  33741. * Gets or sets a boolean indicating if probes are enabled on this scene
  33742. */
  33743. probesEnabled: boolean;
  33744. /**
  33745. * Gets or sets the current offline provider to use to store scene data
  33746. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33747. */
  33748. offlineProvider: IOfflineProvider;
  33749. /**
  33750. * Gets or sets the action manager associated with the scene
  33751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33752. */
  33753. actionManager: ActionManager;
  33754. private _meshesForIntersections;
  33755. /**
  33756. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33757. */
  33758. proceduralTexturesEnabled: boolean;
  33759. private _engine;
  33760. private _totalVertices;
  33761. /** @hidden */
  33762. _activeIndices: PerfCounter;
  33763. /** @hidden */
  33764. _activeParticles: PerfCounter;
  33765. /** @hidden */
  33766. _activeBones: PerfCounter;
  33767. private _animationRatio;
  33768. private _animationTimeLast;
  33769. private _animationTime;
  33770. /**
  33771. * Gets or sets a general scale for animation speed
  33772. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33773. */
  33774. animationTimeScale: number;
  33775. /** @hidden */
  33776. _cachedMaterial: Nullable<Material>;
  33777. /** @hidden */
  33778. _cachedEffect: Nullable<Effect>;
  33779. /** @hidden */
  33780. _cachedVisibility: Nullable<number>;
  33781. private _renderId;
  33782. private _frameId;
  33783. private _executeWhenReadyTimeoutId;
  33784. private _intermediateRendering;
  33785. private _viewUpdateFlag;
  33786. private _projectionUpdateFlag;
  33787. private _alternateViewUpdateFlag;
  33788. private _alternateProjectionUpdateFlag;
  33789. /** @hidden */
  33790. _toBeDisposed: Nullable<IDisposable>[];
  33791. private _activeRequests;
  33792. private _pendingData;
  33793. private _isDisposed;
  33794. /**
  33795. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33796. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33797. */
  33798. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33799. private _activeMeshes;
  33800. private _processedMaterials;
  33801. private _renderTargets;
  33802. /** @hidden */
  33803. _activeParticleSystems: SmartArray<IParticleSystem>;
  33804. private _activeSkeletons;
  33805. private _softwareSkinnedMeshes;
  33806. private _renderingManager;
  33807. /** @hidden */
  33808. _activeAnimatables: Animatable[];
  33809. private _transformMatrix;
  33810. private _sceneUbo;
  33811. private _alternateSceneUbo;
  33812. private _pickWithRayInverseMatrix;
  33813. private _viewMatrix;
  33814. private _projectionMatrix;
  33815. private _alternateViewMatrix;
  33816. private _alternateProjectionMatrix;
  33817. private _alternateTransformMatrix;
  33818. private _useAlternateCameraConfiguration;
  33819. private _alternateRendering;
  33820. private _wheelEventName;
  33821. /** @hidden */
  33822. _forcedViewPosition: Nullable<Vector3>;
  33823. /** @hidden */
  33824. readonly _isAlternateRenderingEnabled: boolean;
  33825. private _frustumPlanes;
  33826. /**
  33827. * Gets the list of frustum planes (built from the active camera)
  33828. */
  33829. readonly frustumPlanes: Plane[];
  33830. /**
  33831. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33832. * This is useful if there are more lights that the maximum simulteanous authorized
  33833. */
  33834. requireLightSorting: boolean;
  33835. /** @hidden */
  33836. readonly useMaterialMeshMap: boolean;
  33837. /** @hidden */
  33838. readonly useClonedMeshhMap: boolean;
  33839. private _pointerOverMesh;
  33840. private _pickedDownMesh;
  33841. private _pickedUpMesh;
  33842. private _externalData;
  33843. private _uid;
  33844. /**
  33845. * @hidden
  33846. * Backing store of defined scene components.
  33847. */
  33848. _components: ISceneComponent[];
  33849. /**
  33850. * @hidden
  33851. * Backing store of defined scene components.
  33852. */
  33853. _serializableComponents: ISceneSerializableComponent[];
  33854. /**
  33855. * List of components to register on the next registration step.
  33856. */
  33857. private _transientComponents;
  33858. /**
  33859. * Registers the transient components if needed.
  33860. */
  33861. private _registerTransientComponents;
  33862. /**
  33863. * @hidden
  33864. * Add a component to the scene.
  33865. * Note that the ccomponent could be registered on th next frame if this is called after
  33866. * the register component stage.
  33867. * @param component Defines the component to add to the scene
  33868. */
  33869. _addComponent(component: ISceneComponent): void;
  33870. /**
  33871. * @hidden
  33872. * Gets a component from the scene.
  33873. * @param name defines the name of the component to retrieve
  33874. * @returns the component or null if not present
  33875. */
  33876. _getComponent(name: string): Nullable<ISceneComponent>;
  33877. /**
  33878. * @hidden
  33879. * Defines the actions happening before camera updates.
  33880. */
  33881. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33882. /**
  33883. * @hidden
  33884. * Defines the actions happening before clear the canvas.
  33885. */
  33886. _beforeClearStage: Stage<SimpleStageAction>;
  33887. /**
  33888. * @hidden
  33889. * Defines the actions when collecting render targets for the frame.
  33890. */
  33891. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33892. /**
  33893. * @hidden
  33894. * Defines the actions happening for one camera in the frame.
  33895. */
  33896. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33897. /**
  33898. * @hidden
  33899. * Defines the actions happening during the per mesh ready checks.
  33900. */
  33901. _isReadyForMeshStage: Stage<MeshStageAction>;
  33902. /**
  33903. * @hidden
  33904. * Defines the actions happening before evaluate active mesh checks.
  33905. */
  33906. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33907. /**
  33908. * @hidden
  33909. * Defines the actions happening during the evaluate sub mesh checks.
  33910. */
  33911. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33912. /**
  33913. * @hidden
  33914. * Defines the actions happening during the active mesh stage.
  33915. */
  33916. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33917. /**
  33918. * @hidden
  33919. * Defines the actions happening during the per camera render target step.
  33920. */
  33921. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33922. /**
  33923. * @hidden
  33924. * Defines the actions happening just before the active camera is drawing.
  33925. */
  33926. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33927. /**
  33928. * @hidden
  33929. * Defines the actions happening just before a render target is drawing.
  33930. */
  33931. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33932. /**
  33933. * @hidden
  33934. * Defines the actions happening just before a rendering group is drawing.
  33935. */
  33936. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33937. /**
  33938. * @hidden
  33939. * Defines the actions happening just before a mesh is drawing.
  33940. */
  33941. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33942. /**
  33943. * @hidden
  33944. * Defines the actions happening just after a mesh has been drawn.
  33945. */
  33946. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33947. /**
  33948. * @hidden
  33949. * Defines the actions happening just after a rendering group has been drawn.
  33950. */
  33951. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33952. /**
  33953. * @hidden
  33954. * Defines the actions happening just after the active camera has been drawn.
  33955. */
  33956. _afterCameraDrawStage: Stage<CameraStageAction>;
  33957. /**
  33958. * @hidden
  33959. * Defines the actions happening just after a render target has been drawn.
  33960. */
  33961. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33962. /**
  33963. * @hidden
  33964. * Defines the actions happening just after rendering all cameras and computing intersections.
  33965. */
  33966. _afterRenderStage: Stage<SimpleStageAction>;
  33967. /**
  33968. * @hidden
  33969. * Defines the actions happening when a pointer move event happens.
  33970. */
  33971. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33972. /**
  33973. * @hidden
  33974. * Defines the actions happening when a pointer down event happens.
  33975. */
  33976. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33977. /**
  33978. * @hidden
  33979. * Defines the actions happening when a pointer up event happens.
  33980. */
  33981. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33982. /**
  33983. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33984. */
  33985. private geometriesByUniqueId;
  33986. /**
  33987. * Creates a new Scene
  33988. * @param engine defines the engine to use to render this scene
  33989. */
  33990. constructor(engine: Engine, options?: SceneOptions);
  33991. private _defaultMeshCandidates;
  33992. /**
  33993. * @hidden
  33994. */
  33995. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33996. private _defaultSubMeshCandidates;
  33997. /**
  33998. * @hidden
  33999. */
  34000. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34001. /**
  34002. * Sets the default candidate providers for the scene.
  34003. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34004. * and getCollidingSubMeshCandidates to their default function
  34005. */
  34006. setDefaultCandidateProviders(): void;
  34007. /**
  34008. * Gets a boolean indicating if collisions are processed on a web worker
  34009. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  34010. */
  34011. workerCollisions: boolean;
  34012. /**
  34013. * Gets the mesh that is currently under the pointer
  34014. */
  34015. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34016. /**
  34017. * Gets or sets the current on-screen X position of the pointer
  34018. */
  34019. pointerX: number;
  34020. /**
  34021. * Gets or sets the current on-screen Y position of the pointer
  34022. */
  34023. pointerY: number;
  34024. /**
  34025. * Gets the cached material (ie. the latest rendered one)
  34026. * @returns the cached material
  34027. */
  34028. getCachedMaterial(): Nullable<Material>;
  34029. /**
  34030. * Gets the cached effect (ie. the latest rendered one)
  34031. * @returns the cached effect
  34032. */
  34033. getCachedEffect(): Nullable<Effect>;
  34034. /**
  34035. * Gets the cached visibility state (ie. the latest rendered one)
  34036. * @returns the cached visibility state
  34037. */
  34038. getCachedVisibility(): Nullable<number>;
  34039. /**
  34040. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34041. * @param material defines the current material
  34042. * @param effect defines the current effect
  34043. * @param visibility defines the current visibility state
  34044. * @returns true if one parameter is not cached
  34045. */
  34046. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34047. /**
  34048. * Gets the engine associated with the scene
  34049. * @returns an Engine
  34050. */
  34051. getEngine(): Engine;
  34052. /**
  34053. * Gets the total number of vertices rendered per frame
  34054. * @returns the total number of vertices rendered per frame
  34055. */
  34056. getTotalVertices(): number;
  34057. /**
  34058. * Gets the performance counter for total vertices
  34059. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34060. */
  34061. readonly totalVerticesPerfCounter: PerfCounter;
  34062. /**
  34063. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34064. * @returns the total number of active indices rendered per frame
  34065. */
  34066. getActiveIndices(): number;
  34067. /**
  34068. * Gets the performance counter for active indices
  34069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34070. */
  34071. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34072. /**
  34073. * Gets the total number of active particles rendered per frame
  34074. * @returns the total number of active particles rendered per frame
  34075. */
  34076. getActiveParticles(): number;
  34077. /**
  34078. * Gets the performance counter for active particles
  34079. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34080. */
  34081. readonly activeParticlesPerfCounter: PerfCounter;
  34082. /**
  34083. * Gets the total number of active bones rendered per frame
  34084. * @returns the total number of active bones rendered per frame
  34085. */
  34086. getActiveBones(): number;
  34087. /**
  34088. * Gets the performance counter for active bones
  34089. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34090. */
  34091. readonly activeBonesPerfCounter: PerfCounter;
  34092. /**
  34093. * Gets the array of active meshes
  34094. * @returns an array of AbstractMesh
  34095. */
  34096. getActiveMeshes(): SmartArray<AbstractMesh>;
  34097. /**
  34098. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34099. * @returns a number
  34100. */
  34101. getAnimationRatio(): number;
  34102. /**
  34103. * Gets an unique Id for the current render phase
  34104. * @returns a number
  34105. */
  34106. getRenderId(): number;
  34107. /**
  34108. * Gets an unique Id for the current frame
  34109. * @returns a number
  34110. */
  34111. getFrameId(): number;
  34112. /** Call this function if you want to manually increment the render Id*/
  34113. incrementRenderId(): void;
  34114. private _updatePointerPosition;
  34115. private _createUbo;
  34116. private _createAlternateUbo;
  34117. private _setRayOnPointerInfo;
  34118. /**
  34119. * Use this method to simulate a pointer move on a mesh
  34120. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34121. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34122. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34123. * @returns the current scene
  34124. */
  34125. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34126. private _processPointerMove;
  34127. private _checkPrePointerObservable;
  34128. /**
  34129. * Use this method to simulate a pointer down on a mesh
  34130. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34131. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34132. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34133. * @returns the current scene
  34134. */
  34135. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34136. private _processPointerDown;
  34137. /**
  34138. * Use this method to simulate a pointer up on a mesh
  34139. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34140. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34141. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34142. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34143. * @returns the current scene
  34144. */
  34145. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34146. private _processPointerUp;
  34147. /**
  34148. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34149. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34150. * @returns true if the pointer was captured
  34151. */
  34152. isPointerCaptured(pointerId?: number): boolean;
  34153. /** @hidden */
  34154. _isPointerSwiping(): boolean;
  34155. /**
  34156. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34157. * @param attachUp defines if you want to attach events to pointerup
  34158. * @param attachDown defines if you want to attach events to pointerdown
  34159. * @param attachMove defines if you want to attach events to pointermove
  34160. */
  34161. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34162. /** Detaches all event handlers*/
  34163. detachControl(): void;
  34164. /**
  34165. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34166. * Delay loaded resources are not taking in account
  34167. * @return true if all required resources are ready
  34168. */
  34169. isReady(): boolean;
  34170. /** Resets all cached information relative to material (including effect and visibility) */
  34171. resetCachedMaterial(): void;
  34172. /**
  34173. * Registers a function to be called before every frame render
  34174. * @param func defines the function to register
  34175. */
  34176. registerBeforeRender(func: () => void): void;
  34177. /**
  34178. * Unregisters a function called before every frame render
  34179. * @param func defines the function to unregister
  34180. */
  34181. unregisterBeforeRender(func: () => void): void;
  34182. /**
  34183. * Registers a function to be called after every frame render
  34184. * @param func defines the function to register
  34185. */
  34186. registerAfterRender(func: () => void): void;
  34187. /**
  34188. * Unregisters a function called after every frame render
  34189. * @param func defines the function to unregister
  34190. */
  34191. unregisterAfterRender(func: () => void): void;
  34192. private _executeOnceBeforeRender;
  34193. /**
  34194. * The provided function will run before render once and will be disposed afterwards.
  34195. * A timeout delay can be provided so that the function will be executed in N ms.
  34196. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34197. * @param func The function to be executed.
  34198. * @param timeout optional delay in ms
  34199. */
  34200. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34201. /** @hidden */
  34202. _addPendingData(data: any): void;
  34203. /** @hidden */
  34204. _removePendingData(data: any): void;
  34205. /**
  34206. * Returns the number of items waiting to be loaded
  34207. * @returns the number of items waiting to be loaded
  34208. */
  34209. getWaitingItemsCount(): number;
  34210. /**
  34211. * Returns a boolean indicating if the scene is still loading data
  34212. */
  34213. readonly isLoading: boolean;
  34214. /**
  34215. * Registers a function to be executed when the scene is ready
  34216. * @param {Function} func - the function to be executed
  34217. */
  34218. executeWhenReady(func: () => void): void;
  34219. /**
  34220. * Returns a promise that resolves when the scene is ready
  34221. * @returns A promise that resolves when the scene is ready
  34222. */
  34223. whenReadyAsync(): Promise<void>;
  34224. /** @hidden */
  34225. _checkIsReady(): void;
  34226. /**
  34227. * Will start the animation sequence of a given target
  34228. * @param target defines the target
  34229. * @param from defines from which frame should animation start
  34230. * @param to defines until which frame should animation run.
  34231. * @param weight defines the weight to apply to the animation (1.0 by default)
  34232. * @param loop defines if the animation loops
  34233. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  34234. * @param onAnimationEnd defines the function to be executed when the animation ends
  34235. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  34236. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  34237. * @param onAnimationLoop defines the callback to call when an animation loops
  34238. * @returns the animatable object created for this animation
  34239. */
  34240. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  34241. /**
  34242. * Will start the animation sequence of a given target
  34243. * @param target defines the target
  34244. * @param from defines from which frame should animation start
  34245. * @param to defines until which frame should animation run.
  34246. * @param loop defines if the animation loops
  34247. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  34248. * @param onAnimationEnd defines the function to be executed when the animation ends
  34249. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  34250. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  34251. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  34252. * @param onAnimationLoop defines the callback to call when an animation loops
  34253. * @returns the animatable object created for this animation
  34254. */
  34255. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  34256. /**
  34257. * Will start the animation sequence of a given target and its hierarchy
  34258. * @param target defines the target
  34259. * @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.
  34260. * @param from defines from which frame should animation start
  34261. * @param to defines until which frame should animation run.
  34262. * @param loop defines if the animation loops
  34263. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  34264. * @param onAnimationEnd defines the function to be executed when the animation ends
  34265. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  34266. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  34267. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  34268. * @param onAnimationLoop defines the callback to call when an animation loops
  34269. * @returns the list of created animatables
  34270. */
  34271. 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[];
  34272. /**
  34273. * Begin a new animation on a given node
  34274. * @param target defines the target where the animation will take place
  34275. * @param animations defines the list of animations to start
  34276. * @param from defines the initial value
  34277. * @param to defines the final value
  34278. * @param loop defines if you want animation to loop (off by default)
  34279. * @param speedRatio defines the speed ratio to apply to all animations
  34280. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34281. * @param onAnimationLoop defines the callback to call when an animation loops
  34282. * @returns the list of created animatables
  34283. */
  34284. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  34285. /**
  34286. * Begin a new animation on a given node and its hierarchy
  34287. * @param target defines the root node where the animation will take place
  34288. * @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.
  34289. * @param animations defines the list of animations to start
  34290. * @param from defines the initial value
  34291. * @param to defines the final value
  34292. * @param loop defines if you want animation to loop (off by default)
  34293. * @param speedRatio defines the speed ratio to apply to all animations
  34294. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34295. * @param onAnimationLoop defines the callback to call when an animation loops
  34296. * @returns the list of animatables created for all nodes
  34297. */
  34298. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  34299. /**
  34300. * Gets the animatable associated with a specific target
  34301. * @param target defines the target of the animatable
  34302. * @returns the required animatable if found
  34303. */
  34304. getAnimatableByTarget(target: any): Nullable<Animatable>;
  34305. /**
  34306. * Gets all animatables associated with a given target
  34307. * @param target defines the target to look animatables for
  34308. * @returns an array of Animatables
  34309. */
  34310. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  34311. /**
  34312. * Gets all animatable attached to the scene
  34313. */
  34314. readonly animatables: Animatable[];
  34315. /**
  34316. * Will stop the animation of the given target
  34317. * @param target - the target
  34318. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34319. * @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)
  34320. */
  34321. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34322. /**
  34323. * Stops and removes all animations that have been applied to the scene
  34324. */
  34325. stopAllAnimations(): void;
  34326. /**
  34327. * Resets the last animation time frame.
  34328. * Useful to override when animations start running when loading a scene for the first time.
  34329. */
  34330. resetLastAnimationTimeFrame(): void;
  34331. private _animate;
  34332. /** @hidden */
  34333. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  34334. private _processLateAnimationBindingsForMatrices;
  34335. private _processLateAnimationBindingsForQuaternions;
  34336. private _processLateAnimationBindings;
  34337. /** @hidden */
  34338. _switchToAlternateCameraConfiguration(active: boolean): void;
  34339. /**
  34340. * Gets the current view matrix
  34341. * @returns a Matrix
  34342. */
  34343. getViewMatrix(): Matrix;
  34344. /**
  34345. * Gets the current projection matrix
  34346. * @returns a Matrix
  34347. */
  34348. getProjectionMatrix(): Matrix;
  34349. /**
  34350. * Gets the current transform matrix
  34351. * @returns a Matrix made of View * Projection
  34352. */
  34353. getTransformMatrix(): Matrix;
  34354. /**
  34355. * Sets the current transform matrix
  34356. * @param view defines the View matrix to use
  34357. * @param projection defines the Projection matrix to use
  34358. */
  34359. setTransformMatrix(view: Matrix, projection: Matrix): void;
  34360. /** @hidden */
  34361. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  34362. /**
  34363. * Gets the uniform buffer used to store scene data
  34364. * @returns a UniformBuffer
  34365. */
  34366. getSceneUniformBuffer(): UniformBuffer;
  34367. /**
  34368. * Gets an unique (relatively to the current scene) Id
  34369. * @returns an unique number for the scene
  34370. */
  34371. getUniqueId(): number;
  34372. /**
  34373. * Add a mesh to the list of scene's meshes
  34374. * @param newMesh defines the mesh to add
  34375. * @param recursive if all child meshes should also be added to the scene
  34376. */
  34377. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34378. /**
  34379. * Remove a mesh for the list of scene's meshes
  34380. * @param toRemove defines the mesh to remove
  34381. * @param recursive if all child meshes should also be removed from the scene
  34382. * @returns the index where the mesh was in the mesh list
  34383. */
  34384. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34385. /**
  34386. * Add a transform node to the list of scene's transform nodes
  34387. * @param newTransformNode defines the transform node to add
  34388. */
  34389. addTransformNode(newTransformNode: TransformNode): void;
  34390. /**
  34391. * Remove a transform node for the list of scene's transform nodes
  34392. * @param toRemove defines the transform node to remove
  34393. * @returns the index where the transform node was in the transform node list
  34394. */
  34395. removeTransformNode(toRemove: TransformNode): number;
  34396. /**
  34397. * Remove a skeleton for the list of scene's skeletons
  34398. * @param toRemove defines the skeleton to remove
  34399. * @returns the index where the skeleton was in the skeleton list
  34400. */
  34401. removeSkeleton(toRemove: Skeleton): number;
  34402. /**
  34403. * Remove a morph target for the list of scene's morph targets
  34404. * @param toRemove defines the morph target to remove
  34405. * @returns the index where the morph target was in the morph target list
  34406. */
  34407. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34408. /**
  34409. * Remove a light for the list of scene's lights
  34410. * @param toRemove defines the light to remove
  34411. * @returns the index where the light was in the light list
  34412. */
  34413. removeLight(toRemove: Light): number;
  34414. /**
  34415. * Remove a camera for the list of scene's cameras
  34416. * @param toRemove defines the camera to remove
  34417. * @returns the index where the camera was in the camera list
  34418. */
  34419. removeCamera(toRemove: Camera): number;
  34420. /**
  34421. * Remove a particle system for the list of scene's particle systems
  34422. * @param toRemove defines the particle system to remove
  34423. * @returns the index where the particle system was in the particle system list
  34424. */
  34425. removeParticleSystem(toRemove: IParticleSystem): number;
  34426. /**
  34427. * Remove a animation for the list of scene's animations
  34428. * @param toRemove defines the animation to remove
  34429. * @returns the index where the animation was in the animation list
  34430. */
  34431. removeAnimation(toRemove: Animation): number;
  34432. /**
  34433. * Removes the given animation group from this scene.
  34434. * @param toRemove The animation group to remove
  34435. * @returns The index of the removed animation group
  34436. */
  34437. removeAnimationGroup(toRemove: AnimationGroup): number;
  34438. /**
  34439. * Removes the given multi-material from this scene.
  34440. * @param toRemove The multi-material to remove
  34441. * @returns The index of the removed multi-material
  34442. */
  34443. removeMultiMaterial(toRemove: MultiMaterial): number;
  34444. /**
  34445. * Removes the given material from this scene.
  34446. * @param toRemove The material to remove
  34447. * @returns The index of the removed material
  34448. */
  34449. removeMaterial(toRemove: Material): number;
  34450. /**
  34451. * Removes the given action manager from this scene.
  34452. * @param toRemove The action manager to remove
  34453. * @returns The index of the removed action manager
  34454. */
  34455. removeActionManager(toRemove: ActionManager): number;
  34456. /**
  34457. * Removes the given texture from this scene.
  34458. * @param toRemove The texture to remove
  34459. * @returns The index of the removed texture
  34460. */
  34461. removeTexture(toRemove: BaseTexture): number;
  34462. /**
  34463. * Adds the given light to this scene
  34464. * @param newLight The light to add
  34465. */
  34466. addLight(newLight: Light): void;
  34467. /**
  34468. * Sorts the list list based on light priorities
  34469. */
  34470. sortLightsByPriority(): void;
  34471. /**
  34472. * Adds the given camera to this scene
  34473. * @param newCamera The camera to add
  34474. */
  34475. addCamera(newCamera: Camera): void;
  34476. /**
  34477. * Adds the given skeleton to this scene
  34478. * @param newSkeleton The skeleton to add
  34479. */
  34480. addSkeleton(newSkeleton: Skeleton): void;
  34481. /**
  34482. * Adds the given particle system to this scene
  34483. * @param newParticleSystem The particle system to add
  34484. */
  34485. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34486. /**
  34487. * Adds the given animation to this scene
  34488. * @param newAnimation The animation to add
  34489. */
  34490. addAnimation(newAnimation: Animation): void;
  34491. /**
  34492. * Adds the given animation group to this scene.
  34493. * @param newAnimationGroup The animation group to add
  34494. */
  34495. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34496. /**
  34497. * Adds the given multi-material to this scene
  34498. * @param newMultiMaterial The multi-material to add
  34499. */
  34500. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34501. /**
  34502. * Adds the given material to this scene
  34503. * @param newMaterial The material to add
  34504. */
  34505. addMaterial(newMaterial: Material): void;
  34506. /**
  34507. * Adds the given morph target to this scene
  34508. * @param newMorphTargetManager The morph target to add
  34509. */
  34510. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34511. /**
  34512. * Adds the given geometry to this scene
  34513. * @param newGeometry The geometry to add
  34514. */
  34515. addGeometry(newGeometry: Geometry): void;
  34516. /**
  34517. * Adds the given action manager to this scene
  34518. * @param newActionManager The action manager to add
  34519. */
  34520. addActionManager(newActionManager: ActionManager): void;
  34521. /**
  34522. * Adds the given texture to this scene.
  34523. * @param newTexture The texture to add
  34524. */
  34525. addTexture(newTexture: BaseTexture): void;
  34526. /**
  34527. * Switch active camera
  34528. * @param newCamera defines the new active camera
  34529. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34530. */
  34531. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34532. /**
  34533. * sets the active camera of the scene using its ID
  34534. * @param id defines the camera's ID
  34535. * @return the new active camera or null if none found.
  34536. */
  34537. setActiveCameraByID(id: string): Nullable<Camera>;
  34538. /**
  34539. * sets the active camera of the scene using its name
  34540. * @param name defines the camera's name
  34541. * @returns the new active camera or null if none found.
  34542. */
  34543. setActiveCameraByName(name: string): Nullable<Camera>;
  34544. /**
  34545. * get an animation group using its name
  34546. * @param name defines the material's name
  34547. * @return the animation group or null if none found.
  34548. */
  34549. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34550. /**
  34551. * get a material using its id
  34552. * @param id defines the material's ID
  34553. * @return the material or null if none found.
  34554. */
  34555. getMaterialByID(id: string): Nullable<Material>;
  34556. /**
  34557. * Gets a material using its name
  34558. * @param name defines the material's name
  34559. * @return the material or null if none found.
  34560. */
  34561. getMaterialByName(name: string): Nullable<Material>;
  34562. /**
  34563. * Gets a camera using its id
  34564. * @param id defines the id to look for
  34565. * @returns the camera or null if not found
  34566. */
  34567. getCameraByID(id: string): Nullable<Camera>;
  34568. /**
  34569. * Gets a camera using its unique id
  34570. * @param uniqueId defines the unique id to look for
  34571. * @returns the camera or null if not found
  34572. */
  34573. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34574. /**
  34575. * Gets a camera using its name
  34576. * @param name defines the camera's name
  34577. * @return the camera or null if none found.
  34578. */
  34579. getCameraByName(name: string): Nullable<Camera>;
  34580. /**
  34581. * Gets a bone using its id
  34582. * @param id defines the bone's id
  34583. * @return the bone or null if not found
  34584. */
  34585. getBoneByID(id: string): Nullable<Bone>;
  34586. /**
  34587. * Gets a bone using its id
  34588. * @param name defines the bone's name
  34589. * @return the bone or null if not found
  34590. */
  34591. getBoneByName(name: string): Nullable<Bone>;
  34592. /**
  34593. * Gets a light node using its name
  34594. * @param name defines the the light's name
  34595. * @return the light or null if none found.
  34596. */
  34597. getLightByName(name: string): Nullable<Light>;
  34598. /**
  34599. * Gets a light node using its id
  34600. * @param id defines the light's id
  34601. * @return the light or null if none found.
  34602. */
  34603. getLightByID(id: string): Nullable<Light>;
  34604. /**
  34605. * Gets a light node using its scene-generated unique ID
  34606. * @param uniqueId defines the light's unique id
  34607. * @return the light or null if none found.
  34608. */
  34609. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34610. /**
  34611. * Gets a particle system by id
  34612. * @param id defines the particle system id
  34613. * @return the corresponding system or null if none found
  34614. */
  34615. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34616. /**
  34617. * Gets a geometry using its ID
  34618. * @param id defines the geometry's id
  34619. * @return the geometry or null if none found.
  34620. */
  34621. getGeometryByID(id: string): Nullable<Geometry>;
  34622. private _getGeometryByUniqueID;
  34623. /**
  34624. * Add a new geometry to this scene
  34625. * @param geometry defines the geometry to be added to the scene.
  34626. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34627. * @return a boolean defining if the geometry was added or not
  34628. */
  34629. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34630. /**
  34631. * Removes an existing geometry
  34632. * @param geometry defines the geometry to be removed from the scene
  34633. * @return a boolean defining if the geometry was removed or not
  34634. */
  34635. removeGeometry(geometry: Geometry): boolean;
  34636. /**
  34637. * Gets the list of geometries attached to the scene
  34638. * @returns an array of Geometry
  34639. */
  34640. getGeometries(): Geometry[];
  34641. /**
  34642. * Gets the first added mesh found of a given ID
  34643. * @param id defines the id to search for
  34644. * @return the mesh found or null if not found at all
  34645. */
  34646. getMeshByID(id: string): Nullable<AbstractMesh>;
  34647. /**
  34648. * Gets a list of meshes using their id
  34649. * @param id defines the id to search for
  34650. * @returns a list of meshes
  34651. */
  34652. getMeshesByID(id: string): Array<AbstractMesh>;
  34653. /**
  34654. * Gets the first added transform node found of a given ID
  34655. * @param id defines the id to search for
  34656. * @return the found transform node or null if not found at all.
  34657. */
  34658. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34659. /**
  34660. * Gets a list of transform nodes using their id
  34661. * @param id defines the id to search for
  34662. * @returns a list of transform nodes
  34663. */
  34664. getTransformNodesByID(id: string): Array<TransformNode>;
  34665. /**
  34666. * Gets a mesh with its auto-generated unique id
  34667. * @param uniqueId defines the unique id to search for
  34668. * @return the found mesh or null if not found at all.
  34669. */
  34670. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34671. /**
  34672. * Gets a the last added mesh using a given id
  34673. * @param id defines the id to search for
  34674. * @return the found mesh or null if not found at all.
  34675. */
  34676. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34677. /**
  34678. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34679. * @param id defines the id to search for
  34680. * @return the found node or null if not found at all
  34681. */
  34682. getLastEntryByID(id: string): Nullable<Node>;
  34683. /**
  34684. * Gets a node (Mesh, Camera, Light) using a given id
  34685. * @param id defines the id to search for
  34686. * @return the found node or null if not found at all
  34687. */
  34688. getNodeByID(id: string): Nullable<Node>;
  34689. /**
  34690. * Gets a node (Mesh, Camera, Light) using a given name
  34691. * @param name defines the name to search for
  34692. * @return the found node or null if not found at all.
  34693. */
  34694. getNodeByName(name: string): Nullable<Node>;
  34695. /**
  34696. * Gets a mesh using a given name
  34697. * @param name defines the name to search for
  34698. * @return the found mesh or null if not found at all.
  34699. */
  34700. getMeshByName(name: string): Nullable<AbstractMesh>;
  34701. /**
  34702. * Gets a transform node using a given name
  34703. * @param name defines the name to search for
  34704. * @return the found transform node or null if not found at all.
  34705. */
  34706. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34707. /**
  34708. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34709. * @param id defines the id to search for
  34710. * @return the found skeleton or null if not found at all.
  34711. */
  34712. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34713. /**
  34714. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34715. * @param id defines the id to search for
  34716. * @return the found skeleton or null if not found at all.
  34717. */
  34718. getSkeletonById(id: string): Nullable<Skeleton>;
  34719. /**
  34720. * Gets a skeleton using a given name
  34721. * @param name defines the name to search for
  34722. * @return the found skeleton or null if not found at all.
  34723. */
  34724. getSkeletonByName(name: string): Nullable<Skeleton>;
  34725. /**
  34726. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34727. * @param id defines the id to search for
  34728. * @return the found morph target manager or null if not found at all.
  34729. */
  34730. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34731. /**
  34732. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34733. * @param id defines the id to search for
  34734. * @return the found morph target or null if not found at all.
  34735. */
  34736. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34737. /**
  34738. * Gets a boolean indicating if the given mesh is active
  34739. * @param mesh defines the mesh to look for
  34740. * @returns true if the mesh is in the active list
  34741. */
  34742. isActiveMesh(mesh: AbstractMesh): boolean;
  34743. /**
  34744. * Return a unique id as a string which can serve as an identifier for the scene
  34745. */
  34746. readonly uid: string;
  34747. /**
  34748. * Add an externaly attached data from its key.
  34749. * This method call will fail and return false, if such key already exists.
  34750. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34751. * @param key the unique key that identifies the data
  34752. * @param data the data object to associate to the key for this Engine instance
  34753. * @return true if no such key were already present and the data was added successfully, false otherwise
  34754. */
  34755. addExternalData<T>(key: string, data: T): boolean;
  34756. /**
  34757. * Get an externaly attached data from its key
  34758. * @param key the unique key that identifies the data
  34759. * @return the associated data, if present (can be null), or undefined if not present
  34760. */
  34761. getExternalData<T>(key: string): Nullable<T>;
  34762. /**
  34763. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34764. * @param key the unique key that identifies the data
  34765. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34766. * @return the associated data, can be null if the factory returned null.
  34767. */
  34768. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34769. /**
  34770. * Remove an externaly attached data from the Engine instance
  34771. * @param key the unique key that identifies the data
  34772. * @return true if the data was successfully removed, false if it doesn't exist
  34773. */
  34774. removeExternalData(key: string): boolean;
  34775. private _evaluateSubMesh;
  34776. /**
  34777. * Clear the processed materials smart array preventing retention point in material dispose.
  34778. */
  34779. freeProcessedMaterials(): void;
  34780. private _preventFreeActiveMeshesAndRenderingGroups;
  34781. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34782. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34783. * when disposing several meshes in a row or a hierarchy of meshes.
  34784. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34785. */
  34786. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34787. /**
  34788. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34789. */
  34790. freeActiveMeshes(): void;
  34791. /**
  34792. * Clear the info related to rendering groups preventing retention points during dispose.
  34793. */
  34794. freeRenderingGroups(): void;
  34795. /** @hidden */
  34796. _isInIntermediateRendering(): boolean;
  34797. /**
  34798. * Lambda returning the list of potentially active meshes.
  34799. */
  34800. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34801. /**
  34802. * Lambda returning the list of potentially active sub meshes.
  34803. */
  34804. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34805. /**
  34806. * Lambda returning the list of potentially intersecting sub meshes.
  34807. */
  34808. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34809. /**
  34810. * Lambda returning the list of potentially colliding sub meshes.
  34811. */
  34812. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34813. private _activeMeshesFrozen;
  34814. /**
  34815. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34816. * @returns the current scene
  34817. */
  34818. freezeActiveMeshes(): Scene;
  34819. /**
  34820. * Use this function to restart evaluating active meshes on every frame
  34821. * @returns the current scene
  34822. */
  34823. unfreezeActiveMeshes(): Scene;
  34824. private _evaluateActiveMeshes;
  34825. private _activeMesh;
  34826. /**
  34827. * Update the transform matrix to update from the current active camera
  34828. * @param force defines a boolean used to force the update even if cache is up to date
  34829. */
  34830. updateTransformMatrix(force?: boolean): void;
  34831. /**
  34832. * 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)
  34833. * @param alternateCamera defines the camera to use
  34834. */
  34835. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  34836. /** @hidden */
  34837. _allowPostProcessClearColor: boolean;
  34838. private _renderForCamera;
  34839. private _processSubCameras;
  34840. private _checkIntersections;
  34841. /** @hidden */
  34842. _advancePhysicsEngineStep(step: number): void;
  34843. /**
  34844. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34845. */
  34846. getDeterministicFrameTime: () => number;
  34847. /**
  34848. * Render the scene
  34849. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34850. */
  34851. render(updateCameras?: boolean): void;
  34852. /**
  34853. * Freeze all materials
  34854. * A frozen material will not be updatable but should be faster to render
  34855. */
  34856. freezeMaterials(): void;
  34857. /**
  34858. * Unfreeze all materials
  34859. * A frozen material will not be updatable but should be faster to render
  34860. */
  34861. unfreezeMaterials(): void;
  34862. /**
  34863. * Releases all held ressources
  34864. */
  34865. dispose(): void;
  34866. /**
  34867. * Gets if the scene is already disposed
  34868. */
  34869. readonly isDisposed: boolean;
  34870. /**
  34871. * Call this function to reduce memory footprint of the scene.
  34872. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34873. */
  34874. clearCachedVertexData(): void;
  34875. /**
  34876. * This function will remove the local cached buffer data from texture.
  34877. * It will save memory but will prevent the texture from being rebuilt
  34878. */
  34879. cleanCachedTextureBuffer(): void;
  34880. /**
  34881. * Get the world extend vectors with an optional filter
  34882. *
  34883. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34884. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34885. */
  34886. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34887. min: Vector3;
  34888. max: Vector3;
  34889. };
  34890. /**
  34891. * Creates a ray that can be used to pick in the scene
  34892. * @param x defines the x coordinate of the origin (on-screen)
  34893. * @param y defines the y coordinate of the origin (on-screen)
  34894. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34895. * @param camera defines the camera to use for the picking
  34896. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34897. * @returns a Ray
  34898. */
  34899. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34900. /**
  34901. * Creates a ray that can be used to pick in the scene
  34902. * @param x defines the x coordinate of the origin (on-screen)
  34903. * @param y defines the y coordinate of the origin (on-screen)
  34904. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34905. * @param result defines the ray where to store the picking ray
  34906. * @param camera defines the camera to use for the picking
  34907. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34908. * @returns the current scene
  34909. */
  34910. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34911. /**
  34912. * Creates a ray that can be used to pick in the scene
  34913. * @param x defines the x coordinate of the origin (on-screen)
  34914. * @param y defines the y coordinate of the origin (on-screen)
  34915. * @param camera defines the camera to use for the picking
  34916. * @returns a Ray
  34917. */
  34918. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34919. /**
  34920. * Creates a ray that can be used to pick in the scene
  34921. * @param x defines the x coordinate of the origin (on-screen)
  34922. * @param y defines the y coordinate of the origin (on-screen)
  34923. * @param result defines the ray where to store the picking ray
  34924. * @param camera defines the camera to use for the picking
  34925. * @returns the current scene
  34926. */
  34927. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34928. private _internalPick;
  34929. private _internalMultiPick;
  34930. private _tempPickingRay;
  34931. /** Launch a ray to try to pick a mesh in the scene
  34932. * @param x position on screen
  34933. * @param y position on screen
  34934. * @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
  34935. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34936. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34937. * @returns a PickingInfo
  34938. */
  34939. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  34940. private _cachedRayForTransform;
  34941. /** Use the given ray to pick a mesh in the scene
  34942. * @param ray The ray to use to pick meshes
  34943. * @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
  34944. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34945. * @returns a PickingInfo
  34946. */
  34947. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  34948. /**
  34949. * Launch a ray to try to pick a mesh in the scene
  34950. * @param x X position on screen
  34951. * @param y Y position on screen
  34952. * @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
  34953. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34954. * @returns an array of PickingInfo
  34955. */
  34956. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  34957. /**
  34958. * Launch a ray to try to pick a mesh in the scene
  34959. * @param ray Ray to use
  34960. * @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
  34961. * @returns an array of PickingInfo
  34962. */
  34963. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  34964. /**
  34965. * Force the value of meshUnderPointer
  34966. * @param mesh defines the mesh to use
  34967. */
  34968. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34969. /**
  34970. * Gets the mesh under the pointer
  34971. * @returns a Mesh or null if no mesh is under the pointer
  34972. */
  34973. getPointerOverMesh(): Nullable<AbstractMesh>;
  34974. /** @hidden */
  34975. _rebuildGeometries(): void;
  34976. /** @hidden */
  34977. _rebuildTextures(): void;
  34978. private _getByTags;
  34979. /**
  34980. * Get a list of meshes by tags
  34981. * @param tagsQuery defines the tags query to use
  34982. * @param forEach defines a predicate used to filter results
  34983. * @returns an array of Mesh
  34984. */
  34985. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34986. /**
  34987. * Get a list of cameras by tags
  34988. * @param tagsQuery defines the tags query to use
  34989. * @param forEach defines a predicate used to filter results
  34990. * @returns an array of Camera
  34991. */
  34992. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34993. /**
  34994. * Get a list of lights by tags
  34995. * @param tagsQuery defines the tags query to use
  34996. * @param forEach defines a predicate used to filter results
  34997. * @returns an array of Light
  34998. */
  34999. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35000. /**
  35001. * Get a list of materials by tags
  35002. * @param tagsQuery defines the tags query to use
  35003. * @param forEach defines a predicate used to filter results
  35004. * @returns an array of Material
  35005. */
  35006. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35007. /**
  35008. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35009. * This allowed control for front to back rendering or reversly depending of the special needs.
  35010. *
  35011. * @param renderingGroupId The rendering group id corresponding to its index
  35012. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35013. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35014. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35015. */
  35016. 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;
  35017. /**
  35018. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35019. *
  35020. * @param renderingGroupId The rendering group id corresponding to its index
  35021. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35022. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35023. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35024. */
  35025. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35026. /**
  35027. * Gets the current auto clear configuration for one rendering group of the rendering
  35028. * manager.
  35029. * @param index the rendering group index to get the information for
  35030. * @returns The auto clear setup for the requested rendering group
  35031. */
  35032. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35033. private _blockMaterialDirtyMechanism;
  35034. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35035. blockMaterialDirtyMechanism: boolean;
  35036. /**
  35037. * Will flag all materials as dirty to trigger new shader compilation
  35038. * @param flag defines the flag used to specify which material part must be marked as dirty
  35039. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35040. */
  35041. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35042. /** @hidden */
  35043. _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;
  35044. /** @hidden */
  35045. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35046. }
  35047. }
  35048. declare module "babylonjs/assetContainer" {
  35049. import { AbstractScene } from "babylonjs/abstractScene";
  35050. import { Scene } from "babylonjs/scene";
  35051. import { Mesh } from "babylonjs/Meshes/mesh";
  35052. /**
  35053. * Set of assets to keep when moving a scene into an asset container.
  35054. */
  35055. export class KeepAssets extends AbstractScene {
  35056. }
  35057. /**
  35058. * Container with a set of assets that can be added or removed from a scene.
  35059. */
  35060. export class AssetContainer extends AbstractScene {
  35061. /**
  35062. * The scene the AssetContainer belongs to.
  35063. */
  35064. scene: Scene;
  35065. /**
  35066. * Instantiates an AssetContainer.
  35067. * @param scene The scene the AssetContainer belongs to.
  35068. */
  35069. constructor(scene: Scene);
  35070. /**
  35071. * Adds all the assets from the container to the scene.
  35072. */
  35073. addAllToScene(): void;
  35074. /**
  35075. * Removes all the assets in the container from the scene
  35076. */
  35077. removeAllFromScene(): void;
  35078. /**
  35079. * Disposes all the assets in the container
  35080. */
  35081. dispose(): void;
  35082. private _moveAssets;
  35083. /**
  35084. * Removes all the assets contained in the scene and adds them to the container.
  35085. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35086. */
  35087. moveAllFromScene(keepAssets?: KeepAssets): void;
  35088. /**
  35089. * 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.
  35090. * @returns the root mesh
  35091. */
  35092. createRootMesh(): Mesh;
  35093. }
  35094. }
  35095. declare module "babylonjs/abstractScene" {
  35096. import { Scene } from "babylonjs/scene";
  35097. import { Nullable } from "babylonjs/types";
  35098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35099. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35100. import { Geometry } from "babylonjs/Meshes/geometry";
  35101. import { Skeleton } from "babylonjs/Bones/skeleton";
  35102. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35103. import { AssetContainer } from "babylonjs/assetContainer";
  35104. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35105. import { Animation } from "babylonjs/Animations/animation";
  35106. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35107. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35108. import { Material } from "babylonjs/Materials/material";
  35109. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35110. import { ActionManager } from "babylonjs/Actions/actionManager";
  35111. import { Camera } from "babylonjs/Cameras/camera";
  35112. import { Light } from "babylonjs/Lights/light";
  35113. import { Node } from "babylonjs/node";
  35114. /**
  35115. * Defines how the parser contract is defined.
  35116. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35117. */
  35118. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35119. /**
  35120. * Defines how the individual parser contract is defined.
  35121. * These parser can parse an individual asset
  35122. */
  35123. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35124. /**
  35125. * Base class of the scene acting as a container for the different elements composing a scene.
  35126. * This class is dynamically extended by the different components of the scene increasing
  35127. * flexibility and reducing coupling
  35128. */
  35129. export abstract class AbstractScene {
  35130. /**
  35131. * Stores the list of available parsers in the application.
  35132. */
  35133. private static _BabylonFileParsers;
  35134. /**
  35135. * Stores the list of available individual parsers in the application.
  35136. */
  35137. private static _IndividualBabylonFileParsers;
  35138. /**
  35139. * Adds a parser in the list of available ones
  35140. * @param name Defines the name of the parser
  35141. * @param parser Defines the parser to add
  35142. */
  35143. static AddParser(name: string, parser: BabylonFileParser): void;
  35144. /**
  35145. * Gets a general parser from the list of avaialble ones
  35146. * @param name Defines the name of the parser
  35147. * @returns the requested parser or null
  35148. */
  35149. static GetParser(name: string): Nullable<BabylonFileParser>;
  35150. /**
  35151. * Adds n individual parser in the list of available ones
  35152. * @param name Defines the name of the parser
  35153. * @param parser Defines the parser to add
  35154. */
  35155. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35156. /**
  35157. * Gets an individual parser from the list of avaialble ones
  35158. * @param name Defines the name of the parser
  35159. * @returns the requested parser or null
  35160. */
  35161. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35162. /**
  35163. * Parser json data and populate both a scene and its associated container object
  35164. * @param jsonData Defines the data to parse
  35165. * @param scene Defines the scene to parse the data for
  35166. * @param container Defines the container attached to the parsing sequence
  35167. * @param rootUrl Defines the root url of the data
  35168. */
  35169. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35170. /**
  35171. * Gets the list of root nodes (ie. nodes with no parent)
  35172. */
  35173. rootNodes: Node[];
  35174. /** All of the cameras added to this scene
  35175. * @see http://doc.babylonjs.com/babylon101/cameras
  35176. */
  35177. cameras: Camera[];
  35178. /**
  35179. * All of the lights added to this scene
  35180. * @see http://doc.babylonjs.com/babylon101/lights
  35181. */
  35182. lights: Light[];
  35183. /**
  35184. * All of the (abstract) meshes added to this scene
  35185. */
  35186. meshes: AbstractMesh[];
  35187. /**
  35188. * The list of skeletons added to the scene
  35189. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35190. */
  35191. skeletons: Skeleton[];
  35192. /**
  35193. * All of the particle systems added to this scene
  35194. * @see http://doc.babylonjs.com/babylon101/particles
  35195. */
  35196. particleSystems: IParticleSystem[];
  35197. /**
  35198. * Gets a list of Animations associated with the scene
  35199. */
  35200. animations: Animation[];
  35201. /**
  35202. * All of the animation groups added to this scene
  35203. * @see http://doc.babylonjs.com/how_to/group
  35204. */
  35205. animationGroups: AnimationGroup[];
  35206. /**
  35207. * All of the multi-materials added to this scene
  35208. * @see http://doc.babylonjs.com/how_to/multi_materials
  35209. */
  35210. multiMaterials: MultiMaterial[];
  35211. /**
  35212. * All of the materials added to this scene
  35213. * In the context of a Scene, it is not supposed to be modified manually.
  35214. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35215. * Note also that the order of the Material wihin the array is not significant and might change.
  35216. * @see http://doc.babylonjs.com/babylon101/materials
  35217. */
  35218. materials: Material[];
  35219. /**
  35220. * The list of morph target managers added to the scene
  35221. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35222. */
  35223. morphTargetManagers: MorphTargetManager[];
  35224. /**
  35225. * The list of geometries used in the scene.
  35226. */
  35227. geometries: Geometry[];
  35228. /**
  35229. * All of the tranform nodes added to this scene
  35230. * In the context of a Scene, it is not supposed to be modified manually.
  35231. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35232. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35233. * @see http://doc.babylonjs.com/how_to/transformnode
  35234. */
  35235. transformNodes: TransformNode[];
  35236. /**
  35237. * ActionManagers available on the scene.
  35238. */
  35239. actionManagers: ActionManager[];
  35240. /**
  35241. * Textures to keep.
  35242. */
  35243. textures: BaseTexture[];
  35244. }
  35245. }
  35246. declare module "babylonjs/Audio/sound" {
  35247. import { Observable } from "babylonjs/Misc/observable";
  35248. import { Vector3 } from "babylonjs/Maths/math";
  35249. import { Nullable } from "babylonjs/types";
  35250. import { Scene } from "babylonjs/scene";
  35251. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35252. /**
  35253. * Defines a sound that can be played in the application.
  35254. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35256. */
  35257. export class Sound {
  35258. /**
  35259. * The name of the sound in the scene.
  35260. */
  35261. name: string;
  35262. /**
  35263. * Does the sound autoplay once loaded.
  35264. */
  35265. autoplay: boolean;
  35266. /**
  35267. * Does the sound loop after it finishes playing once.
  35268. */
  35269. loop: boolean;
  35270. /**
  35271. * Does the sound use a custom attenuation curve to simulate the falloff
  35272. * happening when the source gets further away from the camera.
  35273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35274. */
  35275. useCustomAttenuation: boolean;
  35276. /**
  35277. * The sound track id this sound belongs to.
  35278. */
  35279. soundTrackId: number;
  35280. /**
  35281. * Is this sound currently played.
  35282. */
  35283. isPlaying: boolean;
  35284. /**
  35285. * Is this sound currently paused.
  35286. */
  35287. isPaused: boolean;
  35288. /**
  35289. * Does this sound enables spatial sound.
  35290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35291. */
  35292. spatialSound: boolean;
  35293. /**
  35294. * Define the reference distance the sound should be heard perfectly.
  35295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35296. */
  35297. refDistance: number;
  35298. /**
  35299. * Define the roll off factor of spatial sounds.
  35300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35301. */
  35302. rolloffFactor: number;
  35303. /**
  35304. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35306. */
  35307. maxDistance: number;
  35308. /**
  35309. * Define the distance attenuation model the sound will follow.
  35310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35311. */
  35312. distanceModel: string;
  35313. /**
  35314. * @hidden
  35315. * Back Compat
  35316. **/
  35317. onended: () => any;
  35318. /**
  35319. * Observable event when the current playing sound finishes.
  35320. */
  35321. onEndedObservable: Observable<Sound>;
  35322. private _panningModel;
  35323. private _playbackRate;
  35324. private _streaming;
  35325. private _startTime;
  35326. private _startOffset;
  35327. private _position;
  35328. /** @hidden */
  35329. _positionInEmitterSpace: boolean;
  35330. private _localDirection;
  35331. private _volume;
  35332. private _isReadyToPlay;
  35333. private _isDirectional;
  35334. private _readyToPlayCallback;
  35335. private _audioBuffer;
  35336. private _soundSource;
  35337. private _streamingSource;
  35338. private _soundPanner;
  35339. private _soundGain;
  35340. private _inputAudioNode;
  35341. private _outputAudioNode;
  35342. private _coneInnerAngle;
  35343. private _coneOuterAngle;
  35344. private _coneOuterGain;
  35345. private _scene;
  35346. private _connectedTransformNode;
  35347. private _customAttenuationFunction;
  35348. private _registerFunc;
  35349. private _isOutputConnected;
  35350. private _htmlAudioElement;
  35351. private _urlType;
  35352. /** @hidden */
  35353. static _SceneComponentInitialization: (scene: Scene) => void;
  35354. /**
  35355. * Create a sound and attach it to a scene
  35356. * @param name Name of your sound
  35357. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35358. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35359. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35360. */
  35361. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  35362. /**
  35363. * Release the sound and its associated resources
  35364. */
  35365. dispose(): void;
  35366. /**
  35367. * Gets if the sounds is ready to be played or not.
  35368. * @returns true if ready, otherwise false
  35369. */
  35370. isReady(): boolean;
  35371. private _soundLoaded;
  35372. /**
  35373. * Sets the data of the sound from an audiobuffer
  35374. * @param audioBuffer The audioBuffer containing the data
  35375. */
  35376. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35377. /**
  35378. * Updates the current sounds options such as maxdistance, loop...
  35379. * @param options A JSON object containing values named as the object properties
  35380. */
  35381. updateOptions(options: any): void;
  35382. private _createSpatialParameters;
  35383. private _updateSpatialParameters;
  35384. /**
  35385. * Switch the panning model to HRTF:
  35386. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35388. */
  35389. switchPanningModelToHRTF(): void;
  35390. /**
  35391. * Switch the panning model to Equal Power:
  35392. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35394. */
  35395. switchPanningModelToEqualPower(): void;
  35396. private _switchPanningModel;
  35397. /**
  35398. * Connect this sound to a sound track audio node like gain...
  35399. * @param soundTrackAudioNode the sound track audio node to connect to
  35400. */
  35401. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35402. /**
  35403. * Transform this sound into a directional source
  35404. * @param coneInnerAngle Size of the inner cone in degree
  35405. * @param coneOuterAngle Size of the outer cone in degree
  35406. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35407. */
  35408. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35409. /**
  35410. * Gets or sets the inner angle for the directional cone.
  35411. */
  35412. /**
  35413. * Gets or sets the inner angle for the directional cone.
  35414. */
  35415. directionalConeInnerAngle: number;
  35416. /**
  35417. * Gets or sets the outer angle for the directional cone.
  35418. */
  35419. /**
  35420. * Gets or sets the outer angle for the directional cone.
  35421. */
  35422. directionalConeOuterAngle: number;
  35423. /**
  35424. * Sets the position of the emitter if spatial sound is enabled
  35425. * @param newPosition Defines the new posisiton
  35426. */
  35427. setPosition(newPosition: Vector3): void;
  35428. /**
  35429. * Sets the local direction of the emitter if spatial sound is enabled
  35430. * @param newLocalDirection Defines the new local direction
  35431. */
  35432. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35433. private _updateDirection;
  35434. /** @hidden */
  35435. updateDistanceFromListener(): void;
  35436. /**
  35437. * Sets a new custom attenuation function for the sound.
  35438. * @param callback Defines the function used for the attenuation
  35439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35440. */
  35441. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35442. /**
  35443. * Play the sound
  35444. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35445. * @param offset (optional) Start the sound setting it at a specific time
  35446. */
  35447. play(time?: number, offset?: number): void;
  35448. private _onended;
  35449. /**
  35450. * Stop the sound
  35451. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35452. */
  35453. stop(time?: number): void;
  35454. /**
  35455. * Put the sound in pause
  35456. */
  35457. pause(): void;
  35458. /**
  35459. * Sets a dedicated volume for this sounds
  35460. * @param newVolume Define the new volume of the sound
  35461. * @param time Define in how long the sound should be at this value
  35462. */
  35463. setVolume(newVolume: number, time?: number): void;
  35464. /**
  35465. * Set the sound play back rate
  35466. * @param newPlaybackRate Define the playback rate the sound should be played at
  35467. */
  35468. setPlaybackRate(newPlaybackRate: number): void;
  35469. /**
  35470. * Gets the volume of the sound.
  35471. * @returns the volume of the sound
  35472. */
  35473. getVolume(): number;
  35474. /**
  35475. * Attach the sound to a dedicated mesh
  35476. * @param transformNode The transform node to connect the sound with
  35477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35478. */
  35479. attachToMesh(transformNode: TransformNode): void;
  35480. /**
  35481. * Detach the sound from the previously attached mesh
  35482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35483. */
  35484. detachFromMesh(): void;
  35485. private _onRegisterAfterWorldMatrixUpdate;
  35486. /**
  35487. * Clone the current sound in the scene.
  35488. * @returns the new sound clone
  35489. */
  35490. clone(): Nullable<Sound>;
  35491. /**
  35492. * Gets the current underlying audio buffer containing the data
  35493. * @returns the audio buffer
  35494. */
  35495. getAudioBuffer(): Nullable<AudioBuffer>;
  35496. /**
  35497. * Serializes the Sound in a JSON representation
  35498. * @returns the JSON representation of the sound
  35499. */
  35500. serialize(): any;
  35501. /**
  35502. * Parse a JSON representation of a sound to innstantiate in a given scene
  35503. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35504. * @param scene Define the scene the new parsed sound should be created in
  35505. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35506. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35507. * @returns the newly parsed sound
  35508. */
  35509. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35510. }
  35511. }
  35512. declare module "babylonjs/Actions/directAudioActions" {
  35513. import { Action } from "babylonjs/Actions/action";
  35514. import { Condition } from "babylonjs/Actions/condition";
  35515. import { Sound } from "babylonjs/Audio/sound";
  35516. /**
  35517. * This defines an action helpful to play a defined sound on a triggered action.
  35518. */
  35519. export class PlaySoundAction extends Action {
  35520. private _sound;
  35521. /**
  35522. * Instantiate the action
  35523. * @param triggerOptions defines the trigger options
  35524. * @param sound defines the sound to play
  35525. * @param condition defines the trigger related conditions
  35526. */
  35527. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35528. /** @hidden */
  35529. _prepare(): void;
  35530. /**
  35531. * Execute the action and play the sound.
  35532. */
  35533. execute(): void;
  35534. /**
  35535. * Serializes the actions and its related information.
  35536. * @param parent defines the object to serialize in
  35537. * @returns the serialized object
  35538. */
  35539. serialize(parent: any): any;
  35540. }
  35541. /**
  35542. * This defines an action helpful to stop a defined sound on a triggered action.
  35543. */
  35544. export class StopSoundAction extends Action {
  35545. private _sound;
  35546. /**
  35547. * Instantiate the action
  35548. * @param triggerOptions defines the trigger options
  35549. * @param sound defines the sound to stop
  35550. * @param condition defines the trigger related conditions
  35551. */
  35552. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35553. /** @hidden */
  35554. _prepare(): void;
  35555. /**
  35556. * Execute the action and stop the sound.
  35557. */
  35558. execute(): void;
  35559. /**
  35560. * Serializes the actions and its related information.
  35561. * @param parent defines the object to serialize in
  35562. * @returns the serialized object
  35563. */
  35564. serialize(parent: any): any;
  35565. }
  35566. }
  35567. declare module "babylonjs/Actions/interpolateValueAction" {
  35568. import { Action } from "babylonjs/Actions/action";
  35569. import { Condition } from "babylonjs/Actions/condition";
  35570. import { Observable } from "babylonjs/Misc/observable";
  35571. /**
  35572. * This defines an action responsible to change the value of a property
  35573. * by interpolating between its current value and the newly set one once triggered.
  35574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35575. */
  35576. export class InterpolateValueAction extends Action {
  35577. /**
  35578. * Defines the path of the property where the value should be interpolated
  35579. */
  35580. propertyPath: string;
  35581. /**
  35582. * Defines the target value at the end of the interpolation.
  35583. */
  35584. value: any;
  35585. /**
  35586. * Defines the time it will take for the property to interpolate to the value.
  35587. */
  35588. duration: number;
  35589. /**
  35590. * Defines if the other scene animations should be stopped when the action has been triggered
  35591. */
  35592. stopOtherAnimations?: boolean;
  35593. /**
  35594. * Defines a callback raised once the interpolation animation has been done.
  35595. */
  35596. onInterpolationDone?: () => void;
  35597. /**
  35598. * Observable triggered once the interpolation animation has been done.
  35599. */
  35600. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35601. private _target;
  35602. private _effectiveTarget;
  35603. private _property;
  35604. /**
  35605. * Instantiate the action
  35606. * @param triggerOptions defines the trigger options
  35607. * @param target defines the object containing the value to interpolate
  35608. * @param propertyPath defines the path to the property in the target object
  35609. * @param value defines the target value at the end of the interpolation
  35610. * @param duration deines the time it will take for the property to interpolate to the value.
  35611. * @param condition defines the trigger related conditions
  35612. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35613. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35614. */
  35615. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35616. /** @hidden */
  35617. _prepare(): void;
  35618. /**
  35619. * Execute the action starts the value interpolation.
  35620. */
  35621. execute(): void;
  35622. /**
  35623. * Serializes the actions and its related information.
  35624. * @param parent defines the object to serialize in
  35625. * @returns the serialized object
  35626. */
  35627. serialize(parent: any): any;
  35628. }
  35629. }
  35630. declare module "babylonjs/Actions/index" {
  35631. export * from "babylonjs/Actions/action";
  35632. export * from "babylonjs/Actions/actionEvent";
  35633. export * from "babylonjs/Actions/actionManager";
  35634. export * from "babylonjs/Actions/condition";
  35635. export * from "babylonjs/Actions/directActions";
  35636. export * from "babylonjs/Actions/directAudioActions";
  35637. export * from "babylonjs/Actions/interpolateValueAction";
  35638. }
  35639. declare module "babylonjs/Animations/index" {
  35640. export * from "babylonjs/Animations/animatable";
  35641. export * from "babylonjs/Animations/animation";
  35642. export * from "babylonjs/Animations/animationGroup";
  35643. export * from "babylonjs/Animations/animationPropertiesOverride";
  35644. export * from "babylonjs/Animations/easing";
  35645. export * from "babylonjs/Animations/runtimeAnimation";
  35646. }
  35647. declare module "babylonjs/Audio/soundTrack" {
  35648. import { Sound } from "babylonjs/Audio/sound";
  35649. import { Analyser } from "babylonjs/Audio/analyser";
  35650. import { Scene } from "babylonjs/scene";
  35651. /**
  35652. * Options allowed during the creation of a sound track.
  35653. */
  35654. export interface ISoundTrackOptions {
  35655. /**
  35656. * The volume the sound track should take during creation
  35657. */
  35658. volume?: number;
  35659. /**
  35660. * Define if the sound track is the main sound track of the scene
  35661. */
  35662. mainTrack?: boolean;
  35663. }
  35664. /**
  35665. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35666. * It will be also used in a future release to apply effects on a specific track.
  35667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35668. */
  35669. export class SoundTrack {
  35670. /**
  35671. * The unique identifier of the sound track in the scene.
  35672. */
  35673. id: number;
  35674. /**
  35675. * The list of sounds included in the sound track.
  35676. */
  35677. soundCollection: Array<Sound>;
  35678. private _outputAudioNode;
  35679. private _scene;
  35680. private _isMainTrack;
  35681. private _connectedAnalyser;
  35682. private _options;
  35683. private _isInitialized;
  35684. /**
  35685. * Creates a new sound track.
  35686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35687. * @param scene Define the scene the sound track belongs to
  35688. * @param options
  35689. */
  35690. constructor(scene: Scene, options?: ISoundTrackOptions);
  35691. private _initializeSoundTrackAudioGraph;
  35692. /**
  35693. * Release the sound track and its associated resources
  35694. */
  35695. dispose(): void;
  35696. /**
  35697. * Adds a sound to this sound track
  35698. * @param sound define the cound to add
  35699. * @ignoreNaming
  35700. */
  35701. AddSound(sound: Sound): void;
  35702. /**
  35703. * Removes a sound to this sound track
  35704. * @param sound define the cound to remove
  35705. * @ignoreNaming
  35706. */
  35707. RemoveSound(sound: Sound): void;
  35708. /**
  35709. * Set a global volume for the full sound track.
  35710. * @param newVolume Define the new volume of the sound track
  35711. */
  35712. setVolume(newVolume: number): void;
  35713. /**
  35714. * Switch the panning model to HRTF:
  35715. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35717. */
  35718. switchPanningModelToHRTF(): void;
  35719. /**
  35720. * Switch the panning model to Equal Power:
  35721. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35722. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35723. */
  35724. switchPanningModelToEqualPower(): void;
  35725. /**
  35726. * Connect the sound track to an audio analyser allowing some amazing
  35727. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35729. * @param analyser The analyser to connect to the engine
  35730. */
  35731. connectToAnalyser(analyser: Analyser): void;
  35732. }
  35733. }
  35734. declare module "babylonjs/Audio/audioSceneComponent" {
  35735. import { Sound } from "babylonjs/Audio/sound";
  35736. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35737. import { Nullable } from "babylonjs/types";
  35738. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35739. import { Scene } from "babylonjs/scene";
  35740. import { AbstractScene } from "babylonjs/abstractScene";
  35741. module "babylonjs/abstractScene" {
  35742. interface AbstractScene {
  35743. /**
  35744. * The list of sounds used in the scene.
  35745. */
  35746. sounds: Nullable<Array<Sound>>;
  35747. }
  35748. }
  35749. module "babylonjs/scene" {
  35750. interface Scene {
  35751. /**
  35752. * @hidden
  35753. * Backing field
  35754. */
  35755. _mainSoundTrack: SoundTrack;
  35756. /**
  35757. * The main sound track played by the scene.
  35758. * It cotains your primary collection of sounds.
  35759. */
  35760. mainSoundTrack: SoundTrack;
  35761. /**
  35762. * The list of sound tracks added to the scene
  35763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35764. */
  35765. soundTracks: Nullable<Array<SoundTrack>>;
  35766. /**
  35767. * Gets a sound using a given name
  35768. * @param name defines the name to search for
  35769. * @return the found sound or null if not found at all.
  35770. */
  35771. getSoundByName(name: string): Nullable<Sound>;
  35772. /**
  35773. * Gets or sets if audio support is enabled
  35774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35775. */
  35776. audioEnabled: boolean;
  35777. /**
  35778. * Gets or sets if audio will be output to headphones
  35779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35780. */
  35781. headphone: boolean;
  35782. }
  35783. }
  35784. /**
  35785. * Defines the sound scene component responsible to manage any sounds
  35786. * in a given scene.
  35787. */
  35788. export class AudioSceneComponent implements ISceneSerializableComponent {
  35789. /**
  35790. * The component name helpfull to identify the component in the list of scene components.
  35791. */
  35792. readonly name: string;
  35793. /**
  35794. * The scene the component belongs to.
  35795. */
  35796. scene: Scene;
  35797. private _audioEnabled;
  35798. /**
  35799. * Gets whether audio is enabled or not.
  35800. * Please use related enable/disable method to switch state.
  35801. */
  35802. readonly audioEnabled: boolean;
  35803. private _headphone;
  35804. /**
  35805. * Gets whether audio is outputing to headphone or not.
  35806. * Please use the according Switch methods to change output.
  35807. */
  35808. readonly headphone: boolean;
  35809. /**
  35810. * Creates a new instance of the component for the given scene
  35811. * @param scene Defines the scene to register the component in
  35812. */
  35813. constructor(scene: Scene);
  35814. /**
  35815. * Registers the component in a given scene
  35816. */
  35817. register(): void;
  35818. /**
  35819. * Rebuilds the elements related to this component in case of
  35820. * context lost for instance.
  35821. */
  35822. rebuild(): void;
  35823. /**
  35824. * Serializes the component data to the specified json object
  35825. * @param serializationObject The object to serialize to
  35826. */
  35827. serialize(serializationObject: any): void;
  35828. /**
  35829. * Adds all the element from the container to the scene
  35830. * @param container the container holding the elements
  35831. */
  35832. addFromContainer(container: AbstractScene): void;
  35833. /**
  35834. * Removes all the elements in the container from the scene
  35835. * @param container contains the elements to remove
  35836. */
  35837. removeFromContainer(container: AbstractScene): void;
  35838. /**
  35839. * Disposes the component and the associated ressources.
  35840. */
  35841. dispose(): void;
  35842. /**
  35843. * Disables audio in the associated scene.
  35844. */
  35845. disableAudio(): void;
  35846. /**
  35847. * Enables audio in the associated scene.
  35848. */
  35849. enableAudio(): void;
  35850. /**
  35851. * Switch audio to headphone output.
  35852. */
  35853. switchAudioModeForHeadphones(): void;
  35854. /**
  35855. * Switch audio to normal speakers.
  35856. */
  35857. switchAudioModeForNormalSpeakers(): void;
  35858. private _afterRender;
  35859. }
  35860. }
  35861. declare module "babylonjs/Audio/weightedsound" {
  35862. import { Sound } from "babylonjs/Audio/sound";
  35863. /**
  35864. * Wraps one or more Sound objects and selects one with random weight for playback.
  35865. */
  35866. export class WeightedSound {
  35867. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35868. loop: boolean;
  35869. private _coneInnerAngle;
  35870. private _coneOuterAngle;
  35871. private _volume;
  35872. /** A Sound is currently playing. */
  35873. isPlaying: boolean;
  35874. /** A Sound is currently paused. */
  35875. isPaused: boolean;
  35876. private _sounds;
  35877. private _weights;
  35878. private _currentIndex?;
  35879. /**
  35880. * Creates a new WeightedSound from the list of sounds given.
  35881. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35882. * @param sounds Array of Sounds that will be selected from.
  35883. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35884. */
  35885. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35886. /**
  35887. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35888. */
  35889. /**
  35890. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35891. */
  35892. directionalConeInnerAngle: number;
  35893. /**
  35894. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35895. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35896. */
  35897. /**
  35898. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35899. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35900. */
  35901. directionalConeOuterAngle: number;
  35902. /**
  35903. * Playback volume.
  35904. */
  35905. /**
  35906. * Playback volume.
  35907. */
  35908. volume: number;
  35909. private _onended;
  35910. /**
  35911. * Suspend playback
  35912. */
  35913. pause(): void;
  35914. /**
  35915. * Stop playback
  35916. */
  35917. stop(): void;
  35918. /**
  35919. * Start playback.
  35920. * @param startOffset Position the clip head at a specific time in seconds.
  35921. */
  35922. play(startOffset?: number): void;
  35923. }
  35924. }
  35925. declare module "babylonjs/Audio/index" {
  35926. export * from "babylonjs/Audio/analyser";
  35927. export * from "babylonjs/Audio/audioEngine";
  35928. export * from "babylonjs/Audio/audioSceneComponent";
  35929. export * from "babylonjs/Audio/sound";
  35930. export * from "babylonjs/Audio/soundTrack";
  35931. export * from "babylonjs/Audio/weightedsound";
  35932. }
  35933. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35934. import { Behavior } from "babylonjs/Behaviors/behavior";
  35935. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35936. import { BackEase } from "babylonjs/Animations/easing";
  35937. /**
  35938. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35939. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35940. */
  35941. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35942. /**
  35943. * Gets the name of the behavior.
  35944. */
  35945. readonly name: string;
  35946. /**
  35947. * The easing function used by animations
  35948. */
  35949. static EasingFunction: BackEase;
  35950. /**
  35951. * The easing mode used by animations
  35952. */
  35953. static EasingMode: number;
  35954. /**
  35955. * The duration of the animation, in milliseconds
  35956. */
  35957. transitionDuration: number;
  35958. /**
  35959. * Length of the distance animated by the transition when lower radius is reached
  35960. */
  35961. lowerRadiusTransitionRange: number;
  35962. /**
  35963. * Length of the distance animated by the transition when upper radius is reached
  35964. */
  35965. upperRadiusTransitionRange: number;
  35966. private _autoTransitionRange;
  35967. /**
  35968. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35969. */
  35970. /**
  35971. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35972. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35973. */
  35974. autoTransitionRange: boolean;
  35975. private _attachedCamera;
  35976. private _onAfterCheckInputsObserver;
  35977. private _onMeshTargetChangedObserver;
  35978. /**
  35979. * Initializes the behavior.
  35980. */
  35981. init(): void;
  35982. /**
  35983. * Attaches the behavior to its arc rotate camera.
  35984. * @param camera Defines the camera to attach the behavior to
  35985. */
  35986. attach(camera: ArcRotateCamera): void;
  35987. /**
  35988. * Detaches the behavior from its current arc rotate camera.
  35989. */
  35990. detach(): void;
  35991. private _radiusIsAnimating;
  35992. private _radiusBounceTransition;
  35993. private _animatables;
  35994. private _cachedWheelPrecision;
  35995. /**
  35996. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35997. * @param radiusLimit The limit to check against.
  35998. * @return Bool to indicate if at limit.
  35999. */
  36000. private _isRadiusAtLimit;
  36001. /**
  36002. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36003. * @param radiusDelta The delta by which to animate to. Can be negative.
  36004. */
  36005. private _applyBoundRadiusAnimation;
  36006. /**
  36007. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36008. */
  36009. protected _clearAnimationLocks(): void;
  36010. /**
  36011. * Stops and removes all animations that have been applied to the camera
  36012. */
  36013. stopAllAnimations(): void;
  36014. }
  36015. }
  36016. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36017. import { Behavior } from "babylonjs/Behaviors/behavior";
  36018. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36019. import { ExponentialEase } from "babylonjs/Animations/easing";
  36020. import { Nullable } from "babylonjs/types";
  36021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36022. import { Vector3 } from "babylonjs/Maths/math";
  36023. /**
  36024. * 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.
  36025. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36026. */
  36027. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36028. /**
  36029. * Gets the name of the behavior.
  36030. */
  36031. readonly name: string;
  36032. private _mode;
  36033. private _radiusScale;
  36034. private _positionScale;
  36035. private _defaultElevation;
  36036. private _elevationReturnTime;
  36037. private _elevationReturnWaitTime;
  36038. private _zoomStopsAnimation;
  36039. private _framingTime;
  36040. /**
  36041. * The easing function used by animations
  36042. */
  36043. static EasingFunction: ExponentialEase;
  36044. /**
  36045. * The easing mode used by animations
  36046. */
  36047. static EasingMode: number;
  36048. /**
  36049. * Sets the current mode used by the behavior
  36050. */
  36051. /**
  36052. * Gets current mode used by the behavior.
  36053. */
  36054. mode: number;
  36055. /**
  36056. * Sets the scale applied to the radius (1 by default)
  36057. */
  36058. /**
  36059. * Gets the scale applied to the radius
  36060. */
  36061. radiusScale: number;
  36062. /**
  36063. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36064. */
  36065. /**
  36066. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36067. */
  36068. positionScale: number;
  36069. /**
  36070. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36071. * behaviour is triggered, in radians.
  36072. */
  36073. /**
  36074. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36075. * behaviour is triggered, in radians.
  36076. */
  36077. defaultElevation: number;
  36078. /**
  36079. * Sets the time (in milliseconds) taken to return to the default beta position.
  36080. * Negative value indicates camera should not return to default.
  36081. */
  36082. /**
  36083. * Gets the time (in milliseconds) taken to return to the default beta position.
  36084. * Negative value indicates camera should not return to default.
  36085. */
  36086. elevationReturnTime: number;
  36087. /**
  36088. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36089. */
  36090. /**
  36091. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36092. */
  36093. elevationReturnWaitTime: number;
  36094. /**
  36095. * Sets the flag that indicates if user zooming should stop animation.
  36096. */
  36097. /**
  36098. * Gets the flag that indicates if user zooming should stop animation.
  36099. */
  36100. zoomStopsAnimation: boolean;
  36101. /**
  36102. * Sets the transition time when framing the mesh, in milliseconds
  36103. */
  36104. /**
  36105. * Gets the transition time when framing the mesh, in milliseconds
  36106. */
  36107. framingTime: number;
  36108. /**
  36109. * Define if the behavior should automatically change the configured
  36110. * camera limits and sensibilities.
  36111. */
  36112. autoCorrectCameraLimitsAndSensibility: boolean;
  36113. private _onPrePointerObservableObserver;
  36114. private _onAfterCheckInputsObserver;
  36115. private _onMeshTargetChangedObserver;
  36116. private _attachedCamera;
  36117. private _isPointerDown;
  36118. private _lastInteractionTime;
  36119. /**
  36120. * Initializes the behavior.
  36121. */
  36122. init(): void;
  36123. /**
  36124. * Attaches the behavior to its arc rotate camera.
  36125. * @param camera Defines the camera to attach the behavior to
  36126. */
  36127. attach(camera: ArcRotateCamera): void;
  36128. /**
  36129. * Detaches the behavior from its current arc rotate camera.
  36130. */
  36131. detach(): void;
  36132. private _animatables;
  36133. private _betaIsAnimating;
  36134. private _betaTransition;
  36135. private _radiusTransition;
  36136. private _vectorTransition;
  36137. /**
  36138. * Targets the given mesh and updates zoom level accordingly.
  36139. * @param mesh The mesh to target.
  36140. * @param radius Optional. If a cached radius position already exists, overrides default.
  36141. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36142. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36143. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36144. */
  36145. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36146. /**
  36147. * Targets the given mesh with its children and updates zoom level accordingly.
  36148. * @param mesh The mesh to target.
  36149. * @param radius Optional. If a cached radius position already exists, overrides default.
  36150. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36151. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36152. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36153. */
  36154. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36155. /**
  36156. * Targets the given meshes with their children and updates zoom level accordingly.
  36157. * @param meshes The mesh to target.
  36158. * @param radius Optional. If a cached radius position already exists, overrides default.
  36159. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36160. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36161. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36162. */
  36163. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36164. /**
  36165. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36166. * @param minimumWorld Determines the smaller position of the bounding box extend
  36167. * @param maximumWorld Determines the bigger position of the bounding box extend
  36168. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36169. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36170. */
  36171. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36172. /**
  36173. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36174. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36175. * frustum width.
  36176. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36177. * to fully enclose the mesh in the viewing frustum.
  36178. */
  36179. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36180. /**
  36181. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36182. * is automatically returned to its default position (expected to be above ground plane).
  36183. */
  36184. private _maintainCameraAboveGround;
  36185. /**
  36186. * Returns the frustum slope based on the canvas ratio and camera FOV
  36187. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36188. */
  36189. private _getFrustumSlope;
  36190. /**
  36191. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36192. */
  36193. private _clearAnimationLocks;
  36194. /**
  36195. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36196. */
  36197. private _applyUserInteraction;
  36198. /**
  36199. * Stops and removes all animations that have been applied to the camera
  36200. */
  36201. stopAllAnimations(): void;
  36202. /**
  36203. * Gets a value indicating if the user is moving the camera
  36204. */
  36205. readonly isUserIsMoving: boolean;
  36206. /**
  36207. * The camera can move all the way towards the mesh.
  36208. */
  36209. static IgnoreBoundsSizeMode: number;
  36210. /**
  36211. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36212. */
  36213. static FitFrustumSidesMode: number;
  36214. }
  36215. }
  36216. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36217. import { Nullable } from "babylonjs/types";
  36218. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36219. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36220. /**
  36221. * Manage the pointers inputs to control an arc rotate camera.
  36222. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36223. */
  36224. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  36225. /**
  36226. * Defines the camera the input is attached to.
  36227. */
  36228. camera: ArcRotateCamera;
  36229. /**
  36230. * Defines the buttons associated with the input to handle camera move.
  36231. */
  36232. buttons: number[];
  36233. /**
  36234. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36235. */
  36236. angularSensibilityX: number;
  36237. /**
  36238. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36239. */
  36240. angularSensibilityY: number;
  36241. /**
  36242. * Defines the pointer pinch precision or how fast is the camera zooming.
  36243. */
  36244. pinchPrecision: number;
  36245. /**
  36246. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  36247. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36248. */
  36249. pinchDeltaPercentage: number;
  36250. /**
  36251. * Defines the pointer panning sensibility or how fast is the camera moving.
  36252. */
  36253. panningSensibility: number;
  36254. /**
  36255. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36256. */
  36257. multiTouchPanning: boolean;
  36258. /**
  36259. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  36260. */
  36261. multiTouchPanAndZoom: boolean;
  36262. /**
  36263. * Revers pinch action direction.
  36264. */
  36265. pinchInwards: boolean;
  36266. private _isPanClick;
  36267. private _pointerInput;
  36268. private _observer;
  36269. private _onMouseMove;
  36270. private _onGestureStart;
  36271. private _onGesture;
  36272. private _MSGestureHandler;
  36273. private _onLostFocus;
  36274. private _onContextMenu;
  36275. /**
  36276. * Attach the input controls to a specific dom element to get the input from.
  36277. * @param element Defines the element the controls should be listened from
  36278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36279. */
  36280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36281. /**
  36282. * Detach the current controls from the specified dom element.
  36283. * @param element Defines the element to stop listening the inputs from
  36284. */
  36285. detachControl(element: Nullable<HTMLElement>): void;
  36286. /**
  36287. * Gets the class name of the current intput.
  36288. * @returns the class name
  36289. */
  36290. getClassName(): string;
  36291. /**
  36292. * Get the friendly name associated with the input class.
  36293. * @returns the input friendly name
  36294. */
  36295. getSimpleName(): string;
  36296. }
  36297. }
  36298. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36299. import { Nullable } from "babylonjs/types";
  36300. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36301. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36302. /**
  36303. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36304. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36305. */
  36306. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36307. /**
  36308. * Defines the camera the input is attached to.
  36309. */
  36310. camera: ArcRotateCamera;
  36311. /**
  36312. * Defines the list of key codes associated with the up action (increase alpha)
  36313. */
  36314. keysUp: number[];
  36315. /**
  36316. * Defines the list of key codes associated with the down action (decrease alpha)
  36317. */
  36318. keysDown: number[];
  36319. /**
  36320. * Defines the list of key codes associated with the left action (increase beta)
  36321. */
  36322. keysLeft: number[];
  36323. /**
  36324. * Defines the list of key codes associated with the right action (decrease beta)
  36325. */
  36326. keysRight: number[];
  36327. /**
  36328. * Defines the list of key codes associated with the reset action.
  36329. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36330. */
  36331. keysReset: number[];
  36332. /**
  36333. * Defines the panning sensibility of the inputs.
  36334. * (How fast is the camera paning)
  36335. */
  36336. panningSensibility: number;
  36337. /**
  36338. * Defines the zooming sensibility of the inputs.
  36339. * (How fast is the camera zooming)
  36340. */
  36341. zoomingSensibility: number;
  36342. /**
  36343. * Defines wether maintaining the alt key down switch the movement mode from
  36344. * orientation to zoom.
  36345. */
  36346. useAltToZoom: boolean;
  36347. /**
  36348. * Rotation speed of the camera
  36349. */
  36350. angularSpeed: number;
  36351. private _keys;
  36352. private _ctrlPressed;
  36353. private _altPressed;
  36354. private _onCanvasBlurObserver;
  36355. private _onKeyboardObserver;
  36356. private _engine;
  36357. private _scene;
  36358. /**
  36359. * Attach the input controls to a specific dom element to get the input from.
  36360. * @param element Defines the element the controls should be listened from
  36361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36362. */
  36363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36364. /**
  36365. * Detach the current controls from the specified dom element.
  36366. * @param element Defines the element to stop listening the inputs from
  36367. */
  36368. detachControl(element: Nullable<HTMLElement>): void;
  36369. /**
  36370. * Update the current camera state depending on the inputs that have been used this frame.
  36371. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36372. */
  36373. checkInputs(): void;
  36374. /**
  36375. * Gets the class name of the current intput.
  36376. * @returns the class name
  36377. */
  36378. getClassName(): string;
  36379. /**
  36380. * Get the friendly name associated with the input class.
  36381. * @returns the input friendly name
  36382. */
  36383. getSimpleName(): string;
  36384. }
  36385. }
  36386. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36387. import { Nullable } from "babylonjs/types";
  36388. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36389. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36390. /**
  36391. * Manage the mouse wheel inputs to control an arc rotate camera.
  36392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36393. */
  36394. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36395. /**
  36396. * Defines the camera the input is attached to.
  36397. */
  36398. camera: ArcRotateCamera;
  36399. /**
  36400. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36401. */
  36402. wheelPrecision: number;
  36403. /**
  36404. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36405. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36406. */
  36407. wheelDeltaPercentage: number;
  36408. private _wheel;
  36409. private _observer;
  36410. /**
  36411. * Attach the input controls to a specific dom element to get the input from.
  36412. * @param element Defines the element the controls should be listened from
  36413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36414. */
  36415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36416. /**
  36417. * Detach the current controls from the specified dom element.
  36418. * @param element Defines the element to stop listening the inputs from
  36419. */
  36420. detachControl(element: Nullable<HTMLElement>): void;
  36421. /**
  36422. * Gets the class name of the current intput.
  36423. * @returns the class name
  36424. */
  36425. getClassName(): string;
  36426. /**
  36427. * Get the friendly name associated with the input class.
  36428. * @returns the input friendly name
  36429. */
  36430. getSimpleName(): string;
  36431. }
  36432. }
  36433. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36434. import { Nullable } from "babylonjs/types";
  36435. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36436. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36437. /**
  36438. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36440. */
  36441. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36442. /**
  36443. * Defines the camera the input is attached to.
  36444. */
  36445. camera: ArcRotateCamera;
  36446. /**
  36447. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36448. */
  36449. alphaCorrection: number;
  36450. /**
  36451. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36452. */
  36453. gammaCorrection: number;
  36454. private _alpha;
  36455. private _gamma;
  36456. private _dirty;
  36457. private _deviceOrientationHandler;
  36458. /**
  36459. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36460. */
  36461. constructor();
  36462. /**
  36463. * Attach the input controls to a specific dom element to get the input from.
  36464. * @param element Defines the element the controls should be listened from
  36465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36466. */
  36467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36468. /** @hidden */
  36469. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36470. /**
  36471. * Update the current camera state depending on the inputs that have been used this frame.
  36472. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36473. */
  36474. checkInputs(): void;
  36475. /**
  36476. * Detach the current controls from the specified dom element.
  36477. * @param element Defines the element to stop listening the inputs from
  36478. */
  36479. detachControl(element: Nullable<HTMLElement>): void;
  36480. /**
  36481. * Gets the class name of the current intput.
  36482. * @returns the class name
  36483. */
  36484. getClassName(): string;
  36485. /**
  36486. * Get the friendly name associated with the input class.
  36487. * @returns the input friendly name
  36488. */
  36489. getSimpleName(): string;
  36490. }
  36491. }
  36492. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36493. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36494. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36495. /**
  36496. * Default Inputs manager for the ArcRotateCamera.
  36497. * It groups all the default supported inputs for ease of use.
  36498. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36499. */
  36500. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36501. /**
  36502. * Instantiates a new ArcRotateCameraInputsManager.
  36503. * @param camera Defines the camera the inputs belong to
  36504. */
  36505. constructor(camera: ArcRotateCamera);
  36506. /**
  36507. * Add mouse wheel input support to the input manager.
  36508. * @returns the current input manager
  36509. */
  36510. addMouseWheel(): ArcRotateCameraInputsManager;
  36511. /**
  36512. * Add pointers input support to the input manager.
  36513. * @returns the current input manager
  36514. */
  36515. addPointers(): ArcRotateCameraInputsManager;
  36516. /**
  36517. * Add keyboard input support to the input manager.
  36518. * @returns the current input manager
  36519. */
  36520. addKeyboard(): ArcRotateCameraInputsManager;
  36521. /**
  36522. * Add orientation input support to the input manager.
  36523. * @returns the current input manager
  36524. */
  36525. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36526. }
  36527. }
  36528. declare module "babylonjs/Cameras/arcRotateCamera" {
  36529. import { Observable } from "babylonjs/Misc/observable";
  36530. import { Nullable } from "babylonjs/types";
  36531. import { Scene } from "babylonjs/scene";
  36532. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36534. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36535. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36536. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36537. import { Collider } from "babylonjs/Collisions/collider";
  36538. import { Camera } from "babylonjs/Cameras/camera";
  36539. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36540. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36541. /**
  36542. * This represents an orbital type of camera.
  36543. *
  36544. * 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.
  36545. * 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.
  36546. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36547. */
  36548. export class ArcRotateCamera extends TargetCamera {
  36549. /**
  36550. * Defines the rotation angle of the camera along the longitudinal axis.
  36551. */
  36552. alpha: number;
  36553. /**
  36554. * Defines the rotation angle of the camera along the latitudinal axis.
  36555. */
  36556. beta: number;
  36557. /**
  36558. * Defines the radius of the camera from it s target point.
  36559. */
  36560. radius: number;
  36561. protected _target: Vector3;
  36562. protected _targetHost: Nullable<AbstractMesh>;
  36563. /**
  36564. * Defines the target point of the camera.
  36565. * The camera looks towards it form the radius distance.
  36566. */
  36567. target: Vector3;
  36568. /**
  36569. * Current inertia value on the longitudinal axis.
  36570. * The bigger this number the longer it will take for the camera to stop.
  36571. */
  36572. inertialAlphaOffset: number;
  36573. /**
  36574. * Current inertia value on the latitudinal axis.
  36575. * The bigger this number the longer it will take for the camera to stop.
  36576. */
  36577. inertialBetaOffset: number;
  36578. /**
  36579. * Current inertia value on the radius axis.
  36580. * The bigger this number the longer it will take for the camera to stop.
  36581. */
  36582. inertialRadiusOffset: number;
  36583. /**
  36584. * Minimum allowed angle on the longitudinal axis.
  36585. * This can help limiting how the Camera is able to move in the scene.
  36586. */
  36587. lowerAlphaLimit: Nullable<number>;
  36588. /**
  36589. * Maximum allowed angle on the longitudinal axis.
  36590. * This can help limiting how the Camera is able to move in the scene.
  36591. */
  36592. upperAlphaLimit: Nullable<number>;
  36593. /**
  36594. * Minimum allowed angle on the latitudinal axis.
  36595. * This can help limiting how the Camera is able to move in the scene.
  36596. */
  36597. lowerBetaLimit: number;
  36598. /**
  36599. * Maximum allowed angle on the latitudinal axis.
  36600. * This can help limiting how the Camera is able to move in the scene.
  36601. */
  36602. upperBetaLimit: number;
  36603. /**
  36604. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36605. * This can help limiting how the Camera is able to move in the scene.
  36606. */
  36607. lowerRadiusLimit: Nullable<number>;
  36608. /**
  36609. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36610. * This can help limiting how the Camera is able to move in the scene.
  36611. */
  36612. upperRadiusLimit: Nullable<number>;
  36613. /**
  36614. * Defines the current inertia value used during panning of the camera along the X axis.
  36615. */
  36616. inertialPanningX: number;
  36617. /**
  36618. * Defines the current inertia value used during panning of the camera along the Y axis.
  36619. */
  36620. inertialPanningY: number;
  36621. /**
  36622. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36623. * Basically if your fingers moves away from more than this distance you will be considered
  36624. * in pinch mode.
  36625. */
  36626. pinchToPanMaxDistance: number;
  36627. /**
  36628. * Defines the maximum distance the camera can pan.
  36629. * This could help keeping the cammera always in your scene.
  36630. */
  36631. panningDistanceLimit: Nullable<number>;
  36632. /**
  36633. * Defines the target of the camera before paning.
  36634. */
  36635. panningOriginTarget: Vector3;
  36636. /**
  36637. * Defines the value of the inertia used during panning.
  36638. * 0 would mean stop inertia and one would mean no decelleration at all.
  36639. */
  36640. panningInertia: number;
  36641. /**
  36642. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36643. */
  36644. angularSensibilityX: number;
  36645. /**
  36646. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36647. */
  36648. angularSensibilityY: number;
  36649. /**
  36650. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36651. */
  36652. pinchPrecision: number;
  36653. /**
  36654. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36655. * It will be used instead of pinchDeltaPrecision if different from 0.
  36656. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36657. */
  36658. pinchDeltaPercentage: number;
  36659. /**
  36660. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36661. */
  36662. panningSensibility: number;
  36663. /**
  36664. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36665. */
  36666. keysUp: number[];
  36667. /**
  36668. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36669. */
  36670. keysDown: number[];
  36671. /**
  36672. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36673. */
  36674. keysLeft: number[];
  36675. /**
  36676. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36677. */
  36678. keysRight: number[];
  36679. /**
  36680. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36681. */
  36682. wheelPrecision: number;
  36683. /**
  36684. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36685. * It will be used instead of pinchDeltaPrecision if different from 0.
  36686. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36687. */
  36688. wheelDeltaPercentage: number;
  36689. /**
  36690. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36691. */
  36692. zoomOnFactor: number;
  36693. /**
  36694. * Defines a screen offset for the camera position.
  36695. */
  36696. targetScreenOffset: Vector2;
  36697. /**
  36698. * Allows the camera to be completely reversed.
  36699. * If false the camera can not arrive upside down.
  36700. */
  36701. allowUpsideDown: boolean;
  36702. /**
  36703. * Define if double tap/click is used to restore the previously saved state of the camera.
  36704. */
  36705. useInputToRestoreState: boolean;
  36706. /** @hidden */
  36707. _viewMatrix: Matrix;
  36708. /** @hidden */
  36709. _useCtrlForPanning: boolean;
  36710. /** @hidden */
  36711. _panningMouseButton: number;
  36712. /**
  36713. * Defines the input associated to the camera.
  36714. */
  36715. inputs: ArcRotateCameraInputsManager;
  36716. /** @hidden */
  36717. _reset: () => void;
  36718. /**
  36719. * Defines the allowed panning axis.
  36720. */
  36721. panningAxis: Vector3;
  36722. protected _localDirection: Vector3;
  36723. protected _transformedDirection: Vector3;
  36724. private _bouncingBehavior;
  36725. /**
  36726. * Gets the bouncing behavior of the camera if it has been enabled.
  36727. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36728. */
  36729. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36730. /**
  36731. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36732. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36733. */
  36734. useBouncingBehavior: boolean;
  36735. private _framingBehavior;
  36736. /**
  36737. * Gets the framing behavior of the camera if it has been enabled.
  36738. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36739. */
  36740. readonly framingBehavior: Nullable<FramingBehavior>;
  36741. /**
  36742. * Defines if the framing behavior of the camera is enabled on the camera.
  36743. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36744. */
  36745. useFramingBehavior: boolean;
  36746. private _autoRotationBehavior;
  36747. /**
  36748. * Gets the auto rotation behavior of the camera if it has been enabled.
  36749. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36750. */
  36751. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36752. /**
  36753. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36754. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36755. */
  36756. useAutoRotationBehavior: boolean;
  36757. /**
  36758. * Observable triggered when the mesh target has been changed on the camera.
  36759. */
  36760. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36761. /**
  36762. * Event raised when the camera is colliding with a mesh.
  36763. */
  36764. onCollide: (collidedMesh: AbstractMesh) => void;
  36765. /**
  36766. * Defines whether the camera should check collision with the objects oh the scene.
  36767. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36768. */
  36769. checkCollisions: boolean;
  36770. /**
  36771. * Defines the collision radius of the camera.
  36772. * This simulates a sphere around the camera.
  36773. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36774. */
  36775. collisionRadius: Vector3;
  36776. protected _collider: Collider;
  36777. protected _previousPosition: Vector3;
  36778. protected _collisionVelocity: Vector3;
  36779. protected _newPosition: Vector3;
  36780. protected _previousAlpha: number;
  36781. protected _previousBeta: number;
  36782. protected _previousRadius: number;
  36783. protected _collisionTriggered: boolean;
  36784. protected _targetBoundingCenter: Nullable<Vector3>;
  36785. private _computationVector;
  36786. private _tempAxisVector;
  36787. private _tempAxisRotationMatrix;
  36788. /**
  36789. * Instantiates a new ArcRotateCamera in a given scene
  36790. * @param name Defines the name of the camera
  36791. * @param alpha Defines the camera rotation along the logitudinal axis
  36792. * @param beta Defines the camera rotation along the latitudinal axis
  36793. * @param radius Defines the camera distance from its target
  36794. * @param target Defines the camera target
  36795. * @param scene Defines the scene the camera belongs to
  36796. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36797. */
  36798. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36799. /** @hidden */
  36800. _initCache(): void;
  36801. /** @hidden */
  36802. _updateCache(ignoreParentClass?: boolean): void;
  36803. protected _getTargetPosition(): Vector3;
  36804. private _storedAlpha;
  36805. private _storedBeta;
  36806. private _storedRadius;
  36807. private _storedTarget;
  36808. /**
  36809. * Stores the current state of the camera (alpha, beta, radius and target)
  36810. * @returns the camera itself
  36811. */
  36812. storeState(): Camera;
  36813. /**
  36814. * @hidden
  36815. * Restored camera state. You must call storeState() first
  36816. */
  36817. _restoreStateValues(): boolean;
  36818. /** @hidden */
  36819. _isSynchronizedViewMatrix(): boolean;
  36820. /**
  36821. * Attached controls to the current camera.
  36822. * @param element Defines the element the controls should be listened from
  36823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36824. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36825. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36826. */
  36827. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36828. /**
  36829. * Detach the current controls from the camera.
  36830. * The camera will stop reacting to inputs.
  36831. * @param element Defines the element to stop listening the inputs from
  36832. */
  36833. detachControl(element: HTMLElement): void;
  36834. /** @hidden */
  36835. _checkInputs(): void;
  36836. protected _checkLimits(): void;
  36837. /**
  36838. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  36839. */
  36840. rebuildAnglesAndRadius(): void;
  36841. /**
  36842. * Use a position to define the current camera related information like aplha, beta and radius
  36843. * @param position Defines the position to set the camera at
  36844. */
  36845. setPosition(position: Vector3): void;
  36846. /**
  36847. * Defines the target the camera should look at.
  36848. * This will automatically adapt alpha beta and radius to fit within the new target.
  36849. * @param target Defines the new target as a Vector or a mesh
  36850. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36851. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36852. */
  36853. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36854. /** @hidden */
  36855. _getViewMatrix(): Matrix;
  36856. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36857. /**
  36858. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36859. * @param meshes Defines the mesh to zoom on
  36860. * @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)
  36861. */
  36862. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36863. /**
  36864. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36865. * The target will be changed but the radius
  36866. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36867. * @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)
  36868. */
  36869. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36870. min: Vector3;
  36871. max: Vector3;
  36872. distance: number;
  36873. }, doNotUpdateMaxZ?: boolean): void;
  36874. /**
  36875. * @override
  36876. * Override Camera.createRigCamera
  36877. */
  36878. createRigCamera(name: string, cameraIndex: number): Camera;
  36879. /**
  36880. * @hidden
  36881. * @override
  36882. * Override Camera._updateRigCameras
  36883. */
  36884. _updateRigCameras(): void;
  36885. /**
  36886. * Destroy the camera and release the current resources hold by it.
  36887. */
  36888. dispose(): void;
  36889. /**
  36890. * Gets the current object class name.
  36891. * @return the class name
  36892. */
  36893. getClassName(): string;
  36894. }
  36895. }
  36896. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36897. import { Behavior } from "babylonjs/Behaviors/behavior";
  36898. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36899. /**
  36900. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36901. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36902. */
  36903. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36904. /**
  36905. * Gets the name of the behavior.
  36906. */
  36907. readonly name: string;
  36908. private _zoomStopsAnimation;
  36909. private _idleRotationSpeed;
  36910. private _idleRotationWaitTime;
  36911. private _idleRotationSpinupTime;
  36912. /**
  36913. * Sets the flag that indicates if user zooming should stop animation.
  36914. */
  36915. /**
  36916. * Gets the flag that indicates if user zooming should stop animation.
  36917. */
  36918. zoomStopsAnimation: boolean;
  36919. /**
  36920. * Sets the default speed at which the camera rotates around the model.
  36921. */
  36922. /**
  36923. * Gets the default speed at which the camera rotates around the model.
  36924. */
  36925. idleRotationSpeed: number;
  36926. /**
  36927. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36928. */
  36929. /**
  36930. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36931. */
  36932. idleRotationWaitTime: number;
  36933. /**
  36934. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36935. */
  36936. /**
  36937. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36938. */
  36939. idleRotationSpinupTime: number;
  36940. /**
  36941. * Gets a value indicating if the camera is currently rotating because of this behavior
  36942. */
  36943. readonly rotationInProgress: boolean;
  36944. private _onPrePointerObservableObserver;
  36945. private _onAfterCheckInputsObserver;
  36946. private _attachedCamera;
  36947. private _isPointerDown;
  36948. private _lastFrameTime;
  36949. private _lastInteractionTime;
  36950. private _cameraRotationSpeed;
  36951. /**
  36952. * Initializes the behavior.
  36953. */
  36954. init(): void;
  36955. /**
  36956. * Attaches the behavior to its arc rotate camera.
  36957. * @param camera Defines the camera to attach the behavior to
  36958. */
  36959. attach(camera: ArcRotateCamera): void;
  36960. /**
  36961. * Detaches the behavior from its current arc rotate camera.
  36962. */
  36963. detach(): void;
  36964. /**
  36965. * Returns true if user is scrolling.
  36966. * @return true if user is scrolling.
  36967. */
  36968. private _userIsZooming;
  36969. private _lastFrameRadius;
  36970. private _shouldAnimationStopForInteraction;
  36971. /**
  36972. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36973. */
  36974. private _applyUserInteraction;
  36975. private _userIsMoving;
  36976. }
  36977. }
  36978. declare module "babylonjs/Behaviors/Cameras/index" {
  36979. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36980. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36981. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36982. }
  36983. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36984. import { Mesh } from "babylonjs/Meshes/mesh";
  36985. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36986. import { Behavior } from "babylonjs/Behaviors/behavior";
  36987. /**
  36988. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36989. */
  36990. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36991. private ui;
  36992. /**
  36993. * The name of the behavior
  36994. */
  36995. name: string;
  36996. /**
  36997. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36998. */
  36999. distanceAwayFromFace: number;
  37000. /**
  37001. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37002. */
  37003. distanceAwayFromBottomOfFace: number;
  37004. private _faceVectors;
  37005. private _target;
  37006. private _scene;
  37007. private _onRenderObserver;
  37008. private _tmpMatrix;
  37009. private _tmpVector;
  37010. /**
  37011. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37012. * @param ui The transform node that should be attched to the mesh
  37013. */
  37014. constructor(ui: TransformNode);
  37015. /**
  37016. * Initializes the behavior
  37017. */
  37018. init(): void;
  37019. private _closestFace;
  37020. private _zeroVector;
  37021. private _lookAtTmpMatrix;
  37022. private _lookAtToRef;
  37023. /**
  37024. * Attaches the AttachToBoxBehavior to the passed in mesh
  37025. * @param target The mesh that the specified node will be attached to
  37026. */
  37027. attach(target: Mesh): void;
  37028. /**
  37029. * Detaches the behavior from the mesh
  37030. */
  37031. detach(): void;
  37032. }
  37033. }
  37034. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37035. import { Behavior } from "babylonjs/Behaviors/behavior";
  37036. import { Mesh } from "babylonjs/Meshes/mesh";
  37037. /**
  37038. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37039. */
  37040. export class FadeInOutBehavior implements Behavior<Mesh> {
  37041. /**
  37042. * Time in milliseconds to delay before fading in (Default: 0)
  37043. */
  37044. delay: number;
  37045. /**
  37046. * Time in milliseconds for the mesh to fade in (Default: 300)
  37047. */
  37048. fadeInTime: number;
  37049. private _millisecondsPerFrame;
  37050. private _hovered;
  37051. private _hoverValue;
  37052. private _ownerNode;
  37053. /**
  37054. * Instatiates the FadeInOutBehavior
  37055. */
  37056. constructor();
  37057. /**
  37058. * The name of the behavior
  37059. */
  37060. readonly name: string;
  37061. /**
  37062. * Initializes the behavior
  37063. */
  37064. init(): void;
  37065. /**
  37066. * Attaches the fade behavior on the passed in mesh
  37067. * @param ownerNode The mesh that will be faded in/out once attached
  37068. */
  37069. attach(ownerNode: Mesh): void;
  37070. /**
  37071. * Detaches the behavior from the mesh
  37072. */
  37073. detach(): void;
  37074. /**
  37075. * Triggers the mesh to begin fading in or out
  37076. * @param value if the object should fade in or out (true to fade in)
  37077. */
  37078. fadeIn(value: boolean): void;
  37079. private _update;
  37080. private _setAllVisibility;
  37081. }
  37082. }
  37083. declare module "babylonjs/Misc/pivotTools" {
  37084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37085. /**
  37086. * Class containing a set of static utilities functions for managing Pivots
  37087. * @hidden
  37088. */
  37089. export class PivotTools {
  37090. private static _PivotCached;
  37091. private static _OldPivotPoint;
  37092. private static _PivotTranslation;
  37093. private static _PivotTmpVector;
  37094. /** @hidden */
  37095. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37096. /** @hidden */
  37097. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37098. }
  37099. }
  37100. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37101. import { Behavior } from "babylonjs/Behaviors/behavior";
  37102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37103. import { Observable } from "babylonjs/Misc/observable";
  37104. import { Vector3 } from "babylonjs/Maths/math";
  37105. import { Ray } from "babylonjs/Culling/ray";
  37106. /**
  37107. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37108. */
  37109. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37110. private static _AnyMouseID;
  37111. private _attachedNode;
  37112. private _dragPlane;
  37113. private _scene;
  37114. private _pointerObserver;
  37115. private _beforeRenderObserver;
  37116. private static _planeScene;
  37117. /**
  37118. * 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)
  37119. */
  37120. maxDragAngle: number;
  37121. /**
  37122. * @hidden
  37123. */
  37124. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37125. /**
  37126. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37127. */
  37128. currentDraggingPointerID: number;
  37129. /**
  37130. * The last position where the pointer hit the drag plane in world space
  37131. */
  37132. lastDragPosition: Vector3;
  37133. /**
  37134. * If the behavior is currently in a dragging state
  37135. */
  37136. dragging: boolean;
  37137. /**
  37138. * 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)
  37139. */
  37140. dragDeltaRatio: number;
  37141. /**
  37142. * If the drag plane orientation should be updated during the dragging (Default: true)
  37143. */
  37144. updateDragPlane: boolean;
  37145. private _debugMode;
  37146. private _moving;
  37147. /**
  37148. * Fires each time the attached mesh is dragged with the pointer
  37149. * * delta between last drag position and current drag position in world space
  37150. * * dragDistance along the drag axis
  37151. * * dragPlaneNormal normal of the current drag plane used during the drag
  37152. * * dragPlanePoint in world space where the drag intersects the drag plane
  37153. */
  37154. onDragObservable: Observable<{
  37155. delta: Vector3;
  37156. dragPlanePoint: Vector3;
  37157. dragPlaneNormal: Vector3;
  37158. dragDistance: number;
  37159. pointerId: number;
  37160. }>;
  37161. /**
  37162. * Fires each time a drag begins (eg. mouse down on mesh)
  37163. */
  37164. onDragStartObservable: Observable<{
  37165. dragPlanePoint: Vector3;
  37166. pointerId: number;
  37167. }>;
  37168. /**
  37169. * Fires each time a drag ends (eg. mouse release after drag)
  37170. */
  37171. onDragEndObservable: Observable<{
  37172. dragPlanePoint: Vector3;
  37173. pointerId: number;
  37174. }>;
  37175. /**
  37176. * If the attached mesh should be moved when dragged
  37177. */
  37178. moveAttached: boolean;
  37179. /**
  37180. * If the drag behavior will react to drag events (Default: true)
  37181. */
  37182. enabled: boolean;
  37183. /**
  37184. * If camera controls should be detached during the drag
  37185. */
  37186. detachCameraControls: boolean;
  37187. /**
  37188. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37189. */
  37190. useObjectOrienationForDragging: boolean;
  37191. private _options;
  37192. /**
  37193. * Creates a pointer drag behavior that can be attached to a mesh
  37194. * @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)
  37195. */
  37196. constructor(options?: {
  37197. dragAxis?: Vector3;
  37198. dragPlaneNormal?: Vector3;
  37199. });
  37200. /**
  37201. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37202. */
  37203. validateDrag: (targetPosition: Vector3) => boolean;
  37204. /**
  37205. * The name of the behavior
  37206. */
  37207. readonly name: string;
  37208. /**
  37209. * Initializes the behavior
  37210. */
  37211. init(): void;
  37212. private _tmpVector;
  37213. private _alternatePickedPoint;
  37214. private _worldDragAxis;
  37215. private _targetPosition;
  37216. private _attachedElement;
  37217. /**
  37218. * Attaches the drag behavior the passed in mesh
  37219. * @param ownerNode The mesh that will be dragged around once attached
  37220. */
  37221. attach(ownerNode: AbstractMesh): void;
  37222. /**
  37223. * Force relase the drag action by code.
  37224. */
  37225. releaseDrag(): void;
  37226. private _startDragRay;
  37227. private _lastPointerRay;
  37228. /**
  37229. * Simulates the start of a pointer drag event on the behavior
  37230. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37231. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37232. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37233. */
  37234. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37235. private _startDrag;
  37236. private _dragDelta;
  37237. private _moveDrag;
  37238. private _pickWithRayOnDragPlane;
  37239. private _pointA;
  37240. private _pointB;
  37241. private _pointC;
  37242. private _lineA;
  37243. private _lineB;
  37244. private _localAxis;
  37245. private _lookAt;
  37246. private _updateDragPlanePosition;
  37247. /**
  37248. * Detaches the behavior from the mesh
  37249. */
  37250. detach(): void;
  37251. }
  37252. }
  37253. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37254. import { Mesh } from "babylonjs/Meshes/mesh";
  37255. import { Behavior } from "babylonjs/Behaviors/behavior";
  37256. /**
  37257. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37258. */
  37259. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37260. private _dragBehaviorA;
  37261. private _dragBehaviorB;
  37262. private _startDistance;
  37263. private _initialScale;
  37264. private _targetScale;
  37265. private _ownerNode;
  37266. private _sceneRenderObserver;
  37267. /**
  37268. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37269. */
  37270. constructor();
  37271. /**
  37272. * The name of the behavior
  37273. */
  37274. readonly name: string;
  37275. /**
  37276. * Initializes the behavior
  37277. */
  37278. init(): void;
  37279. private _getCurrentDistance;
  37280. /**
  37281. * Attaches the scale behavior the passed in mesh
  37282. * @param ownerNode The mesh that will be scaled around once attached
  37283. */
  37284. attach(ownerNode: Mesh): void;
  37285. /**
  37286. * Detaches the behavior from the mesh
  37287. */
  37288. detach(): void;
  37289. }
  37290. }
  37291. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37292. import { Behavior } from "babylonjs/Behaviors/behavior";
  37293. import { Mesh } from "babylonjs/Meshes/mesh";
  37294. import { Observable } from "babylonjs/Misc/observable";
  37295. /**
  37296. * 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
  37297. */
  37298. export class SixDofDragBehavior implements Behavior<Mesh> {
  37299. private static _virtualScene;
  37300. private _ownerNode;
  37301. private _sceneRenderObserver;
  37302. private _scene;
  37303. private _targetPosition;
  37304. private _virtualOriginMesh;
  37305. private _virtualDragMesh;
  37306. private _pointerObserver;
  37307. private _moving;
  37308. private _startingOrientation;
  37309. /**
  37310. * 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)
  37311. */
  37312. private zDragFactor;
  37313. /**
  37314. * If the object should rotate to face the drag origin
  37315. */
  37316. rotateDraggedObject: boolean;
  37317. /**
  37318. * If the behavior is currently in a dragging state
  37319. */
  37320. dragging: boolean;
  37321. /**
  37322. * 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)
  37323. */
  37324. dragDeltaRatio: number;
  37325. /**
  37326. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37327. */
  37328. currentDraggingPointerID: number;
  37329. /**
  37330. * If camera controls should be detached during the drag
  37331. */
  37332. detachCameraControls: boolean;
  37333. /**
  37334. * Fires each time a drag starts
  37335. */
  37336. onDragStartObservable: Observable<{}>;
  37337. /**
  37338. * Fires each time a drag ends (eg. mouse release after drag)
  37339. */
  37340. onDragEndObservable: Observable<{}>;
  37341. /**
  37342. * 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
  37343. */
  37344. constructor();
  37345. /**
  37346. * The name of the behavior
  37347. */
  37348. readonly name: string;
  37349. /**
  37350. * Initializes the behavior
  37351. */
  37352. init(): void;
  37353. /**
  37354. * Attaches the scale behavior the passed in mesh
  37355. * @param ownerNode The mesh that will be scaled around once attached
  37356. */
  37357. attach(ownerNode: Mesh): void;
  37358. /**
  37359. * Detaches the behavior from the mesh
  37360. */
  37361. detach(): void;
  37362. }
  37363. }
  37364. declare module "babylonjs/Behaviors/Meshes/index" {
  37365. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37366. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37367. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37368. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37369. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37370. }
  37371. declare module "babylonjs/Behaviors/index" {
  37372. export * from "babylonjs/Behaviors/behavior";
  37373. export * from "babylonjs/Behaviors/Cameras/index";
  37374. export * from "babylonjs/Behaviors/Meshes/index";
  37375. }
  37376. declare module "babylonjs/Bones/boneIKController" {
  37377. import { Bone } from "babylonjs/Bones/bone";
  37378. import { Vector3 } from "babylonjs/Maths/math";
  37379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37380. import { Nullable } from "babylonjs/types";
  37381. /**
  37382. * Class used to apply inverse kinematics to bones
  37383. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37384. */
  37385. export class BoneIKController {
  37386. private static _tmpVecs;
  37387. private static _tmpQuat;
  37388. private static _tmpMats;
  37389. /**
  37390. * Gets or sets the target mesh
  37391. */
  37392. targetMesh: AbstractMesh;
  37393. /** Gets or sets the mesh used as pole */
  37394. poleTargetMesh: AbstractMesh;
  37395. /**
  37396. * Gets or sets the bone used as pole
  37397. */
  37398. poleTargetBone: Nullable<Bone>;
  37399. /**
  37400. * Gets or sets the target position
  37401. */
  37402. targetPosition: Vector3;
  37403. /**
  37404. * Gets or sets the pole target position
  37405. */
  37406. poleTargetPosition: Vector3;
  37407. /**
  37408. * Gets or sets the pole target local offset
  37409. */
  37410. poleTargetLocalOffset: Vector3;
  37411. /**
  37412. * Gets or sets the pole angle
  37413. */
  37414. poleAngle: number;
  37415. /**
  37416. * Gets or sets the mesh associated with the controller
  37417. */
  37418. mesh: AbstractMesh;
  37419. /**
  37420. * 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)
  37421. */
  37422. slerpAmount: number;
  37423. private _bone1Quat;
  37424. private _bone1Mat;
  37425. private _bone2Ang;
  37426. private _bone1;
  37427. private _bone2;
  37428. private _bone1Length;
  37429. private _bone2Length;
  37430. private _maxAngle;
  37431. private _maxReach;
  37432. private _rightHandedSystem;
  37433. private _bendAxis;
  37434. private _slerping;
  37435. private _adjustRoll;
  37436. /**
  37437. * Gets or sets maximum allowed angle
  37438. */
  37439. maxAngle: number;
  37440. /**
  37441. * Creates a new BoneIKController
  37442. * @param mesh defines the mesh to control
  37443. * @param bone defines the bone to control
  37444. * @param options defines options to set up the controller
  37445. */
  37446. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37447. targetMesh?: AbstractMesh;
  37448. poleTargetMesh?: AbstractMesh;
  37449. poleTargetBone?: Bone;
  37450. poleTargetLocalOffset?: Vector3;
  37451. poleAngle?: number;
  37452. bendAxis?: Vector3;
  37453. maxAngle?: number;
  37454. slerpAmount?: number;
  37455. });
  37456. private _setMaxAngle;
  37457. /**
  37458. * Force the controller to update the bones
  37459. */
  37460. update(): void;
  37461. }
  37462. }
  37463. declare module "babylonjs/Bones/boneLookController" {
  37464. import { Vector3, Space } from "babylonjs/Maths/math";
  37465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37466. import { Bone } from "babylonjs/Bones/bone";
  37467. /**
  37468. * Class used to make a bone look toward a point in space
  37469. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37470. */
  37471. export class BoneLookController {
  37472. private static _tmpVecs;
  37473. private static _tmpQuat;
  37474. private static _tmpMats;
  37475. /**
  37476. * The target Vector3 that the bone will look at
  37477. */
  37478. target: Vector3;
  37479. /**
  37480. * The mesh that the bone is attached to
  37481. */
  37482. mesh: AbstractMesh;
  37483. /**
  37484. * The bone that will be looking to the target
  37485. */
  37486. bone: Bone;
  37487. /**
  37488. * The up axis of the coordinate system that is used when the bone is rotated
  37489. */
  37490. upAxis: Vector3;
  37491. /**
  37492. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37493. */
  37494. upAxisSpace: Space;
  37495. /**
  37496. * Used to make an adjustment to the yaw of the bone
  37497. */
  37498. adjustYaw: number;
  37499. /**
  37500. * Used to make an adjustment to the pitch of the bone
  37501. */
  37502. adjustPitch: number;
  37503. /**
  37504. * Used to make an adjustment to the roll of the bone
  37505. */
  37506. adjustRoll: number;
  37507. /**
  37508. * 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)
  37509. */
  37510. slerpAmount: number;
  37511. private _minYaw;
  37512. private _maxYaw;
  37513. private _minPitch;
  37514. private _maxPitch;
  37515. private _minYawSin;
  37516. private _minYawCos;
  37517. private _maxYawSin;
  37518. private _maxYawCos;
  37519. private _midYawConstraint;
  37520. private _minPitchTan;
  37521. private _maxPitchTan;
  37522. private _boneQuat;
  37523. private _slerping;
  37524. private _transformYawPitch;
  37525. private _transformYawPitchInv;
  37526. private _firstFrameSkipped;
  37527. private _yawRange;
  37528. private _fowardAxis;
  37529. /**
  37530. * Gets or sets the minimum yaw angle that the bone can look to
  37531. */
  37532. minYaw: number;
  37533. /**
  37534. * Gets or sets the maximum yaw angle that the bone can look to
  37535. */
  37536. maxYaw: number;
  37537. /**
  37538. * Gets or sets the minimum pitch angle that the bone can look to
  37539. */
  37540. minPitch: number;
  37541. /**
  37542. * Gets or sets the maximum pitch angle that the bone can look to
  37543. */
  37544. maxPitch: number;
  37545. /**
  37546. * Create a BoneLookController
  37547. * @param mesh the mesh that the bone belongs to
  37548. * @param bone the bone that will be looking to the target
  37549. * @param target the target Vector3 to look at
  37550. * @param settings optional settings:
  37551. * * maxYaw: the maximum angle the bone will yaw to
  37552. * * minYaw: the minimum angle the bone will yaw to
  37553. * * maxPitch: the maximum angle the bone will pitch to
  37554. * * minPitch: the minimum angle the bone will yaw to
  37555. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37556. * * upAxis: the up axis of the coordinate system
  37557. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37558. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37559. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37560. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37561. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37562. * * adjustRoll: used to make an adjustment to the roll of the bone
  37563. **/
  37564. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37565. maxYaw?: number;
  37566. minYaw?: number;
  37567. maxPitch?: number;
  37568. minPitch?: number;
  37569. slerpAmount?: number;
  37570. upAxis?: Vector3;
  37571. upAxisSpace?: Space;
  37572. yawAxis?: Vector3;
  37573. pitchAxis?: Vector3;
  37574. adjustYaw?: number;
  37575. adjustPitch?: number;
  37576. adjustRoll?: number;
  37577. });
  37578. /**
  37579. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37580. */
  37581. update(): void;
  37582. private _getAngleDiff;
  37583. private _getAngleBetween;
  37584. private _isAngleBetween;
  37585. }
  37586. }
  37587. declare module "babylonjs/Bones/index" {
  37588. export * from "babylonjs/Bones/bone";
  37589. export * from "babylonjs/Bones/boneIKController";
  37590. export * from "babylonjs/Bones/boneLookController";
  37591. export * from "babylonjs/Bones/skeleton";
  37592. }
  37593. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37594. import { Nullable } from "babylonjs/types";
  37595. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37596. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37597. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37598. /**
  37599. * Manage the gamepad inputs to control an arc rotate camera.
  37600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37601. */
  37602. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37603. /**
  37604. * Defines the camera the input is attached to.
  37605. */
  37606. camera: ArcRotateCamera;
  37607. /**
  37608. * Defines the gamepad the input is gathering event from.
  37609. */
  37610. gamepad: Nullable<Gamepad>;
  37611. /**
  37612. * Defines the gamepad rotation sensiblity.
  37613. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37614. */
  37615. gamepadRotationSensibility: number;
  37616. /**
  37617. * Defines the gamepad move sensiblity.
  37618. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37619. */
  37620. gamepadMoveSensibility: number;
  37621. private _onGamepadConnectedObserver;
  37622. private _onGamepadDisconnectedObserver;
  37623. /**
  37624. * Attach the input controls to a specific dom element to get the input from.
  37625. * @param element Defines the element the controls should be listened from
  37626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37627. */
  37628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37629. /**
  37630. * Detach the current controls from the specified dom element.
  37631. * @param element Defines the element to stop listening the inputs from
  37632. */
  37633. detachControl(element: Nullable<HTMLElement>): void;
  37634. /**
  37635. * Update the current camera state depending on the inputs that have been used this frame.
  37636. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37637. */
  37638. checkInputs(): void;
  37639. /**
  37640. * Gets the class name of the current intput.
  37641. * @returns the class name
  37642. */
  37643. getClassName(): string;
  37644. /**
  37645. * Get the friendly name associated with the input class.
  37646. * @returns the input friendly name
  37647. */
  37648. getSimpleName(): string;
  37649. }
  37650. }
  37651. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37652. import { Nullable } from "babylonjs/types";
  37653. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37654. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37655. /**
  37656. * Listen to mouse events to control the camera.
  37657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37658. */
  37659. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37660. /**
  37661. * Defines the camera the input is attached to.
  37662. */
  37663. camera: FlyCamera;
  37664. /**
  37665. * Defines if touch is enabled. (Default is true.)
  37666. */
  37667. touchEnabled: boolean;
  37668. /**
  37669. * Defines the buttons associated with the input to handle camera rotation.
  37670. */
  37671. buttons: number[];
  37672. /**
  37673. * Assign buttons for Yaw control.
  37674. */
  37675. buttonsYaw: number[];
  37676. /**
  37677. * Assign buttons for Pitch control.
  37678. */
  37679. buttonsPitch: number[];
  37680. /**
  37681. * Assign buttons for Roll control.
  37682. */
  37683. buttonsRoll: number[];
  37684. /**
  37685. * Detect if any button is being pressed while mouse is moved.
  37686. * -1 = Mouse locked.
  37687. * 0 = Left button.
  37688. * 1 = Middle Button.
  37689. * 2 = Right Button.
  37690. */
  37691. activeButton: number;
  37692. /**
  37693. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37694. * Higher values reduce its sensitivity.
  37695. */
  37696. angularSensibility: number;
  37697. private _mousemoveCallback;
  37698. private _observer;
  37699. private _rollObserver;
  37700. private previousPosition;
  37701. private noPreventDefault;
  37702. private element;
  37703. /**
  37704. * Listen to mouse events to control the camera.
  37705. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37707. */
  37708. constructor(touchEnabled?: boolean);
  37709. /**
  37710. * Attach the mouse control to the HTML DOM element.
  37711. * @param element Defines the element that listens to the input events.
  37712. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37713. */
  37714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37715. /**
  37716. * Detach the current controls from the specified dom element.
  37717. * @param element Defines the element to stop listening the inputs from
  37718. */
  37719. detachControl(element: Nullable<HTMLElement>): void;
  37720. /**
  37721. * Gets the class name of the current input.
  37722. * @returns the class name.
  37723. */
  37724. getClassName(): string;
  37725. /**
  37726. * Get the friendly name associated with the input class.
  37727. * @returns the input's friendly name.
  37728. */
  37729. getSimpleName(): string;
  37730. private _pointerInput;
  37731. private _onMouseMove;
  37732. /**
  37733. * Rotate camera by mouse offset.
  37734. */
  37735. private rotateCamera;
  37736. }
  37737. }
  37738. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37739. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37740. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37741. /**
  37742. * Default Inputs manager for the FlyCamera.
  37743. * It groups all the default supported inputs for ease of use.
  37744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37745. */
  37746. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37747. /**
  37748. * Instantiates a new FlyCameraInputsManager.
  37749. * @param camera Defines the camera the inputs belong to.
  37750. */
  37751. constructor(camera: FlyCamera);
  37752. /**
  37753. * Add keyboard input support to the input manager.
  37754. * @returns the new FlyCameraKeyboardMoveInput().
  37755. */
  37756. addKeyboard(): FlyCameraInputsManager;
  37757. /**
  37758. * Add mouse input support to the input manager.
  37759. * @param touchEnabled Enable touch screen support.
  37760. * @returns the new FlyCameraMouseInput().
  37761. */
  37762. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37763. }
  37764. }
  37765. declare module "babylonjs/Cameras/flyCamera" {
  37766. import { Scene } from "babylonjs/scene";
  37767. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37769. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37770. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37771. /**
  37772. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37773. * such as in a 3D Space Shooter or a Flight Simulator.
  37774. */
  37775. export class FlyCamera extends TargetCamera {
  37776. /**
  37777. * Define the collision ellipsoid of the camera.
  37778. * This is helpful for simulating a camera body, like a player's body.
  37779. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37780. */
  37781. ellipsoid: Vector3;
  37782. /**
  37783. * Define an offset for the position of the ellipsoid around the camera.
  37784. * This can be helpful if the camera is attached away from the player's body center,
  37785. * such as at its head.
  37786. */
  37787. ellipsoidOffset: Vector3;
  37788. /**
  37789. * Enable or disable collisions of the camera with the rest of the scene objects.
  37790. */
  37791. checkCollisions: boolean;
  37792. /**
  37793. * Enable or disable gravity on the camera.
  37794. */
  37795. applyGravity: boolean;
  37796. /**
  37797. * Define the current direction the camera is moving to.
  37798. */
  37799. cameraDirection: Vector3;
  37800. /**
  37801. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37802. * This overrides and empties cameraRotation.
  37803. */
  37804. rotationQuaternion: Quaternion;
  37805. /**
  37806. * Track Roll to maintain the wanted Rolling when looking around.
  37807. */
  37808. _trackRoll: number;
  37809. /**
  37810. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37811. */
  37812. rollCorrect: number;
  37813. /**
  37814. * Mimic a banked turn, Rolling the camera when Yawing.
  37815. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37816. */
  37817. bankedTurn: boolean;
  37818. /**
  37819. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37820. */
  37821. bankedTurnLimit: number;
  37822. /**
  37823. * Value of 0 disables the banked Roll.
  37824. * Value of 1 is equal to the Yaw angle in radians.
  37825. */
  37826. bankedTurnMultiplier: number;
  37827. /**
  37828. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37829. */
  37830. inputs: FlyCameraInputsManager;
  37831. /**
  37832. * Gets the input sensibility for mouse input.
  37833. * Higher values reduce sensitivity.
  37834. */
  37835. /**
  37836. * Sets the input sensibility for a mouse input.
  37837. * Higher values reduce sensitivity.
  37838. */
  37839. angularSensibility: number;
  37840. /**
  37841. * Get the keys for camera movement forward.
  37842. */
  37843. /**
  37844. * Set the keys for camera movement forward.
  37845. */
  37846. keysForward: number[];
  37847. /**
  37848. * Get the keys for camera movement backward.
  37849. */
  37850. keysBackward: number[];
  37851. /**
  37852. * Get the keys for camera movement up.
  37853. */
  37854. /**
  37855. * Set the keys for camera movement up.
  37856. */
  37857. keysUp: number[];
  37858. /**
  37859. * Get the keys for camera movement down.
  37860. */
  37861. /**
  37862. * Set the keys for camera movement down.
  37863. */
  37864. keysDown: number[];
  37865. /**
  37866. * Get the keys for camera movement left.
  37867. */
  37868. /**
  37869. * Set the keys for camera movement left.
  37870. */
  37871. keysLeft: number[];
  37872. /**
  37873. * Set the keys for camera movement right.
  37874. */
  37875. /**
  37876. * Set the keys for camera movement right.
  37877. */
  37878. keysRight: number[];
  37879. /**
  37880. * Event raised when the camera collides with a mesh in the scene.
  37881. */
  37882. onCollide: (collidedMesh: AbstractMesh) => void;
  37883. private _collider;
  37884. private _needMoveForGravity;
  37885. private _oldPosition;
  37886. private _diffPosition;
  37887. private _newPosition;
  37888. /** @hidden */
  37889. _localDirection: Vector3;
  37890. /** @hidden */
  37891. _transformedDirection: Vector3;
  37892. /**
  37893. * Instantiates a FlyCamera.
  37894. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37895. * such as in a 3D Space Shooter or a Flight Simulator.
  37896. * @param name Define the name of the camera in the scene.
  37897. * @param position Define the starting position of the camera in the scene.
  37898. * @param scene Define the scene the camera belongs to.
  37899. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37900. */
  37901. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37902. /**
  37903. * Attach a control to the HTML DOM element.
  37904. * @param element Defines the element that listens to the input events.
  37905. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37906. */
  37907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37908. /**
  37909. * Detach a control from the HTML DOM element.
  37910. * The camera will stop reacting to that input.
  37911. * @param element Defines the element that listens to the input events.
  37912. */
  37913. detachControl(element: HTMLElement): void;
  37914. private _collisionMask;
  37915. /**
  37916. * Get the mask that the camera ignores in collision events.
  37917. */
  37918. /**
  37919. * Set the mask that the camera ignores in collision events.
  37920. */
  37921. collisionMask: number;
  37922. /** @hidden */
  37923. _collideWithWorld(displacement: Vector3): void;
  37924. /** @hidden */
  37925. private _onCollisionPositionChange;
  37926. /** @hidden */
  37927. _checkInputs(): void;
  37928. /** @hidden */
  37929. _decideIfNeedsToMove(): boolean;
  37930. /** @hidden */
  37931. _updatePosition(): void;
  37932. /**
  37933. * Restore the Roll to its target value at the rate specified.
  37934. * @param rate - Higher means slower restoring.
  37935. * @hidden
  37936. */
  37937. restoreRoll(rate: number): void;
  37938. /**
  37939. * Destroy the camera and release the current resources held by it.
  37940. */
  37941. dispose(): void;
  37942. /**
  37943. * Get the current object class name.
  37944. * @returns the class name.
  37945. */
  37946. getClassName(): string;
  37947. }
  37948. }
  37949. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37950. import { Nullable } from "babylonjs/types";
  37951. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37952. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37953. /**
  37954. * Listen to keyboard events to control the camera.
  37955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37956. */
  37957. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37958. /**
  37959. * Defines the camera the input is attached to.
  37960. */
  37961. camera: FlyCamera;
  37962. /**
  37963. * The list of keyboard keys used to control the forward move of the camera.
  37964. */
  37965. keysForward: number[];
  37966. /**
  37967. * The list of keyboard keys used to control the backward move of the camera.
  37968. */
  37969. keysBackward: number[];
  37970. /**
  37971. * The list of keyboard keys used to control the forward move of the camera.
  37972. */
  37973. keysUp: number[];
  37974. /**
  37975. * The list of keyboard keys used to control the backward move of the camera.
  37976. */
  37977. keysDown: number[];
  37978. /**
  37979. * The list of keyboard keys used to control the right strafe move of the camera.
  37980. */
  37981. keysRight: number[];
  37982. /**
  37983. * The list of keyboard keys used to control the left strafe move of the camera.
  37984. */
  37985. keysLeft: number[];
  37986. private _keys;
  37987. private _onCanvasBlurObserver;
  37988. private _onKeyboardObserver;
  37989. private _engine;
  37990. private _scene;
  37991. /**
  37992. * Attach the input controls to a specific dom element to get the input from.
  37993. * @param element Defines the element the controls should be listened from
  37994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37995. */
  37996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37997. /**
  37998. * Detach the current controls from the specified dom element.
  37999. * @param element Defines the element to stop listening the inputs from
  38000. */
  38001. detachControl(element: Nullable<HTMLElement>): void;
  38002. /**
  38003. * Gets the class name of the current intput.
  38004. * @returns the class name
  38005. */
  38006. getClassName(): string;
  38007. /** @hidden */
  38008. _onLostFocus(e: FocusEvent): void;
  38009. /**
  38010. * Get the friendly name associated with the input class.
  38011. * @returns the input friendly name
  38012. */
  38013. getSimpleName(): string;
  38014. /**
  38015. * Update the current camera state depending on the inputs that have been used this frame.
  38016. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38017. */
  38018. checkInputs(): void;
  38019. }
  38020. }
  38021. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38022. import { Nullable } from "babylonjs/types";
  38023. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38024. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38025. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38026. /**
  38027. * Manage the gamepad inputs to control a free camera.
  38028. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38029. */
  38030. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38031. /**
  38032. * Define the camera the input is attached to.
  38033. */
  38034. camera: FreeCamera;
  38035. /**
  38036. * Define the Gamepad controlling the input
  38037. */
  38038. gamepad: Nullable<Gamepad>;
  38039. /**
  38040. * Defines the gamepad rotation sensiblity.
  38041. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38042. */
  38043. gamepadAngularSensibility: number;
  38044. /**
  38045. * Defines the gamepad move sensiblity.
  38046. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38047. */
  38048. gamepadMoveSensibility: number;
  38049. private _onGamepadConnectedObserver;
  38050. private _onGamepadDisconnectedObserver;
  38051. private _cameraTransform;
  38052. private _deltaTransform;
  38053. private _vector3;
  38054. private _vector2;
  38055. /**
  38056. * Attach the input controls to a specific dom element to get the input from.
  38057. * @param element Defines the element the controls should be listened from
  38058. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38059. */
  38060. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38061. /**
  38062. * Detach the current controls from the specified dom element.
  38063. * @param element Defines the element to stop listening the inputs from
  38064. */
  38065. detachControl(element: Nullable<HTMLElement>): void;
  38066. /**
  38067. * Update the current camera state depending on the inputs that have been used this frame.
  38068. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38069. */
  38070. checkInputs(): void;
  38071. /**
  38072. * Gets the class name of the current intput.
  38073. * @returns the class name
  38074. */
  38075. getClassName(): string;
  38076. /**
  38077. * Get the friendly name associated with the input class.
  38078. * @returns the input friendly name
  38079. */
  38080. getSimpleName(): string;
  38081. }
  38082. }
  38083. declare module "babylonjs/Cameras/Inputs/index" {
  38084. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38085. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38086. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38087. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38088. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38089. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38090. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38091. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38092. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38093. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38094. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38095. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38096. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38097. }
  38098. declare module "babylonjs/Cameras/touchCamera" {
  38099. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38100. import { Scene } from "babylonjs/scene";
  38101. import { Vector3 } from "babylonjs/Maths/math";
  38102. /**
  38103. * This represents a FPS type of camera controlled by touch.
  38104. * This is like a universal camera minus the Gamepad controls.
  38105. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38106. */
  38107. export class TouchCamera extends FreeCamera {
  38108. /**
  38109. * Defines the touch sensibility for rotation.
  38110. * The higher the faster.
  38111. */
  38112. touchAngularSensibility: number;
  38113. /**
  38114. * Defines the touch sensibility for move.
  38115. * The higher the faster.
  38116. */
  38117. touchMoveSensibility: number;
  38118. /**
  38119. * Instantiates a new touch camera.
  38120. * This represents a FPS type of camera controlled by touch.
  38121. * This is like a universal camera minus the Gamepad controls.
  38122. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38123. * @param name Define the name of the camera in the scene
  38124. * @param position Define the start position of the camera in the scene
  38125. * @param scene Define the scene the camera belongs to
  38126. */
  38127. constructor(name: string, position: Vector3, scene: Scene);
  38128. /**
  38129. * Gets the current object class name.
  38130. * @return the class name
  38131. */
  38132. getClassName(): string;
  38133. /** @hidden */
  38134. _setupInputs(): void;
  38135. }
  38136. }
  38137. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38138. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38139. import { Scene } from "babylonjs/scene";
  38140. import { Vector3, Axis } from "babylonjs/Maths/math";
  38141. /**
  38142. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38143. * being tilted forward or back and left or right.
  38144. */
  38145. export class DeviceOrientationCamera extends FreeCamera {
  38146. private _initialQuaternion;
  38147. private _quaternionCache;
  38148. /**
  38149. * Creates a new device orientation camera
  38150. * @param name The name of the camera
  38151. * @param position The start position camera
  38152. * @param scene The scene the camera belongs to
  38153. */
  38154. constructor(name: string, position: Vector3, scene: Scene);
  38155. /**
  38156. * Gets the current instance class name ("DeviceOrientationCamera").
  38157. * This helps avoiding instanceof at run time.
  38158. * @returns the class name
  38159. */
  38160. getClassName(): string;
  38161. /**
  38162. * @hidden
  38163. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38164. */
  38165. _checkInputs(): void;
  38166. /**
  38167. * Reset the camera to its default orientation on the specified axis only.
  38168. * @param axis The axis to reset
  38169. */
  38170. resetToCurrentRotation(axis?: Axis): void;
  38171. }
  38172. }
  38173. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38174. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38175. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38176. import { Nullable } from "babylonjs/types";
  38177. /**
  38178. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38179. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38180. */
  38181. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38182. /**
  38183. * Defines the camera the input is attached to.
  38184. */
  38185. camera: FollowCamera;
  38186. /**
  38187. * Defines the list of key codes associated with the up action (increase heightOffset)
  38188. */
  38189. keysUp: number[];
  38190. /**
  38191. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38192. */
  38193. keysDown: number[];
  38194. /**
  38195. * Defines the list of key codes associated with the left action (increase rotation)
  38196. */
  38197. keysLeft: number[];
  38198. /**
  38199. * Defines the list of key codes associated with the right action (decrease rotation)
  38200. */
  38201. keysRight: number[];
  38202. /**
  38203. * Defines the rate of change of heightOffset.
  38204. */
  38205. heightSensibility: number;
  38206. /**
  38207. * Defines the rate of change of rotationOffset.
  38208. */
  38209. rotationSensibility: number;
  38210. /**
  38211. * Defines the rate of change of radius.
  38212. */
  38213. radiusSensibility: number;
  38214. /**
  38215. * Defines the minimum heightOffset value.
  38216. */
  38217. minHeightOffset: number;
  38218. /**
  38219. * Defines the minimum radius value.
  38220. */
  38221. minRadius: number;
  38222. private _keys;
  38223. private _altPressed;
  38224. private _onCanvasBlurObserver;
  38225. private _onKeyboardObserver;
  38226. private _engine;
  38227. private _scene;
  38228. /**
  38229. * Attach the input controls to a specific dom element to get the input from.
  38230. * @param element Defines the element the controls should be listened from
  38231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38232. */
  38233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38234. /**
  38235. * Detach the current controls from the specified dom element.
  38236. * @param element Defines the element to stop listening the inputs from
  38237. */
  38238. detachControl(element: Nullable<HTMLElement>): void;
  38239. /**
  38240. * Update the current camera state depending on the inputs that have been used this frame.
  38241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38242. */
  38243. checkInputs(): void;
  38244. /**
  38245. * Gets the class name of the current intput.
  38246. * @returns the class name
  38247. */
  38248. getClassName(): string;
  38249. /**
  38250. * Get the friendly name associated with the input class.
  38251. * @returns the input friendly name
  38252. */
  38253. getSimpleName(): string;
  38254. }
  38255. }
  38256. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38257. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38258. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38259. /**
  38260. * Default Inputs manager for the FollowCamera.
  38261. * It groups all the default supported inputs for ease of use.
  38262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38263. */
  38264. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38265. /**
  38266. * Instantiates a new FollowCameraInputsManager.
  38267. * @param camera Defines the camera the inputs belong to
  38268. */
  38269. constructor(camera: FollowCamera);
  38270. /**
  38271. * Add keyboard input support to the input manager.
  38272. * @returns the current input manager
  38273. */
  38274. addKeyboard(): FollowCameraInputsManager;
  38275. /**
  38276. * Add mouse wheel input support to the input manager.
  38277. * @returns the current input manager
  38278. */
  38279. addMouseWheel(): FollowCameraInputsManager;
  38280. /**
  38281. * Add pointers input support to the input manager.
  38282. * @returns the current input manager
  38283. */
  38284. addPointers(): FollowCameraInputsManager;
  38285. /**
  38286. * Add orientation input support to the input manager.
  38287. * @returns the current input manager
  38288. */
  38289. addVRDeviceOrientation(): FollowCameraInputsManager;
  38290. }
  38291. }
  38292. declare module "babylonjs/Cameras/followCamera" {
  38293. import { Nullable } from "babylonjs/types";
  38294. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38295. import { Scene } from "babylonjs/scene";
  38296. import { Vector3 } from "babylonjs/Maths/math";
  38297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38298. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38299. /**
  38300. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38301. * an arc rotate version arcFollowCamera are available.
  38302. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38303. */
  38304. export class FollowCamera extends TargetCamera {
  38305. /**
  38306. * Distance the follow camera should follow an object at
  38307. */
  38308. radius: number;
  38309. /**
  38310. * Define a rotation offset between the camera and the object it follows
  38311. */
  38312. rotationOffset: number;
  38313. /**
  38314. * Define a height offset between the camera and the object it follows.
  38315. * It can help following an object from the top (like a car chaing a plane)
  38316. */
  38317. heightOffset: number;
  38318. /**
  38319. * Define how fast the camera can accelerate to follow it s target.
  38320. */
  38321. cameraAcceleration: number;
  38322. /**
  38323. * Define the speed limit of the camera following an object.
  38324. */
  38325. maxCameraSpeed: number;
  38326. /**
  38327. * Define the target of the camera.
  38328. */
  38329. lockedTarget: Nullable<AbstractMesh>;
  38330. /**
  38331. * Defines the input associated with the camera.
  38332. */
  38333. inputs: FollowCameraInputsManager;
  38334. /**
  38335. * Instantiates the follow camera.
  38336. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38337. * @param name Define the name of the camera in the scene
  38338. * @param position Define the position of the camera
  38339. * @param scene Define the scene the camera belong to
  38340. * @param lockedTarget Define the target of the camera
  38341. */
  38342. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38343. private _follow;
  38344. /**
  38345. * Attached controls to the current camera.
  38346. * @param element Defines the element the controls should be listened from
  38347. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38348. */
  38349. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38350. /**
  38351. * Detach the current controls from the camera.
  38352. * The camera will stop reacting to inputs.
  38353. * @param element Defines the element to stop listening the inputs from
  38354. */
  38355. detachControl(element: HTMLElement): void;
  38356. /** @hidden */
  38357. _checkInputs(): void;
  38358. /**
  38359. * Gets the camera class name.
  38360. * @returns the class name
  38361. */
  38362. getClassName(): string;
  38363. }
  38364. /**
  38365. * Arc Rotate version of the follow camera.
  38366. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38367. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38368. */
  38369. export class ArcFollowCamera extends TargetCamera {
  38370. /** The longitudinal angle of the camera */
  38371. alpha: number;
  38372. /** The latitudinal angle of the camera */
  38373. beta: number;
  38374. /** The radius of the camera from its target */
  38375. radius: number;
  38376. /** Define the camera target (the messh it should follow) */
  38377. target: Nullable<AbstractMesh>;
  38378. private _cartesianCoordinates;
  38379. /**
  38380. * Instantiates a new ArcFollowCamera
  38381. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38382. * @param name Define the name of the camera
  38383. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38384. * @param beta Define the rotation angle of the camera around the elevation axis
  38385. * @param radius Define the radius of the camera from its target point
  38386. * @param target Define the target of the camera
  38387. * @param scene Define the scene the camera belongs to
  38388. */
  38389. constructor(name: string,
  38390. /** The longitudinal angle of the camera */
  38391. alpha: number,
  38392. /** The latitudinal angle of the camera */
  38393. beta: number,
  38394. /** The radius of the camera from its target */
  38395. radius: number,
  38396. /** Define the camera target (the messh it should follow) */
  38397. target: Nullable<AbstractMesh>, scene: Scene);
  38398. private _follow;
  38399. /** @hidden */
  38400. _checkInputs(): void;
  38401. /**
  38402. * Returns the class name of the object.
  38403. * It is mostly used internally for serialization purposes.
  38404. */
  38405. getClassName(): string;
  38406. }
  38407. }
  38408. declare module "babylonjs/Cameras/universalCamera" {
  38409. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38410. import { Scene } from "babylonjs/scene";
  38411. import { Vector3 } from "babylonjs/Maths/math";
  38412. /**
  38413. * 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,
  38414. * which still works and will still be found in many Playgrounds.
  38415. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38416. */
  38417. export class UniversalCamera extends TouchCamera {
  38418. /**
  38419. * Defines the gamepad rotation sensiblity.
  38420. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38421. */
  38422. gamepadAngularSensibility: number;
  38423. /**
  38424. * Defines the gamepad move sensiblity.
  38425. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38426. */
  38427. gamepadMoveSensibility: number;
  38428. /**
  38429. * 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,
  38430. * which still works and will still be found in many Playgrounds.
  38431. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38432. * @param name Define the name of the camera in the scene
  38433. * @param position Define the start position of the camera in the scene
  38434. * @param scene Define the scene the camera belongs to
  38435. */
  38436. constructor(name: string, position: Vector3, scene: Scene);
  38437. /**
  38438. * Gets the current object class name.
  38439. * @return the class name
  38440. */
  38441. getClassName(): string;
  38442. }
  38443. }
  38444. declare module "babylonjs/Cameras/gamepadCamera" {
  38445. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38446. import { Scene } from "babylonjs/scene";
  38447. import { Vector3 } from "babylonjs/Maths/math";
  38448. /**
  38449. * This represents a FPS type of camera. This is only here for back compat purpose.
  38450. * Please use the UniversalCamera instead as both are identical.
  38451. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38452. */
  38453. export class GamepadCamera extends UniversalCamera {
  38454. /**
  38455. * Instantiates a new Gamepad Camera
  38456. * This represents a FPS type of camera. This is only here for back compat purpose.
  38457. * Please use the UniversalCamera instead as both are identical.
  38458. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38459. * @param name Define the name of the camera in the scene
  38460. * @param position Define the start position of the camera in the scene
  38461. * @param scene Define the scene the camera belongs to
  38462. */
  38463. constructor(name: string, position: Vector3, scene: Scene);
  38464. /**
  38465. * Gets the current object class name.
  38466. * @return the class name
  38467. */
  38468. getClassName(): string;
  38469. }
  38470. }
  38471. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38472. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38473. import { Scene } from "babylonjs/scene";
  38474. import { Vector3 } from "babylonjs/Maths/math";
  38475. /**
  38476. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38477. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38478. */
  38479. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38480. /**
  38481. * Creates a new AnaglyphArcRotateCamera
  38482. * @param name defines camera name
  38483. * @param alpha defines alpha angle (in radians)
  38484. * @param beta defines beta angle (in radians)
  38485. * @param radius defines radius
  38486. * @param target defines camera target
  38487. * @param interaxialDistance defines distance between each color axis
  38488. * @param scene defines the hosting scene
  38489. */
  38490. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38491. /**
  38492. * Gets camera class name
  38493. * @returns AnaglyphArcRotateCamera
  38494. */
  38495. getClassName(): string;
  38496. }
  38497. }
  38498. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38499. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38500. import { Scene } from "babylonjs/scene";
  38501. import { Vector3 } from "babylonjs/Maths/math";
  38502. /**
  38503. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38504. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38505. */
  38506. export class AnaglyphFreeCamera extends FreeCamera {
  38507. /**
  38508. * Creates a new AnaglyphFreeCamera
  38509. * @param name defines camera name
  38510. * @param position defines initial position
  38511. * @param interaxialDistance defines distance between each color axis
  38512. * @param scene defines the hosting scene
  38513. */
  38514. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38515. /**
  38516. * Gets camera class name
  38517. * @returns AnaglyphFreeCamera
  38518. */
  38519. getClassName(): string;
  38520. }
  38521. }
  38522. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38523. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38524. import { Scene } from "babylonjs/scene";
  38525. import { Vector3 } from "babylonjs/Maths/math";
  38526. /**
  38527. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38528. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38529. */
  38530. export class AnaglyphGamepadCamera extends GamepadCamera {
  38531. /**
  38532. * Creates a new AnaglyphGamepadCamera
  38533. * @param name defines camera name
  38534. * @param position defines initial position
  38535. * @param interaxialDistance defines distance between each color axis
  38536. * @param scene defines the hosting scene
  38537. */
  38538. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38539. /**
  38540. * Gets camera class name
  38541. * @returns AnaglyphGamepadCamera
  38542. */
  38543. getClassName(): string;
  38544. }
  38545. }
  38546. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38547. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38548. import { Scene } from "babylonjs/scene";
  38549. import { Vector3 } from "babylonjs/Maths/math";
  38550. /**
  38551. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38552. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38553. */
  38554. export class AnaglyphUniversalCamera extends UniversalCamera {
  38555. /**
  38556. * Creates a new AnaglyphUniversalCamera
  38557. * @param name defines camera name
  38558. * @param position defines initial position
  38559. * @param interaxialDistance defines distance between each color axis
  38560. * @param scene defines the hosting scene
  38561. */
  38562. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38563. /**
  38564. * Gets camera class name
  38565. * @returns AnaglyphUniversalCamera
  38566. */
  38567. getClassName(): string;
  38568. }
  38569. }
  38570. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38571. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38572. import { Scene } from "babylonjs/scene";
  38573. import { Vector3 } from "babylonjs/Maths/math";
  38574. /**
  38575. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38576. * @see http://doc.babylonjs.com/features/cameras
  38577. */
  38578. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38579. /**
  38580. * Creates a new StereoscopicArcRotateCamera
  38581. * @param name defines camera name
  38582. * @param alpha defines alpha angle (in radians)
  38583. * @param beta defines beta angle (in radians)
  38584. * @param radius defines radius
  38585. * @param target defines camera target
  38586. * @param interaxialDistance defines distance between each color axis
  38587. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38588. * @param scene defines the hosting scene
  38589. */
  38590. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38591. /**
  38592. * Gets camera class name
  38593. * @returns StereoscopicArcRotateCamera
  38594. */
  38595. getClassName(): string;
  38596. }
  38597. }
  38598. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38599. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38600. import { Scene } from "babylonjs/scene";
  38601. import { Vector3 } from "babylonjs/Maths/math";
  38602. /**
  38603. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38604. * @see http://doc.babylonjs.com/features/cameras
  38605. */
  38606. export class StereoscopicFreeCamera extends FreeCamera {
  38607. /**
  38608. * Creates a new StereoscopicFreeCamera
  38609. * @param name defines camera name
  38610. * @param position defines initial position
  38611. * @param interaxialDistance defines distance between each color axis
  38612. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38613. * @param scene defines the hosting scene
  38614. */
  38615. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38616. /**
  38617. * Gets camera class name
  38618. * @returns StereoscopicFreeCamera
  38619. */
  38620. getClassName(): string;
  38621. }
  38622. }
  38623. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38624. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38625. import { Scene } from "babylonjs/scene";
  38626. import { Vector3 } from "babylonjs/Maths/math";
  38627. /**
  38628. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38629. * @see http://doc.babylonjs.com/features/cameras
  38630. */
  38631. export class StereoscopicGamepadCamera extends GamepadCamera {
  38632. /**
  38633. * Creates a new StereoscopicGamepadCamera
  38634. * @param name defines camera name
  38635. * @param position defines initial position
  38636. * @param interaxialDistance defines distance between each color axis
  38637. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38638. * @param scene defines the hosting scene
  38639. */
  38640. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38641. /**
  38642. * Gets camera class name
  38643. * @returns StereoscopicGamepadCamera
  38644. */
  38645. getClassName(): string;
  38646. }
  38647. }
  38648. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38649. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38650. import { Scene } from "babylonjs/scene";
  38651. import { Vector3 } from "babylonjs/Maths/math";
  38652. /**
  38653. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38654. * @see http://doc.babylonjs.com/features/cameras
  38655. */
  38656. export class StereoscopicUniversalCamera extends UniversalCamera {
  38657. /**
  38658. * Creates a new StereoscopicUniversalCamera
  38659. * @param name defines camera name
  38660. * @param position defines initial position
  38661. * @param interaxialDistance defines distance between each color axis
  38662. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38663. * @param scene defines the hosting scene
  38664. */
  38665. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38666. /**
  38667. * Gets camera class name
  38668. * @returns StereoscopicUniversalCamera
  38669. */
  38670. getClassName(): string;
  38671. }
  38672. }
  38673. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38674. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38675. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38676. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38677. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38678. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38679. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38680. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38681. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38682. }
  38683. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38684. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38685. import { Scene } from "babylonjs/scene";
  38686. import { Vector3 } from "babylonjs/Maths/math";
  38687. /**
  38688. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38689. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38690. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38691. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38692. */
  38693. export class VirtualJoysticksCamera extends FreeCamera {
  38694. /**
  38695. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38696. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38697. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38698. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38699. * @param name Define the name of the camera in the scene
  38700. * @param position Define the start position of the camera in the scene
  38701. * @param scene Define the scene the camera belongs to
  38702. */
  38703. constructor(name: string, position: Vector3, scene: Scene);
  38704. /**
  38705. * Gets the current object class name.
  38706. * @return the class name
  38707. */
  38708. getClassName(): string;
  38709. }
  38710. }
  38711. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38712. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38713. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38714. import { Scene } from "babylonjs/scene";
  38715. import { Vector3 } from "babylonjs/Maths/math";
  38716. /**
  38717. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38718. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38719. */
  38720. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38721. /**
  38722. * Creates a new VRDeviceOrientationArcRotateCamera
  38723. * @param name defines camera name
  38724. * @param alpha defines the camera rotation along the logitudinal axis
  38725. * @param beta defines the camera rotation along the latitudinal axis
  38726. * @param radius defines the camera distance from its target
  38727. * @param target defines the camera target
  38728. * @param scene defines the scene the camera belongs to
  38729. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38730. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38731. */
  38732. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38733. /**
  38734. * Gets camera class name
  38735. * @returns VRDeviceOrientationArcRotateCamera
  38736. */
  38737. getClassName(): string;
  38738. }
  38739. }
  38740. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38741. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38742. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38743. import { Scene } from "babylonjs/scene";
  38744. import { Vector3 } from "babylonjs/Maths/math";
  38745. /**
  38746. * Camera used to simulate VR rendering (based on FreeCamera)
  38747. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38748. */
  38749. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38750. /**
  38751. * Creates a new VRDeviceOrientationFreeCamera
  38752. * @param name defines camera name
  38753. * @param position defines the start position of the camera
  38754. * @param scene defines the scene the camera belongs to
  38755. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38756. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38757. */
  38758. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38759. /**
  38760. * Gets camera class name
  38761. * @returns VRDeviceOrientationFreeCamera
  38762. */
  38763. getClassName(): string;
  38764. }
  38765. }
  38766. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38767. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38768. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38769. import { Scene } from "babylonjs/scene";
  38770. import { Vector3 } from "babylonjs/Maths/math";
  38771. /**
  38772. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38773. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38774. */
  38775. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38776. /**
  38777. * Creates a new VRDeviceOrientationGamepadCamera
  38778. * @param name defines camera name
  38779. * @param position defines the start position of the camera
  38780. * @param scene defines the scene the camera belongs to
  38781. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38782. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38783. */
  38784. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38785. /**
  38786. * Gets camera class name
  38787. * @returns VRDeviceOrientationGamepadCamera
  38788. */
  38789. getClassName(): string;
  38790. }
  38791. }
  38792. declare module "babylonjs/Gamepads/xboxGamepad" {
  38793. import { Observable } from "babylonjs/Misc/observable";
  38794. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38795. /**
  38796. * Defines supported buttons for XBox360 compatible gamepads
  38797. */
  38798. export enum Xbox360Button {
  38799. /** A */
  38800. A = 0,
  38801. /** B */
  38802. B = 1,
  38803. /** X */
  38804. X = 2,
  38805. /** Y */
  38806. Y = 3,
  38807. /** Start */
  38808. Start = 4,
  38809. /** Back */
  38810. Back = 5,
  38811. /** Left button */
  38812. LB = 6,
  38813. /** Right button */
  38814. RB = 7,
  38815. /** Left stick */
  38816. LeftStick = 8,
  38817. /** Right stick */
  38818. RightStick = 9
  38819. }
  38820. /** Defines values for XBox360 DPad */
  38821. export enum Xbox360Dpad {
  38822. /** Up */
  38823. Up = 0,
  38824. /** Down */
  38825. Down = 1,
  38826. /** Left */
  38827. Left = 2,
  38828. /** Right */
  38829. Right = 3
  38830. }
  38831. /**
  38832. * Defines a XBox360 gamepad
  38833. */
  38834. export class Xbox360Pad extends Gamepad {
  38835. private _leftTrigger;
  38836. private _rightTrigger;
  38837. private _onlefttriggerchanged;
  38838. private _onrighttriggerchanged;
  38839. private _onbuttondown;
  38840. private _onbuttonup;
  38841. private _ondpaddown;
  38842. private _ondpadup;
  38843. /** Observable raised when a button is pressed */
  38844. onButtonDownObservable: Observable<Xbox360Button>;
  38845. /** Observable raised when a button is released */
  38846. onButtonUpObservable: Observable<Xbox360Button>;
  38847. /** Observable raised when a pad is pressed */
  38848. onPadDownObservable: Observable<Xbox360Dpad>;
  38849. /** Observable raised when a pad is released */
  38850. onPadUpObservable: Observable<Xbox360Dpad>;
  38851. private _buttonA;
  38852. private _buttonB;
  38853. private _buttonX;
  38854. private _buttonY;
  38855. private _buttonBack;
  38856. private _buttonStart;
  38857. private _buttonLB;
  38858. private _buttonRB;
  38859. private _buttonLeftStick;
  38860. private _buttonRightStick;
  38861. private _dPadUp;
  38862. private _dPadDown;
  38863. private _dPadLeft;
  38864. private _dPadRight;
  38865. private _isXboxOnePad;
  38866. /**
  38867. * Creates a new XBox360 gamepad object
  38868. * @param id defines the id of this gamepad
  38869. * @param index defines its index
  38870. * @param gamepad defines the internal HTML gamepad object
  38871. * @param xboxOne defines if it is a XBox One gamepad
  38872. */
  38873. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38874. /**
  38875. * Defines the callback to call when left trigger is pressed
  38876. * @param callback defines the callback to use
  38877. */
  38878. onlefttriggerchanged(callback: (value: number) => void): void;
  38879. /**
  38880. * Defines the callback to call when right trigger is pressed
  38881. * @param callback defines the callback to use
  38882. */
  38883. onrighttriggerchanged(callback: (value: number) => void): void;
  38884. /**
  38885. * Gets the left trigger value
  38886. */
  38887. /**
  38888. * Sets the left trigger value
  38889. */
  38890. leftTrigger: number;
  38891. /**
  38892. * Gets the right trigger value
  38893. */
  38894. /**
  38895. * Sets the right trigger value
  38896. */
  38897. rightTrigger: number;
  38898. /**
  38899. * Defines the callback to call when a button is pressed
  38900. * @param callback defines the callback to use
  38901. */
  38902. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38903. /**
  38904. * Defines the callback to call when a button is released
  38905. * @param callback defines the callback to use
  38906. */
  38907. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38908. /**
  38909. * Defines the callback to call when a pad is pressed
  38910. * @param callback defines the callback to use
  38911. */
  38912. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38913. /**
  38914. * Defines the callback to call when a pad is released
  38915. * @param callback defines the callback to use
  38916. */
  38917. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38918. private _setButtonValue;
  38919. private _setDPadValue;
  38920. /**
  38921. * Gets the value of the `A` button
  38922. */
  38923. /**
  38924. * Sets the value of the `A` button
  38925. */
  38926. buttonA: number;
  38927. /**
  38928. * Gets the value of the `B` button
  38929. */
  38930. /**
  38931. * Sets the value of the `B` button
  38932. */
  38933. buttonB: number;
  38934. /**
  38935. * Gets the value of the `X` button
  38936. */
  38937. /**
  38938. * Sets the value of the `X` button
  38939. */
  38940. buttonX: number;
  38941. /**
  38942. * Gets the value of the `Y` button
  38943. */
  38944. /**
  38945. * Sets the value of the `Y` button
  38946. */
  38947. buttonY: number;
  38948. /**
  38949. * Gets the value of the `Start` button
  38950. */
  38951. /**
  38952. * Sets the value of the `Start` button
  38953. */
  38954. buttonStart: number;
  38955. /**
  38956. * Gets the value of the `Back` button
  38957. */
  38958. /**
  38959. * Sets the value of the `Back` button
  38960. */
  38961. buttonBack: number;
  38962. /**
  38963. * Gets the value of the `Left` button
  38964. */
  38965. /**
  38966. * Sets the value of the `Left` button
  38967. */
  38968. buttonLB: number;
  38969. /**
  38970. * Gets the value of the `Right` button
  38971. */
  38972. /**
  38973. * Sets the value of the `Right` button
  38974. */
  38975. buttonRB: number;
  38976. /**
  38977. * Gets the value of the Left joystick
  38978. */
  38979. /**
  38980. * Sets the value of the Left joystick
  38981. */
  38982. buttonLeftStick: number;
  38983. /**
  38984. * Gets the value of the Right joystick
  38985. */
  38986. /**
  38987. * Sets the value of the Right joystick
  38988. */
  38989. buttonRightStick: number;
  38990. /**
  38991. * Gets the value of D-pad up
  38992. */
  38993. /**
  38994. * Sets the value of D-pad up
  38995. */
  38996. dPadUp: number;
  38997. /**
  38998. * Gets the value of D-pad down
  38999. */
  39000. /**
  39001. * Sets the value of D-pad down
  39002. */
  39003. dPadDown: number;
  39004. /**
  39005. * Gets the value of D-pad left
  39006. */
  39007. /**
  39008. * Sets the value of D-pad left
  39009. */
  39010. dPadLeft: number;
  39011. /**
  39012. * Gets the value of D-pad right
  39013. */
  39014. /**
  39015. * Sets the value of D-pad right
  39016. */
  39017. dPadRight: number;
  39018. /**
  39019. * Force the gamepad to synchronize with device values
  39020. */
  39021. update(): void;
  39022. /**
  39023. * Disposes the gamepad
  39024. */
  39025. dispose(): void;
  39026. }
  39027. }
  39028. declare module "babylonjs/Materials/pushMaterial" {
  39029. import { Nullable } from "babylonjs/types";
  39030. import { Scene } from "babylonjs/scene";
  39031. import { Matrix } from "babylonjs/Maths/math";
  39032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39033. import { Mesh } from "babylonjs/Meshes/mesh";
  39034. import { Material } from "babylonjs/Materials/material";
  39035. import { Effect } from "babylonjs/Materials/effect";
  39036. /**
  39037. * Base class of materials working in push mode in babylon JS
  39038. * @hidden
  39039. */
  39040. export class PushMaterial extends Material {
  39041. protected _activeEffect: Effect;
  39042. protected _normalMatrix: Matrix;
  39043. /**
  39044. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39045. * This means that the material can keep using a previous shader while a new one is being compiled.
  39046. * This is mostly used when shader parallel compilation is supported (true by default)
  39047. */
  39048. allowShaderHotSwapping: boolean;
  39049. constructor(name: string, scene: Scene);
  39050. getEffect(): Effect;
  39051. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39052. /**
  39053. * Binds the given world matrix to the active effect
  39054. *
  39055. * @param world the matrix to bind
  39056. */
  39057. bindOnlyWorldMatrix(world: Matrix): void;
  39058. /**
  39059. * Binds the given normal matrix to the active effect
  39060. *
  39061. * @param normalMatrix the matrix to bind
  39062. */
  39063. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39064. bind(world: Matrix, mesh?: Mesh): void;
  39065. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39066. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39067. }
  39068. }
  39069. declare module "babylonjs/Materials/materialFlags" {
  39070. /**
  39071. * This groups all the flags used to control the materials channel.
  39072. */
  39073. export class MaterialFlags {
  39074. private static _DiffuseTextureEnabled;
  39075. /**
  39076. * Are diffuse textures enabled in the application.
  39077. */
  39078. static DiffuseTextureEnabled: boolean;
  39079. private static _AmbientTextureEnabled;
  39080. /**
  39081. * Are ambient textures enabled in the application.
  39082. */
  39083. static AmbientTextureEnabled: boolean;
  39084. private static _OpacityTextureEnabled;
  39085. /**
  39086. * Are opacity textures enabled in the application.
  39087. */
  39088. static OpacityTextureEnabled: boolean;
  39089. private static _ReflectionTextureEnabled;
  39090. /**
  39091. * Are reflection textures enabled in the application.
  39092. */
  39093. static ReflectionTextureEnabled: boolean;
  39094. private static _EmissiveTextureEnabled;
  39095. /**
  39096. * Are emissive textures enabled in the application.
  39097. */
  39098. static EmissiveTextureEnabled: boolean;
  39099. private static _SpecularTextureEnabled;
  39100. /**
  39101. * Are specular textures enabled in the application.
  39102. */
  39103. static SpecularTextureEnabled: boolean;
  39104. private static _BumpTextureEnabled;
  39105. /**
  39106. * Are bump textures enabled in the application.
  39107. */
  39108. static BumpTextureEnabled: boolean;
  39109. private static _LightmapTextureEnabled;
  39110. /**
  39111. * Are lightmap textures enabled in the application.
  39112. */
  39113. static LightmapTextureEnabled: boolean;
  39114. private static _RefractionTextureEnabled;
  39115. /**
  39116. * Are refraction textures enabled in the application.
  39117. */
  39118. static RefractionTextureEnabled: boolean;
  39119. private static _ColorGradingTextureEnabled;
  39120. /**
  39121. * Are color grading textures enabled in the application.
  39122. */
  39123. static ColorGradingTextureEnabled: boolean;
  39124. private static _FresnelEnabled;
  39125. /**
  39126. * Are fresnels enabled in the application.
  39127. */
  39128. static FresnelEnabled: boolean;
  39129. }
  39130. }
  39131. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39132. /** @hidden */
  39133. export var defaultFragmentDeclaration: {
  39134. name: string;
  39135. shader: string;
  39136. };
  39137. }
  39138. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39139. /** @hidden */
  39140. export var defaultUboDeclaration: {
  39141. name: string;
  39142. shader: string;
  39143. };
  39144. }
  39145. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39146. /** @hidden */
  39147. export var lightFragmentDeclaration: {
  39148. name: string;
  39149. shader: string;
  39150. };
  39151. }
  39152. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39153. /** @hidden */
  39154. export var lightUboDeclaration: {
  39155. name: string;
  39156. shader: string;
  39157. };
  39158. }
  39159. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39160. /** @hidden */
  39161. export var lightsFragmentFunctions: {
  39162. name: string;
  39163. shader: string;
  39164. };
  39165. }
  39166. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39167. /** @hidden */
  39168. export var shadowsFragmentFunctions: {
  39169. name: string;
  39170. shader: string;
  39171. };
  39172. }
  39173. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39174. /** @hidden */
  39175. export var fresnelFunction: {
  39176. name: string;
  39177. shader: string;
  39178. };
  39179. }
  39180. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39181. /** @hidden */
  39182. export var reflectionFunction: {
  39183. name: string;
  39184. shader: string;
  39185. };
  39186. }
  39187. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39188. /** @hidden */
  39189. export var bumpFragmentFunctions: {
  39190. name: string;
  39191. shader: string;
  39192. };
  39193. }
  39194. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39195. /** @hidden */
  39196. export var logDepthDeclaration: {
  39197. name: string;
  39198. shader: string;
  39199. };
  39200. }
  39201. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39202. /** @hidden */
  39203. export var bumpFragment: {
  39204. name: string;
  39205. shader: string;
  39206. };
  39207. }
  39208. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39209. /** @hidden */
  39210. export var depthPrePass: {
  39211. name: string;
  39212. shader: string;
  39213. };
  39214. }
  39215. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39216. /** @hidden */
  39217. export var lightFragment: {
  39218. name: string;
  39219. shader: string;
  39220. };
  39221. }
  39222. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39223. /** @hidden */
  39224. export var logDepthFragment: {
  39225. name: string;
  39226. shader: string;
  39227. };
  39228. }
  39229. declare module "babylonjs/Shaders/default.fragment" {
  39230. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39231. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39232. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39233. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39234. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39235. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39236. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39237. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39238. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39239. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39240. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39241. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39242. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39243. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39244. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39245. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39246. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39247. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39248. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39249. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39250. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39251. /** @hidden */
  39252. export var defaultPixelShader: {
  39253. name: string;
  39254. shader: string;
  39255. };
  39256. }
  39257. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39258. /** @hidden */
  39259. export var defaultVertexDeclaration: {
  39260. name: string;
  39261. shader: string;
  39262. };
  39263. }
  39264. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39265. /** @hidden */
  39266. export var bumpVertexDeclaration: {
  39267. name: string;
  39268. shader: string;
  39269. };
  39270. }
  39271. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39272. /** @hidden */
  39273. export var bumpVertex: {
  39274. name: string;
  39275. shader: string;
  39276. };
  39277. }
  39278. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39279. /** @hidden */
  39280. export var fogVertex: {
  39281. name: string;
  39282. shader: string;
  39283. };
  39284. }
  39285. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39286. /** @hidden */
  39287. export var shadowsVertex: {
  39288. name: string;
  39289. shader: string;
  39290. };
  39291. }
  39292. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39293. /** @hidden */
  39294. export var pointCloudVertex: {
  39295. name: string;
  39296. shader: string;
  39297. };
  39298. }
  39299. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39300. /** @hidden */
  39301. export var logDepthVertex: {
  39302. name: string;
  39303. shader: string;
  39304. };
  39305. }
  39306. declare module "babylonjs/Shaders/default.vertex" {
  39307. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39308. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39309. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39310. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39311. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39312. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39313. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39314. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39315. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39316. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39317. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39318. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39319. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39320. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39321. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39322. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39323. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39324. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39325. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39326. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39327. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39328. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39329. /** @hidden */
  39330. export var defaultVertexShader: {
  39331. name: string;
  39332. shader: string;
  39333. };
  39334. }
  39335. declare module "babylonjs/Materials/standardMaterial" {
  39336. import { SmartArray } from "babylonjs/Misc/smartArray";
  39337. import { IAnimatable } from "babylonjs/Misc/tools";
  39338. import { Nullable } from "babylonjs/types";
  39339. import { Scene } from "babylonjs/scene";
  39340. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39341. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39343. import { Mesh } from "babylonjs/Meshes/mesh";
  39344. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39345. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39346. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39347. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39348. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39351. import "babylonjs/Shaders/default.fragment";
  39352. import "babylonjs/Shaders/default.vertex";
  39353. /** @hidden */
  39354. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39355. MAINUV1: boolean;
  39356. MAINUV2: boolean;
  39357. DIFFUSE: boolean;
  39358. DIFFUSEDIRECTUV: number;
  39359. AMBIENT: boolean;
  39360. AMBIENTDIRECTUV: number;
  39361. OPACITY: boolean;
  39362. OPACITYDIRECTUV: number;
  39363. OPACITYRGB: boolean;
  39364. REFLECTION: boolean;
  39365. EMISSIVE: boolean;
  39366. EMISSIVEDIRECTUV: number;
  39367. SPECULAR: boolean;
  39368. SPECULARDIRECTUV: number;
  39369. BUMP: boolean;
  39370. BUMPDIRECTUV: number;
  39371. PARALLAX: boolean;
  39372. PARALLAXOCCLUSION: boolean;
  39373. SPECULAROVERALPHA: boolean;
  39374. CLIPPLANE: boolean;
  39375. CLIPPLANE2: boolean;
  39376. CLIPPLANE3: boolean;
  39377. CLIPPLANE4: boolean;
  39378. ALPHATEST: boolean;
  39379. DEPTHPREPASS: boolean;
  39380. ALPHAFROMDIFFUSE: boolean;
  39381. POINTSIZE: boolean;
  39382. FOG: boolean;
  39383. SPECULARTERM: boolean;
  39384. DIFFUSEFRESNEL: boolean;
  39385. OPACITYFRESNEL: boolean;
  39386. REFLECTIONFRESNEL: boolean;
  39387. REFRACTIONFRESNEL: boolean;
  39388. EMISSIVEFRESNEL: boolean;
  39389. FRESNEL: boolean;
  39390. NORMAL: boolean;
  39391. UV1: boolean;
  39392. UV2: boolean;
  39393. VERTEXCOLOR: boolean;
  39394. VERTEXALPHA: boolean;
  39395. NUM_BONE_INFLUENCERS: number;
  39396. BonesPerMesh: number;
  39397. BONETEXTURE: boolean;
  39398. INSTANCES: boolean;
  39399. GLOSSINESS: boolean;
  39400. ROUGHNESS: boolean;
  39401. EMISSIVEASILLUMINATION: boolean;
  39402. LINKEMISSIVEWITHDIFFUSE: boolean;
  39403. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39404. LIGHTMAP: boolean;
  39405. LIGHTMAPDIRECTUV: number;
  39406. OBJECTSPACE_NORMALMAP: boolean;
  39407. USELIGHTMAPASSHADOWMAP: boolean;
  39408. REFLECTIONMAP_3D: boolean;
  39409. REFLECTIONMAP_SPHERICAL: boolean;
  39410. REFLECTIONMAP_PLANAR: boolean;
  39411. REFLECTIONMAP_CUBIC: boolean;
  39412. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39413. REFLECTIONMAP_PROJECTION: boolean;
  39414. REFLECTIONMAP_SKYBOX: boolean;
  39415. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39416. REFLECTIONMAP_EXPLICIT: boolean;
  39417. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39418. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39419. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39420. INVERTCUBICMAP: boolean;
  39421. LOGARITHMICDEPTH: boolean;
  39422. REFRACTION: boolean;
  39423. REFRACTIONMAP_3D: boolean;
  39424. REFLECTIONOVERALPHA: boolean;
  39425. TWOSIDEDLIGHTING: boolean;
  39426. SHADOWFLOAT: boolean;
  39427. MORPHTARGETS: boolean;
  39428. MORPHTARGETS_NORMAL: boolean;
  39429. MORPHTARGETS_TANGENT: boolean;
  39430. NUM_MORPH_INFLUENCERS: number;
  39431. NONUNIFORMSCALING: boolean;
  39432. PREMULTIPLYALPHA: boolean;
  39433. IMAGEPROCESSING: boolean;
  39434. VIGNETTE: boolean;
  39435. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39436. VIGNETTEBLENDMODEOPAQUE: boolean;
  39437. TONEMAPPING: boolean;
  39438. TONEMAPPING_ACES: boolean;
  39439. CONTRAST: boolean;
  39440. COLORCURVES: boolean;
  39441. COLORGRADING: boolean;
  39442. COLORGRADING3D: boolean;
  39443. SAMPLER3DGREENDEPTH: boolean;
  39444. SAMPLER3DBGRMAP: boolean;
  39445. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39446. /**
  39447. * If the reflection texture on this material is in linear color space
  39448. * @hidden
  39449. */
  39450. IS_REFLECTION_LINEAR: boolean;
  39451. /**
  39452. * If the refraction texture on this material is in linear color space
  39453. * @hidden
  39454. */
  39455. IS_REFRACTION_LINEAR: boolean;
  39456. EXPOSURE: boolean;
  39457. constructor();
  39458. setReflectionMode(modeToEnable: string): void;
  39459. }
  39460. /**
  39461. * This is the default material used in Babylon. It is the best trade off between quality
  39462. * and performances.
  39463. * @see http://doc.babylonjs.com/babylon101/materials
  39464. */
  39465. export class StandardMaterial extends PushMaterial {
  39466. private _diffuseTexture;
  39467. /**
  39468. * The basic texture of the material as viewed under a light.
  39469. */
  39470. diffuseTexture: Nullable<BaseTexture>;
  39471. private _ambientTexture;
  39472. /**
  39473. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39474. */
  39475. ambientTexture: Nullable<BaseTexture>;
  39476. private _opacityTexture;
  39477. /**
  39478. * Define the transparency of the material from a texture.
  39479. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39480. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39481. */
  39482. opacityTexture: Nullable<BaseTexture>;
  39483. private _reflectionTexture;
  39484. /**
  39485. * Define the texture used to display the reflection.
  39486. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39487. */
  39488. reflectionTexture: Nullable<BaseTexture>;
  39489. private _emissiveTexture;
  39490. /**
  39491. * Define texture of the material as if self lit.
  39492. * This will be mixed in the final result even in the absence of light.
  39493. */
  39494. emissiveTexture: Nullable<BaseTexture>;
  39495. private _specularTexture;
  39496. /**
  39497. * Define how the color and intensity of the highlight given by the light in the material.
  39498. */
  39499. specularTexture: Nullable<BaseTexture>;
  39500. private _bumpTexture;
  39501. /**
  39502. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39503. * 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.
  39504. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39505. */
  39506. bumpTexture: Nullable<BaseTexture>;
  39507. private _lightmapTexture;
  39508. /**
  39509. * Complex lighting can be computationally expensive to compute at runtime.
  39510. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39511. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39512. */
  39513. lightmapTexture: Nullable<BaseTexture>;
  39514. private _refractionTexture;
  39515. /**
  39516. * Define the texture used to display the refraction.
  39517. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39518. */
  39519. refractionTexture: Nullable<BaseTexture>;
  39520. /**
  39521. * The color of the material lit by the environmental background lighting.
  39522. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39523. */
  39524. ambientColor: Color3;
  39525. /**
  39526. * The basic color of the material as viewed under a light.
  39527. */
  39528. diffuseColor: Color3;
  39529. /**
  39530. * Define how the color and intensity of the highlight given by the light in the material.
  39531. */
  39532. specularColor: Color3;
  39533. /**
  39534. * Define the color of the material as if self lit.
  39535. * This will be mixed in the final result even in the absence of light.
  39536. */
  39537. emissiveColor: Color3;
  39538. /**
  39539. * Defines how sharp are the highlights in the material.
  39540. * The bigger the value the sharper giving a more glossy feeling to the result.
  39541. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39542. */
  39543. specularPower: number;
  39544. private _useAlphaFromDiffuseTexture;
  39545. /**
  39546. * Does the transparency come from the diffuse texture alpha channel.
  39547. */
  39548. useAlphaFromDiffuseTexture: boolean;
  39549. private _useEmissiveAsIllumination;
  39550. /**
  39551. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39552. */
  39553. useEmissiveAsIllumination: boolean;
  39554. private _linkEmissiveWithDiffuse;
  39555. /**
  39556. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39557. * the emissive level when the final color is close to one.
  39558. */
  39559. linkEmissiveWithDiffuse: boolean;
  39560. private _useSpecularOverAlpha;
  39561. /**
  39562. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39563. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39564. */
  39565. useSpecularOverAlpha: boolean;
  39566. private _useReflectionOverAlpha;
  39567. /**
  39568. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39569. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39570. */
  39571. useReflectionOverAlpha: boolean;
  39572. private _disableLighting;
  39573. /**
  39574. * Does lights from the scene impacts this material.
  39575. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39576. */
  39577. disableLighting: boolean;
  39578. private _useObjectSpaceNormalMap;
  39579. /**
  39580. * Allows using an object space normal map (instead of tangent space).
  39581. */
  39582. useObjectSpaceNormalMap: boolean;
  39583. private _useParallax;
  39584. /**
  39585. * Is parallax enabled or not.
  39586. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39587. */
  39588. useParallax: boolean;
  39589. private _useParallaxOcclusion;
  39590. /**
  39591. * Is parallax occlusion enabled or not.
  39592. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39593. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39594. */
  39595. useParallaxOcclusion: boolean;
  39596. /**
  39597. * 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.
  39598. */
  39599. parallaxScaleBias: number;
  39600. private _roughness;
  39601. /**
  39602. * Helps to define how blurry the reflections should appears in the material.
  39603. */
  39604. roughness: number;
  39605. /**
  39606. * In case of refraction, define the value of the indice of refraction.
  39607. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39608. */
  39609. indexOfRefraction: number;
  39610. /**
  39611. * Invert the refraction texture alongside the y axis.
  39612. * It can be useful with procedural textures or probe for instance.
  39613. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39614. */
  39615. invertRefractionY: boolean;
  39616. /**
  39617. * Defines the alpha limits in alpha test mode.
  39618. */
  39619. alphaCutOff: number;
  39620. private _useLightmapAsShadowmap;
  39621. /**
  39622. * In case of light mapping, define whether the map contains light or shadow informations.
  39623. */
  39624. useLightmapAsShadowmap: boolean;
  39625. private _diffuseFresnelParameters;
  39626. /**
  39627. * Define the diffuse fresnel parameters of the material.
  39628. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39629. */
  39630. diffuseFresnelParameters: FresnelParameters;
  39631. private _opacityFresnelParameters;
  39632. /**
  39633. * Define the opacity fresnel parameters of the material.
  39634. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39635. */
  39636. opacityFresnelParameters: FresnelParameters;
  39637. private _reflectionFresnelParameters;
  39638. /**
  39639. * Define the reflection fresnel parameters of the material.
  39640. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39641. */
  39642. reflectionFresnelParameters: FresnelParameters;
  39643. private _refractionFresnelParameters;
  39644. /**
  39645. * Define the refraction fresnel parameters of the material.
  39646. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39647. */
  39648. refractionFresnelParameters: FresnelParameters;
  39649. private _emissiveFresnelParameters;
  39650. /**
  39651. * Define the emissive fresnel parameters of the material.
  39652. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39653. */
  39654. emissiveFresnelParameters: FresnelParameters;
  39655. private _useReflectionFresnelFromSpecular;
  39656. /**
  39657. * If true automatically deducts the fresnels values from the material specularity.
  39658. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39659. */
  39660. useReflectionFresnelFromSpecular: boolean;
  39661. private _useGlossinessFromSpecularMapAlpha;
  39662. /**
  39663. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39664. */
  39665. useGlossinessFromSpecularMapAlpha: boolean;
  39666. private _maxSimultaneousLights;
  39667. /**
  39668. * Defines the maximum number of lights that can be used in the material
  39669. */
  39670. maxSimultaneousLights: number;
  39671. private _invertNormalMapX;
  39672. /**
  39673. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39674. */
  39675. invertNormalMapX: boolean;
  39676. private _invertNormalMapY;
  39677. /**
  39678. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39679. */
  39680. invertNormalMapY: boolean;
  39681. private _twoSidedLighting;
  39682. /**
  39683. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39684. */
  39685. twoSidedLighting: boolean;
  39686. /**
  39687. * Default configuration related to image processing available in the standard Material.
  39688. */
  39689. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39690. /**
  39691. * Gets the image processing configuration used either in this material.
  39692. */
  39693. /**
  39694. * Sets the Default image processing configuration used either in the this material.
  39695. *
  39696. * If sets to null, the scene one is in use.
  39697. */
  39698. imageProcessingConfiguration: ImageProcessingConfiguration;
  39699. /**
  39700. * Keep track of the image processing observer to allow dispose and replace.
  39701. */
  39702. private _imageProcessingObserver;
  39703. /**
  39704. * Attaches a new image processing configuration to the Standard Material.
  39705. * @param configuration
  39706. */
  39707. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39708. /**
  39709. * Gets wether the color curves effect is enabled.
  39710. */
  39711. /**
  39712. * Sets wether the color curves effect is enabled.
  39713. */
  39714. cameraColorCurvesEnabled: boolean;
  39715. /**
  39716. * Gets wether the color grading effect is enabled.
  39717. */
  39718. /**
  39719. * Gets wether the color grading effect is enabled.
  39720. */
  39721. cameraColorGradingEnabled: boolean;
  39722. /**
  39723. * Gets wether tonemapping is enabled or not.
  39724. */
  39725. /**
  39726. * Sets wether tonemapping is enabled or not
  39727. */
  39728. cameraToneMappingEnabled: boolean;
  39729. /**
  39730. * The camera exposure used on this material.
  39731. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39732. * This corresponds to a photographic exposure.
  39733. */
  39734. /**
  39735. * The camera exposure used on this material.
  39736. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39737. * This corresponds to a photographic exposure.
  39738. */
  39739. cameraExposure: number;
  39740. /**
  39741. * Gets The camera contrast used on this material.
  39742. */
  39743. /**
  39744. * Sets The camera contrast used on this material.
  39745. */
  39746. cameraContrast: number;
  39747. /**
  39748. * Gets the Color Grading 2D Lookup Texture.
  39749. */
  39750. /**
  39751. * Sets the Color Grading 2D Lookup Texture.
  39752. */
  39753. cameraColorGradingTexture: Nullable<BaseTexture>;
  39754. /**
  39755. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39756. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39757. * 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;
  39758. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39759. */
  39760. /**
  39761. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39762. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39763. * 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;
  39764. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39765. */
  39766. cameraColorCurves: Nullable<ColorCurves>;
  39767. /**
  39768. * Custom callback helping to override the default shader used in the material.
  39769. */
  39770. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39771. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39772. protected _worldViewProjectionMatrix: Matrix;
  39773. protected _globalAmbientColor: Color3;
  39774. protected _useLogarithmicDepth: boolean;
  39775. /**
  39776. * Instantiates a new standard material.
  39777. * This is the default material used in Babylon. It is the best trade off between quality
  39778. * and performances.
  39779. * @see http://doc.babylonjs.com/babylon101/materials
  39780. * @param name Define the name of the material in the scene
  39781. * @param scene Define the scene the material belong to
  39782. */
  39783. constructor(name: string, scene: Scene);
  39784. /**
  39785. * Gets a boolean indicating that current material needs to register RTT
  39786. */
  39787. readonly hasRenderTargetTextures: boolean;
  39788. /**
  39789. * Gets the current class name of the material e.g. "StandardMaterial"
  39790. * Mainly use in serialization.
  39791. * @returns the class name
  39792. */
  39793. getClassName(): string;
  39794. /**
  39795. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39796. * You can try switching to logarithmic depth.
  39797. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39798. */
  39799. useLogarithmicDepth: boolean;
  39800. /**
  39801. * Specifies if the material will require alpha blending
  39802. * @returns a boolean specifying if alpha blending is needed
  39803. */
  39804. needAlphaBlending(): boolean;
  39805. /**
  39806. * Specifies if this material should be rendered in alpha test mode
  39807. * @returns a boolean specifying if an alpha test is needed.
  39808. */
  39809. needAlphaTesting(): boolean;
  39810. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39811. /**
  39812. * Get the texture used for alpha test purpose.
  39813. * @returns the diffuse texture in case of the standard material.
  39814. */
  39815. getAlphaTestTexture(): Nullable<BaseTexture>;
  39816. /**
  39817. * Get if the submesh is ready to be used and all its information available.
  39818. * Child classes can use it to update shaders
  39819. * @param mesh defines the mesh to check
  39820. * @param subMesh defines which submesh to check
  39821. * @param useInstances specifies that instances should be used
  39822. * @returns a boolean indicating that the submesh is ready or not
  39823. */
  39824. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39825. /**
  39826. * Builds the material UBO layouts.
  39827. * Used internally during the effect preparation.
  39828. */
  39829. buildUniformLayout(): void;
  39830. /**
  39831. * Unbinds the material from the mesh
  39832. */
  39833. unbind(): void;
  39834. /**
  39835. * Binds the submesh to this material by preparing the effect and shader to draw
  39836. * @param world defines the world transformation matrix
  39837. * @param mesh defines the mesh containing the submesh
  39838. * @param subMesh defines the submesh to bind the material to
  39839. */
  39840. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39841. /**
  39842. * Get the list of animatables in the material.
  39843. * @returns the list of animatables object used in the material
  39844. */
  39845. getAnimatables(): IAnimatable[];
  39846. /**
  39847. * Gets the active textures from the material
  39848. * @returns an array of textures
  39849. */
  39850. getActiveTextures(): BaseTexture[];
  39851. /**
  39852. * Specifies if the material uses a texture
  39853. * @param texture defines the texture to check against the material
  39854. * @returns a boolean specifying if the material uses the texture
  39855. */
  39856. hasTexture(texture: BaseTexture): boolean;
  39857. /**
  39858. * Disposes the material
  39859. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39860. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39861. */
  39862. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39863. /**
  39864. * Makes a duplicate of the material, and gives it a new name
  39865. * @param name defines the new name for the duplicated material
  39866. * @returns the cloned material
  39867. */
  39868. clone(name: string): StandardMaterial;
  39869. /**
  39870. * Serializes this material in a JSON representation
  39871. * @returns the serialized material object
  39872. */
  39873. serialize(): any;
  39874. /**
  39875. * Creates a standard material from parsed material data
  39876. * @param source defines the JSON representation of the material
  39877. * @param scene defines the hosting scene
  39878. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39879. * @returns a new standard material
  39880. */
  39881. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39882. /**
  39883. * Are diffuse textures enabled in the application.
  39884. */
  39885. static DiffuseTextureEnabled: boolean;
  39886. /**
  39887. * Are ambient textures enabled in the application.
  39888. */
  39889. static AmbientTextureEnabled: boolean;
  39890. /**
  39891. * Are opacity textures enabled in the application.
  39892. */
  39893. static OpacityTextureEnabled: boolean;
  39894. /**
  39895. * Are reflection textures enabled in the application.
  39896. */
  39897. static ReflectionTextureEnabled: boolean;
  39898. /**
  39899. * Are emissive textures enabled in the application.
  39900. */
  39901. static EmissiveTextureEnabled: boolean;
  39902. /**
  39903. * Are specular textures enabled in the application.
  39904. */
  39905. static SpecularTextureEnabled: boolean;
  39906. /**
  39907. * Are bump textures enabled in the application.
  39908. */
  39909. static BumpTextureEnabled: boolean;
  39910. /**
  39911. * Are lightmap textures enabled in the application.
  39912. */
  39913. static LightmapTextureEnabled: boolean;
  39914. /**
  39915. * Are refraction textures enabled in the application.
  39916. */
  39917. static RefractionTextureEnabled: boolean;
  39918. /**
  39919. * Are color grading textures enabled in the application.
  39920. */
  39921. static ColorGradingTextureEnabled: boolean;
  39922. /**
  39923. * Are fresnels enabled in the application.
  39924. */
  39925. static FresnelEnabled: boolean;
  39926. }
  39927. }
  39928. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39929. import { Scene } from "babylonjs/scene";
  39930. import { Texture } from "babylonjs/Materials/Textures/texture";
  39931. /**
  39932. * A class extending Texture allowing drawing on a texture
  39933. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39934. */
  39935. export class DynamicTexture extends Texture {
  39936. private _generateMipMaps;
  39937. private _canvas;
  39938. private _context;
  39939. private _engine;
  39940. /**
  39941. * Creates a DynamicTexture
  39942. * @param name defines the name of the texture
  39943. * @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
  39944. * @param scene defines the scene where you want the texture
  39945. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39946. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39947. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39948. */
  39949. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39950. /**
  39951. * Get the current class name of the texture useful for serialization or dynamic coding.
  39952. * @returns "DynamicTexture"
  39953. */
  39954. getClassName(): string;
  39955. /**
  39956. * Gets the current state of canRescale
  39957. */
  39958. readonly canRescale: boolean;
  39959. private _recreate;
  39960. /**
  39961. * Scales the texture
  39962. * @param ratio the scale factor to apply to both width and height
  39963. */
  39964. scale(ratio: number): void;
  39965. /**
  39966. * Resizes the texture
  39967. * @param width the new width
  39968. * @param height the new height
  39969. */
  39970. scaleTo(width: number, height: number): void;
  39971. /**
  39972. * Gets the context of the canvas used by the texture
  39973. * @returns the canvas context of the dynamic texture
  39974. */
  39975. getContext(): CanvasRenderingContext2D;
  39976. /**
  39977. * Clears the texture
  39978. */
  39979. clear(): void;
  39980. /**
  39981. * Updates the texture
  39982. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39983. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39984. */
  39985. update(invertY?: boolean, premulAlpha?: boolean): void;
  39986. /**
  39987. * Draws text onto the texture
  39988. * @param text defines the text to be drawn
  39989. * @param x defines the placement of the text from the left
  39990. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39991. * @param font defines the font to be used with font-style, font-size, font-name
  39992. * @param color defines the color used for the text
  39993. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39994. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39995. * @param update defines whether texture is immediately update (default is true)
  39996. */
  39997. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39998. /**
  39999. * Clones the texture
  40000. * @returns the clone of the texture.
  40001. */
  40002. clone(): DynamicTexture;
  40003. /**
  40004. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40005. * @returns a serialized dynamic texture object
  40006. */
  40007. serialize(): any;
  40008. /** @hidden */
  40009. _rebuild(): void;
  40010. }
  40011. }
  40012. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40013. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40014. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40015. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40016. /** @hidden */
  40017. export var imageProcessingPixelShader: {
  40018. name: string;
  40019. shader: string;
  40020. };
  40021. }
  40022. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40023. import { Nullable } from "babylonjs/types";
  40024. import { Color4 } from "babylonjs/Maths/math";
  40025. import { Camera } from "babylonjs/Cameras/camera";
  40026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40027. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40028. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40029. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40030. import { Engine } from "babylonjs/Engines/engine";
  40031. import "babylonjs/Shaders/imageProcessing.fragment";
  40032. import "babylonjs/Shaders/postprocess.vertex";
  40033. /**
  40034. * ImageProcessingPostProcess
  40035. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40036. */
  40037. export class ImageProcessingPostProcess extends PostProcess {
  40038. /**
  40039. * Default configuration related to image processing available in the PBR Material.
  40040. */
  40041. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40042. /**
  40043. * Gets the image processing configuration used either in this material.
  40044. */
  40045. /**
  40046. * Sets the Default image processing configuration used either in the this material.
  40047. *
  40048. * If sets to null, the scene one is in use.
  40049. */
  40050. imageProcessingConfiguration: ImageProcessingConfiguration;
  40051. /**
  40052. * Keep track of the image processing observer to allow dispose and replace.
  40053. */
  40054. private _imageProcessingObserver;
  40055. /**
  40056. * Attaches a new image processing configuration to the PBR Material.
  40057. * @param configuration
  40058. */
  40059. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40060. /**
  40061. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40062. */
  40063. /**
  40064. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40065. */
  40066. colorCurves: Nullable<ColorCurves>;
  40067. /**
  40068. * Gets wether the color curves effect is enabled.
  40069. */
  40070. /**
  40071. * Sets wether the color curves effect is enabled.
  40072. */
  40073. colorCurvesEnabled: boolean;
  40074. /**
  40075. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40076. */
  40077. /**
  40078. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40079. */
  40080. colorGradingTexture: Nullable<BaseTexture>;
  40081. /**
  40082. * Gets wether the color grading effect is enabled.
  40083. */
  40084. /**
  40085. * Gets wether the color grading effect is enabled.
  40086. */
  40087. colorGradingEnabled: boolean;
  40088. /**
  40089. * Gets exposure used in the effect.
  40090. */
  40091. /**
  40092. * Sets exposure used in the effect.
  40093. */
  40094. exposure: number;
  40095. /**
  40096. * Gets wether tonemapping is enabled or not.
  40097. */
  40098. /**
  40099. * Sets wether tonemapping is enabled or not
  40100. */
  40101. toneMappingEnabled: boolean;
  40102. /**
  40103. * Gets contrast used in the effect.
  40104. */
  40105. /**
  40106. * Sets contrast used in the effect.
  40107. */
  40108. contrast: number;
  40109. /**
  40110. * Gets Vignette stretch size.
  40111. */
  40112. /**
  40113. * Sets Vignette stretch size.
  40114. */
  40115. vignetteStretch: number;
  40116. /**
  40117. * Gets Vignette centre X Offset.
  40118. */
  40119. /**
  40120. * Sets Vignette centre X Offset.
  40121. */
  40122. vignetteCentreX: number;
  40123. /**
  40124. * Gets Vignette centre Y Offset.
  40125. */
  40126. /**
  40127. * Sets Vignette centre Y Offset.
  40128. */
  40129. vignetteCentreY: number;
  40130. /**
  40131. * Gets Vignette weight or intensity of the vignette effect.
  40132. */
  40133. /**
  40134. * Sets Vignette weight or intensity of the vignette effect.
  40135. */
  40136. vignetteWeight: number;
  40137. /**
  40138. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40139. * if vignetteEnabled is set to true.
  40140. */
  40141. /**
  40142. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40143. * if vignetteEnabled is set to true.
  40144. */
  40145. vignetteColor: Color4;
  40146. /**
  40147. * Gets Camera field of view used by the Vignette effect.
  40148. */
  40149. /**
  40150. * Sets Camera field of view used by the Vignette effect.
  40151. */
  40152. vignetteCameraFov: number;
  40153. /**
  40154. * Gets the vignette blend mode allowing different kind of effect.
  40155. */
  40156. /**
  40157. * Sets the vignette blend mode allowing different kind of effect.
  40158. */
  40159. vignetteBlendMode: number;
  40160. /**
  40161. * Gets wether the vignette effect is enabled.
  40162. */
  40163. /**
  40164. * Sets wether the vignette effect is enabled.
  40165. */
  40166. vignetteEnabled: boolean;
  40167. private _fromLinearSpace;
  40168. /**
  40169. * Gets wether the input of the processing is in Gamma or Linear Space.
  40170. */
  40171. /**
  40172. * Sets wether the input of the processing is in Gamma or Linear Space.
  40173. */
  40174. fromLinearSpace: boolean;
  40175. /**
  40176. * Defines cache preventing GC.
  40177. */
  40178. private _defines;
  40179. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40180. /**
  40181. * "ImageProcessingPostProcess"
  40182. * @returns "ImageProcessingPostProcess"
  40183. */
  40184. getClassName(): string;
  40185. protected _updateParameters(): void;
  40186. dispose(camera?: Camera): void;
  40187. }
  40188. }
  40189. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40190. import { Observable } from "babylonjs/Misc/observable";
  40191. import { Nullable } from "babylonjs/types";
  40192. import { Camera } from "babylonjs/Cameras/camera";
  40193. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40194. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40195. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40196. import { Scene } from "babylonjs/scene";
  40197. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40198. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40200. import { Mesh } from "babylonjs/Meshes/mesh";
  40201. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40202. /**
  40203. * Options to modify the vr teleportation behavior.
  40204. */
  40205. export interface VRTeleportationOptions {
  40206. /**
  40207. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40208. */
  40209. floorMeshName?: string;
  40210. /**
  40211. * A list of meshes to be used as the teleportation floor. (default: empty)
  40212. */
  40213. floorMeshes?: Mesh[];
  40214. }
  40215. /**
  40216. * Options to modify the vr experience helper's behavior.
  40217. */
  40218. export interface VRExperienceHelperOptions extends WebVROptions {
  40219. /**
  40220. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40221. */
  40222. createDeviceOrientationCamera?: boolean;
  40223. /**
  40224. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40225. */
  40226. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40227. /**
  40228. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40229. */
  40230. laserToggle?: boolean;
  40231. /**
  40232. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40233. */
  40234. floorMeshes?: Mesh[];
  40235. }
  40236. /**
  40237. * Helps to quickly add VR support to an existing scene.
  40238. * See http://doc.babylonjs.com/how_to/webvr_helper
  40239. */
  40240. export class VRExperienceHelper {
  40241. /** Options to modify the vr experience helper's behavior. */
  40242. webVROptions: VRExperienceHelperOptions;
  40243. private _scene;
  40244. private _position;
  40245. private _btnVR;
  40246. private _btnVRDisplayed;
  40247. private _webVRsupported;
  40248. private _webVRready;
  40249. private _webVRrequesting;
  40250. private _webVRpresenting;
  40251. private _hasEnteredVR;
  40252. private _fullscreenVRpresenting;
  40253. private _canvas;
  40254. private _webVRCamera;
  40255. private _vrDeviceOrientationCamera;
  40256. private _deviceOrientationCamera;
  40257. private _existingCamera;
  40258. private _onKeyDown;
  40259. private _onVrDisplayPresentChange;
  40260. private _onVRDisplayChanged;
  40261. private _onVRRequestPresentStart;
  40262. private _onVRRequestPresentComplete;
  40263. /**
  40264. * Observable raised when entering VR.
  40265. */
  40266. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40267. /**
  40268. * Observable raised when exiting VR.
  40269. */
  40270. onExitingVRObservable: Observable<VRExperienceHelper>;
  40271. /**
  40272. * Observable raised when controller mesh is loaded.
  40273. */
  40274. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40275. /** Return this.onEnteringVRObservable
  40276. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40277. */
  40278. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40279. /** Return this.onExitingVRObservable
  40280. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40281. */
  40282. readonly onExitingVR: Observable<VRExperienceHelper>;
  40283. /** Return this.onControllerMeshLoadedObservable
  40284. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40285. */
  40286. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40287. private _rayLength;
  40288. private _useCustomVRButton;
  40289. private _teleportationRequested;
  40290. private _teleportActive;
  40291. private _floorMeshName;
  40292. private _floorMeshesCollection;
  40293. private _rotationAllowed;
  40294. private _teleportBackwardsVector;
  40295. private _teleportationTarget;
  40296. private _isDefaultTeleportationTarget;
  40297. private _postProcessMove;
  40298. private _teleportationFillColor;
  40299. private _teleportationBorderColor;
  40300. private _rotationAngle;
  40301. private _haloCenter;
  40302. private _cameraGazer;
  40303. private _padSensibilityUp;
  40304. private _padSensibilityDown;
  40305. private _leftController;
  40306. private _rightController;
  40307. /**
  40308. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40309. */
  40310. onNewMeshSelected: Observable<AbstractMesh>;
  40311. /**
  40312. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40313. */
  40314. onNewMeshPicked: Observable<PickingInfo>;
  40315. private _circleEase;
  40316. /**
  40317. * Observable raised before camera teleportation
  40318. */
  40319. onBeforeCameraTeleport: Observable<Vector3>;
  40320. /**
  40321. * Observable raised after camera teleportation
  40322. */
  40323. onAfterCameraTeleport: Observable<Vector3>;
  40324. /**
  40325. * Observable raised when current selected mesh gets unselected
  40326. */
  40327. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40328. private _raySelectionPredicate;
  40329. /**
  40330. * To be optionaly changed by user to define custom ray selection
  40331. */
  40332. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40333. /**
  40334. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40335. */
  40336. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40337. /**
  40338. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40339. */
  40340. teleportationEnabled: boolean;
  40341. private _defaultHeight;
  40342. private _teleportationInitialized;
  40343. private _interactionsEnabled;
  40344. private _interactionsRequested;
  40345. private _displayGaze;
  40346. private _displayLaserPointer;
  40347. /**
  40348. * The mesh used to display where the user is going to teleport.
  40349. */
  40350. /**
  40351. * Sets the mesh to be used to display where the user is going to teleport.
  40352. */
  40353. teleportationTarget: Mesh;
  40354. /**
  40355. * 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
  40356. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40357. * See http://doc.babylonjs.com/resources/baking_transformations
  40358. */
  40359. gazeTrackerMesh: Mesh;
  40360. /**
  40361. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40362. */
  40363. updateGazeTrackerScale: boolean;
  40364. /**
  40365. * If the gaze trackers color should be updated when selecting meshes
  40366. */
  40367. updateGazeTrackerColor: boolean;
  40368. /**
  40369. * The gaze tracking mesh corresponding to the left controller
  40370. */
  40371. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40372. /**
  40373. * The gaze tracking mesh corresponding to the right controller
  40374. */
  40375. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40376. /**
  40377. * If the ray of the gaze should be displayed.
  40378. */
  40379. /**
  40380. * Sets if the ray of the gaze should be displayed.
  40381. */
  40382. displayGaze: boolean;
  40383. /**
  40384. * If the ray of the LaserPointer should be displayed.
  40385. */
  40386. /**
  40387. * Sets if the ray of the LaserPointer should be displayed.
  40388. */
  40389. displayLaserPointer: boolean;
  40390. /**
  40391. * The deviceOrientationCamera used as the camera when not in VR.
  40392. */
  40393. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40394. /**
  40395. * Based on the current WebVR support, returns the current VR camera used.
  40396. */
  40397. readonly currentVRCamera: Nullable<Camera>;
  40398. /**
  40399. * The webVRCamera which is used when in VR.
  40400. */
  40401. readonly webVRCamera: WebVRFreeCamera;
  40402. /**
  40403. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40404. */
  40405. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40406. private readonly _teleportationRequestInitiated;
  40407. /**
  40408. * Instantiates a VRExperienceHelper.
  40409. * Helps to quickly add VR support to an existing scene.
  40410. * @param scene The scene the VRExperienceHelper belongs to.
  40411. * @param webVROptions Options to modify the vr experience helper's behavior.
  40412. */
  40413. constructor(scene: Scene,
  40414. /** Options to modify the vr experience helper's behavior. */
  40415. webVROptions?: VRExperienceHelperOptions);
  40416. private _onDefaultMeshLoaded;
  40417. private _onResize;
  40418. private _onFullscreenChange;
  40419. /**
  40420. * Gets a value indicating if we are currently in VR mode.
  40421. */
  40422. readonly isInVRMode: boolean;
  40423. private onVrDisplayPresentChange;
  40424. private onVRDisplayChanged;
  40425. private moveButtonToBottomRight;
  40426. private displayVRButton;
  40427. private updateButtonVisibility;
  40428. private _cachedAngularSensibility;
  40429. /**
  40430. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40431. * Otherwise, will use the fullscreen API.
  40432. */
  40433. enterVR(): void;
  40434. /**
  40435. * Attempt to exit VR, or fullscreen.
  40436. */
  40437. exitVR(): void;
  40438. /**
  40439. * The position of the vr experience helper.
  40440. */
  40441. /**
  40442. * Sets the position of the vr experience helper.
  40443. */
  40444. position: Vector3;
  40445. /**
  40446. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40447. */
  40448. enableInteractions(): void;
  40449. private readonly _noControllerIsActive;
  40450. private beforeRender;
  40451. private _isTeleportationFloor;
  40452. /**
  40453. * Adds a floor mesh to be used for teleportation.
  40454. * @param floorMesh the mesh to be used for teleportation.
  40455. */
  40456. addFloorMesh(floorMesh: Mesh): void;
  40457. /**
  40458. * Removes a floor mesh from being used for teleportation.
  40459. * @param floorMesh the mesh to be removed.
  40460. */
  40461. removeFloorMesh(floorMesh: Mesh): void;
  40462. /**
  40463. * Enables interactions and teleportation using the VR controllers and gaze.
  40464. * @param vrTeleportationOptions options to modify teleportation behavior.
  40465. */
  40466. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40467. private _onNewGamepadConnected;
  40468. private _tryEnableInteractionOnController;
  40469. private _onNewGamepadDisconnected;
  40470. private _enableInteractionOnController;
  40471. private _checkTeleportWithRay;
  40472. private _checkRotate;
  40473. private _checkTeleportBackwards;
  40474. private _enableTeleportationOnController;
  40475. private _createTeleportationCircles;
  40476. private _displayTeleportationTarget;
  40477. private _hideTeleportationTarget;
  40478. private _rotateCamera;
  40479. private _moveTeleportationSelectorTo;
  40480. private _workingVector;
  40481. private _workingQuaternion;
  40482. private _workingMatrix;
  40483. /**
  40484. * Teleports the users feet to the desired location
  40485. * @param location The location where the user's feet should be placed
  40486. */
  40487. teleportCamera(location: Vector3): void;
  40488. private _convertNormalToDirectionOfRay;
  40489. private _castRayAndSelectObject;
  40490. private _notifySelectedMeshUnselected;
  40491. /**
  40492. * Sets the color of the laser ray from the vr controllers.
  40493. * @param color new color for the ray.
  40494. */
  40495. changeLaserColor(color: Color3): void;
  40496. /**
  40497. * Sets the color of the ray from the vr headsets gaze.
  40498. * @param color new color for the ray.
  40499. */
  40500. changeGazeColor(color: Color3): void;
  40501. /**
  40502. * Exits VR and disposes of the vr experience helper
  40503. */
  40504. dispose(): void;
  40505. /**
  40506. * Gets the name of the VRExperienceHelper class
  40507. * @returns "VRExperienceHelper"
  40508. */
  40509. getClassName(): string;
  40510. }
  40511. }
  40512. declare module "babylonjs/Cameras/VR/index" {
  40513. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40514. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40515. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40516. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40517. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40518. export * from "babylonjs/Cameras/VR/webVRCamera";
  40519. }
  40520. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40521. import { Observable } from "babylonjs/Misc/observable";
  40522. import { Nullable } from "babylonjs/types";
  40523. import { IDisposable, Scene } from "babylonjs/scene";
  40524. import { Vector3 } from "babylonjs/Maths/math";
  40525. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40526. import { Ray } from "babylonjs/Culling/ray";
  40527. /**
  40528. * Manages an XRSession
  40529. * @see https://doc.babylonjs.com/how_to/webxr
  40530. */
  40531. export class WebXRSessionManager implements IDisposable {
  40532. private scene;
  40533. /**
  40534. * Fires every time a new xrFrame arrives which can be used to update the camera
  40535. */
  40536. onXRFrameObservable: Observable<any>;
  40537. /**
  40538. * Fires when the xr session is ended either by the device or manually done
  40539. */
  40540. onXRSessionEnded: Observable<any>;
  40541. /** @hidden */
  40542. _xrSession: XRSession;
  40543. /** @hidden */
  40544. _frameOfReference: XRFrameOfReference;
  40545. /** @hidden */
  40546. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40547. /** @hidden */
  40548. _currentXRFrame: Nullable<XRFrame>;
  40549. private _xrNavigator;
  40550. private _xrDevice;
  40551. private _tmpMatrix;
  40552. /**
  40553. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40554. * @param scene The scene which the session should be created for
  40555. */
  40556. constructor(scene: Scene);
  40557. /**
  40558. * Initializes the manager
  40559. * After initialization enterXR can be called to start an XR session
  40560. * @returns Promise which resolves after it is initialized
  40561. */
  40562. initializeAsync(): Promise<void>;
  40563. /**
  40564. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40565. * @param sessionCreationOptions xr options to create the session with
  40566. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40567. * @returns Promise which resolves after it enters XR
  40568. */
  40569. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40570. /**
  40571. * Stops the xrSession and restores the renderloop
  40572. * @returns Promise which resolves after it exits XR
  40573. */
  40574. exitXRAsync(): Promise<void>;
  40575. /**
  40576. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40577. * @param ray ray to cast into the environment
  40578. * @returns Promise which resolves with a collision point in the environment if it exists
  40579. */
  40580. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40581. /**
  40582. * Checks if a session would be supported for the creation options specified
  40583. * @param options creation options to check if they are supported
  40584. * @returns true if supported
  40585. */
  40586. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40587. /**
  40588. * @hidden
  40589. * Converts the render layer of xrSession to a render target
  40590. * @param session session to create render target for
  40591. * @param scene scene the new render target should be created for
  40592. */
  40593. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40594. /**
  40595. * Disposes of the session manager
  40596. */
  40597. dispose(): void;
  40598. }
  40599. }
  40600. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40601. import { Scene } from "babylonjs/scene";
  40602. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40603. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40604. /**
  40605. * WebXR Camera which holds the views for the xrSession
  40606. * @see https://doc.babylonjs.com/how_to/webxr
  40607. */
  40608. export class WebXRCamera extends FreeCamera {
  40609. private static _TmpMatrix;
  40610. /**
  40611. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40612. * @param name the name of the camera
  40613. * @param scene the scene to add the camera to
  40614. */
  40615. constructor(name: string, scene: Scene);
  40616. private _updateNumberOfRigCameras;
  40617. /** @hidden */
  40618. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40619. /**
  40620. * Updates the cameras position from the current pose information of the XR session
  40621. * @param xrSessionManager the session containing pose information
  40622. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40623. */
  40624. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40625. }
  40626. }
  40627. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40628. import { Nullable } from "babylonjs/types";
  40629. import { Observable } from "babylonjs/Misc/observable";
  40630. import { IDisposable, Scene } from "babylonjs/scene";
  40631. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40633. import { Ray } from "babylonjs/Culling/ray";
  40634. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40635. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40636. /**
  40637. * States of the webXR experience
  40638. */
  40639. export enum WebXRState {
  40640. /**
  40641. * Transitioning to being in XR mode
  40642. */
  40643. ENTERING_XR = 0,
  40644. /**
  40645. * Transitioning to non XR mode
  40646. */
  40647. EXITING_XR = 1,
  40648. /**
  40649. * In XR mode and presenting
  40650. */
  40651. IN_XR = 2,
  40652. /**
  40653. * Not entered XR mode
  40654. */
  40655. NOT_IN_XR = 3
  40656. }
  40657. /**
  40658. * Helper class used to enable XR
  40659. * @see https://doc.babylonjs.com/how_to/webxr
  40660. */
  40661. export class WebXRExperienceHelper implements IDisposable {
  40662. private scene;
  40663. /**
  40664. * 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
  40665. */
  40666. container: AbstractMesh;
  40667. /**
  40668. * Camera used to render xr content
  40669. */
  40670. camera: WebXRCamera;
  40671. /**
  40672. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40673. */
  40674. state: WebXRState;
  40675. private _setState;
  40676. private static _TmpVector;
  40677. /**
  40678. * Fires when the state of the experience helper has changed
  40679. */
  40680. onStateChangedObservable: Observable<WebXRState>;
  40681. /** @hidden */
  40682. _sessionManager: WebXRSessionManager;
  40683. private _nonVRCamera;
  40684. private _originalSceneAutoClear;
  40685. private _supported;
  40686. /**
  40687. * Creates the experience helper
  40688. * @param scene the scene to attach the experience helper to
  40689. * @returns a promise for the experience helper
  40690. */
  40691. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40692. /**
  40693. * Creates a WebXRExperienceHelper
  40694. * @param scene The scene the helper should be created in
  40695. */
  40696. private constructor();
  40697. /**
  40698. * Exits XR mode and returns the scene to its original state
  40699. * @returns promise that resolves after xr mode has exited
  40700. */
  40701. exitXRAsync(): Promise<void>;
  40702. /**
  40703. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40704. * @param sessionCreationOptions options for the XR session
  40705. * @param frameOfReference frame of reference of the XR session
  40706. * @returns promise that resolves after xr mode has entered
  40707. */
  40708. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40709. /**
  40710. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40711. * @param ray ray to cast into the environment
  40712. * @returns Promise which resolves with a collision point in the environment if it exists
  40713. */
  40714. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40715. /**
  40716. * Updates the global position of the camera by moving the camera's container
  40717. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40718. * @param position The desired global position of the camera
  40719. */
  40720. setPositionOfCameraUsingContainer(position: Vector3): void;
  40721. /**
  40722. * Rotates the xr camera by rotating the camera's container around the camera's position
  40723. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40724. * @param rotation the desired quaternion rotation to apply to the camera
  40725. */
  40726. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40727. /**
  40728. * Checks if the creation options are supported by the xr session
  40729. * @param options creation options
  40730. * @returns true if supported
  40731. */
  40732. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40733. /**
  40734. * Disposes of the experience helper
  40735. */
  40736. dispose(): void;
  40737. }
  40738. }
  40739. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40740. import { Nullable } from "babylonjs/types";
  40741. import { Observable } from "babylonjs/Misc/observable";
  40742. import { IDisposable, Scene } from "babylonjs/scene";
  40743. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40744. /**
  40745. * Button which can be used to enter a different mode of XR
  40746. */
  40747. export class WebXREnterExitUIButton {
  40748. /** button element */
  40749. element: HTMLElement;
  40750. /** XR initialization options for the button */
  40751. initializationOptions: XRSessionCreationOptions;
  40752. /**
  40753. * Creates a WebXREnterExitUIButton
  40754. * @param element button element
  40755. * @param initializationOptions XR initialization options for the button
  40756. */
  40757. constructor(
  40758. /** button element */
  40759. element: HTMLElement,
  40760. /** XR initialization options for the button */
  40761. initializationOptions: XRSessionCreationOptions);
  40762. /**
  40763. * Overwritable function which can be used to update the button's visuals when the state changes
  40764. * @param activeButton the current active button in the UI
  40765. */
  40766. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40767. }
  40768. /**
  40769. * Options to create the webXR UI
  40770. */
  40771. export class WebXREnterExitUIOptions {
  40772. /**
  40773. * Context to enter xr with
  40774. */
  40775. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40776. /**
  40777. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40778. */
  40779. customButtons?: Array<WebXREnterExitUIButton>;
  40780. }
  40781. /**
  40782. * UI to allow the user to enter/exit XR mode
  40783. */
  40784. export class WebXREnterExitUI implements IDisposable {
  40785. private scene;
  40786. private _overlay;
  40787. private _buttons;
  40788. private _activeButton;
  40789. /**
  40790. * Fired every time the active button is changed.
  40791. *
  40792. * When xr is entered via a button that launches xr that button will be the callback parameter
  40793. *
  40794. * When exiting xr the callback parameter will be null)
  40795. */
  40796. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40797. /**
  40798. * Creates UI to allow the user to enter/exit XR mode
  40799. * @param scene the scene to add the ui to
  40800. * @param helper the xr experience helper to enter/exit xr with
  40801. * @param options options to configure the UI
  40802. * @returns the created ui
  40803. */
  40804. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40805. private constructor();
  40806. private _updateButtons;
  40807. /**
  40808. * Disposes of the object
  40809. */
  40810. dispose(): void;
  40811. }
  40812. }
  40813. declare module "babylonjs/Cameras/XR/webXRInput" {
  40814. import { IDisposable, Scene } from "babylonjs/scene";
  40815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40816. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40817. /**
  40818. * Represents an XR input
  40819. */
  40820. export class WebXRController {
  40821. /**
  40822. * 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
  40823. */
  40824. grip?: AbstractMesh;
  40825. /**
  40826. * Pointer which can be used to select objects or attach a visible laser to
  40827. */
  40828. pointer: AbstractMesh;
  40829. /**
  40830. * Creates the controller
  40831. * @see https://doc.babylonjs.com/how_to/webxr
  40832. * @param scene the scene which the controller should be associated to
  40833. */
  40834. constructor(scene: Scene);
  40835. /**
  40836. * Disposes of the object
  40837. */
  40838. dispose(): void;
  40839. }
  40840. /**
  40841. * XR input used to track XR inputs such as controllers/rays
  40842. */
  40843. export class WebXRInput implements IDisposable {
  40844. private helper;
  40845. /**
  40846. * XR controllers being tracked
  40847. */
  40848. controllers: Array<WebXRController>;
  40849. private _tmpMatrix;
  40850. private _frameObserver;
  40851. /**
  40852. * Initializes the WebXRInput
  40853. * @param helper experience helper which the input should be created for
  40854. */
  40855. constructor(helper: WebXRExperienceHelper);
  40856. /**
  40857. * Disposes of the object
  40858. */
  40859. dispose(): void;
  40860. }
  40861. }
  40862. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40863. import { Nullable } from "babylonjs/types";
  40864. import { IDisposable } from "babylonjs/scene";
  40865. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40866. /**
  40867. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40868. */
  40869. export class WebXRManagedOutputCanvas implements IDisposable {
  40870. private _canvas;
  40871. /**
  40872. * xrpresent context of the canvas which can be used to display/mirror xr content
  40873. */
  40874. canvasContext: Nullable<WebGLRenderingContext>;
  40875. /**
  40876. * Initializes the canvas to be added/removed upon entering/exiting xr
  40877. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40878. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40879. */
  40880. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40881. /**
  40882. * Disposes of the object
  40883. */
  40884. dispose(): void;
  40885. private _setManagedOutputCanvas;
  40886. private _addCanvas;
  40887. private _removeCanvas;
  40888. }
  40889. }
  40890. declare module "babylonjs/Cameras/XR/index" {
  40891. export * from "babylonjs/Cameras/XR/webXRCamera";
  40892. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40893. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40894. export * from "babylonjs/Cameras/XR/webXRInput";
  40895. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40896. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40897. }
  40898. declare module "babylonjs/Cameras/index" {
  40899. export * from "babylonjs/Cameras/Inputs/index";
  40900. export * from "babylonjs/Cameras/cameraInputsManager";
  40901. export * from "babylonjs/Cameras/camera";
  40902. export * from "babylonjs/Cameras/targetCamera";
  40903. export * from "babylonjs/Cameras/freeCamera";
  40904. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40905. export * from "babylonjs/Cameras/touchCamera";
  40906. export * from "babylonjs/Cameras/arcRotateCamera";
  40907. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40908. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40909. export * from "babylonjs/Cameras/flyCamera";
  40910. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40911. export * from "babylonjs/Cameras/followCamera";
  40912. export * from "babylonjs/Cameras/gamepadCamera";
  40913. export * from "babylonjs/Cameras/Stereoscopic/index";
  40914. export * from "babylonjs/Cameras/universalCamera";
  40915. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40916. export * from "babylonjs/Cameras/VR/index";
  40917. export * from "babylonjs/Cameras/XR/index";
  40918. }
  40919. declare module "babylonjs/Collisions/index" {
  40920. export * from "babylonjs/Collisions/collider";
  40921. export * from "babylonjs/Collisions/collisionCoordinator";
  40922. export * from "babylonjs/Collisions/pickingInfo";
  40923. export * from "babylonjs/Collisions/intersectionInfo";
  40924. }
  40925. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40926. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40927. import { Vector3, Plane } from "babylonjs/Maths/math";
  40928. import { Ray } from "babylonjs/Culling/ray";
  40929. /**
  40930. * Contains an array of blocks representing the octree
  40931. */
  40932. export interface IOctreeContainer<T> {
  40933. /**
  40934. * Blocks within the octree
  40935. */
  40936. blocks: Array<OctreeBlock<T>>;
  40937. }
  40938. /**
  40939. * Class used to store a cell in an octree
  40940. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40941. */
  40942. export class OctreeBlock<T> {
  40943. /**
  40944. * Gets the content of the current block
  40945. */
  40946. entries: T[];
  40947. /**
  40948. * Gets the list of block children
  40949. */
  40950. blocks: Array<OctreeBlock<T>>;
  40951. private _depth;
  40952. private _maxDepth;
  40953. private _capacity;
  40954. private _minPoint;
  40955. private _maxPoint;
  40956. private _boundingVectors;
  40957. private _creationFunc;
  40958. /**
  40959. * Creates a new block
  40960. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40961. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40962. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40963. * @param depth defines the current depth of this block in the octree
  40964. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40965. * @param creationFunc defines a callback to call when an element is added to the block
  40966. */
  40967. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40968. /**
  40969. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40970. */
  40971. readonly capacity: number;
  40972. /**
  40973. * Gets the minimum vector (in world space) of the block's bounding box
  40974. */
  40975. readonly minPoint: Vector3;
  40976. /**
  40977. * Gets the maximum vector (in world space) of the block's bounding box
  40978. */
  40979. readonly maxPoint: Vector3;
  40980. /**
  40981. * Add a new element to this block
  40982. * @param entry defines the element to add
  40983. */
  40984. addEntry(entry: T): void;
  40985. /**
  40986. * Remove an element from this block
  40987. * @param entry defines the element to remove
  40988. */
  40989. removeEntry(entry: T): void;
  40990. /**
  40991. * Add an array of elements to this block
  40992. * @param entries defines the array of elements to add
  40993. */
  40994. addEntries(entries: T[]): void;
  40995. /**
  40996. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40997. * @param frustumPlanes defines the frustum planes to test
  40998. * @param selection defines the array to store current content if selection is positive
  40999. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41000. */
  41001. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41002. /**
  41003. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41004. * @param sphereCenter defines the bounding sphere center
  41005. * @param sphereRadius defines the bounding sphere radius
  41006. * @param selection defines the array to store current content if selection is positive
  41007. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41008. */
  41009. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41010. /**
  41011. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41012. * @param ray defines the ray to test with
  41013. * @param selection defines the array to store current content if selection is positive
  41014. */
  41015. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41016. /**
  41017. * Subdivide the content into child blocks (this block will then be empty)
  41018. */
  41019. createInnerBlocks(): void;
  41020. /**
  41021. * @hidden
  41022. */
  41023. 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;
  41024. }
  41025. }
  41026. declare module "babylonjs/Culling/Octrees/octree" {
  41027. import { SmartArray } from "babylonjs/Misc/smartArray";
  41028. import { Vector3, Plane } from "babylonjs/Maths/math";
  41029. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41031. import { Ray } from "babylonjs/Culling/ray";
  41032. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41033. /**
  41034. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41035. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41036. */
  41037. export class Octree<T> {
  41038. /** 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.) */
  41039. maxDepth: number;
  41040. /**
  41041. * Blocks within the octree containing objects
  41042. */
  41043. blocks: Array<OctreeBlock<T>>;
  41044. /**
  41045. * Content stored in the octree
  41046. */
  41047. dynamicContent: T[];
  41048. private _maxBlockCapacity;
  41049. private _selectionContent;
  41050. private _creationFunc;
  41051. /**
  41052. * Creates a octree
  41053. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41054. * @param creationFunc function to be used to instatiate the octree
  41055. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41056. * @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.)
  41057. */
  41058. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41059. /** 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.) */
  41060. maxDepth?: number);
  41061. /**
  41062. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41063. * @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);
  41064. * @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);
  41065. * @param entries meshes to be added to the octree blocks
  41066. */
  41067. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41068. /**
  41069. * Adds a mesh to the octree
  41070. * @param entry Mesh to add to the octree
  41071. */
  41072. addMesh(entry: T): void;
  41073. /**
  41074. * Remove an element from the octree
  41075. * @param entry defines the element to remove
  41076. */
  41077. removeMesh(entry: T): void;
  41078. /**
  41079. * Selects an array of meshes within the frustum
  41080. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41081. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41082. * @returns array of meshes within the frustum
  41083. */
  41084. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41085. /**
  41086. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41087. * @param sphereCenter defines the bounding sphere center
  41088. * @param sphereRadius defines the bounding sphere radius
  41089. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41090. * @returns an array of objects that intersect the sphere
  41091. */
  41092. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41093. /**
  41094. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41095. * @param ray defines the ray to test with
  41096. * @returns array of intersected objects
  41097. */
  41098. intersectsRay(ray: Ray): SmartArray<T>;
  41099. /**
  41100. * Adds a mesh into the octree block if it intersects the block
  41101. */
  41102. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41103. /**
  41104. * Adds a submesh into the octree block if it intersects the block
  41105. */
  41106. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41107. }
  41108. }
  41109. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41110. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41111. import { Scene } from "babylonjs/scene";
  41112. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41114. import { Collider } from "babylonjs/Collisions/collider";
  41115. import { Ray } from "babylonjs/Culling/ray";
  41116. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41117. module "babylonjs/scene" {
  41118. interface Scene {
  41119. /**
  41120. * @hidden
  41121. * Backing Filed
  41122. */
  41123. _selectionOctree: Octree<AbstractMesh>;
  41124. /**
  41125. * Gets the octree used to boost mesh selection (picking)
  41126. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41127. */
  41128. selectionOctree: Octree<AbstractMesh>;
  41129. /**
  41130. * Creates or updates the octree used to boost selection (picking)
  41131. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41132. * @param maxCapacity defines the maximum capacity per leaf
  41133. * @param maxDepth defines the maximum depth of the octree
  41134. * @returns an octree of AbstractMesh
  41135. */
  41136. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41137. }
  41138. }
  41139. module "babylonjs/Meshes/abstractMesh" {
  41140. interface AbstractMesh {
  41141. /**
  41142. * @hidden
  41143. * Backing Field
  41144. */
  41145. _submeshesOctree: Octree<SubMesh>;
  41146. /**
  41147. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41148. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41149. * @param maxCapacity defines the maximum size of each block (64 by default)
  41150. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41151. * @returns the new octree
  41152. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41153. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41154. */
  41155. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41156. }
  41157. }
  41158. /**
  41159. * Defines the octree scene component responsible to manage any octrees
  41160. * in a given scene.
  41161. */
  41162. export class OctreeSceneComponent {
  41163. /**
  41164. * The component name helpfull to identify the component in the list of scene components.
  41165. */
  41166. readonly name: string;
  41167. /**
  41168. * The scene the component belongs to.
  41169. */
  41170. scene: Scene;
  41171. /**
  41172. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41173. */
  41174. readonly checksIsEnabled: boolean;
  41175. /**
  41176. * Creates a new instance of the component for the given scene
  41177. * @param scene Defines the scene to register the component in
  41178. */
  41179. constructor(scene: Scene);
  41180. /**
  41181. * Registers the component in a given scene
  41182. */
  41183. register(): void;
  41184. /**
  41185. * Return the list of active meshes
  41186. * @returns the list of active meshes
  41187. */
  41188. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41189. /**
  41190. * Return the list of active sub meshes
  41191. * @param mesh The mesh to get the candidates sub meshes from
  41192. * @returns the list of active sub meshes
  41193. */
  41194. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41195. private _tempRay;
  41196. /**
  41197. * Return the list of sub meshes intersecting with a given local ray
  41198. * @param mesh defines the mesh to find the submesh for
  41199. * @param localRay defines the ray in local space
  41200. * @returns the list of intersecting sub meshes
  41201. */
  41202. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41203. /**
  41204. * Return the list of sub meshes colliding with a collider
  41205. * @param mesh defines the mesh to find the submesh for
  41206. * @param collider defines the collider to evaluate the collision against
  41207. * @returns the list of colliding sub meshes
  41208. */
  41209. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41210. /**
  41211. * Rebuilds the elements related to this component in case of
  41212. * context lost for instance.
  41213. */
  41214. rebuild(): void;
  41215. /**
  41216. * Disposes the component and the associated ressources.
  41217. */
  41218. dispose(): void;
  41219. }
  41220. }
  41221. declare module "babylonjs/Culling/Octrees/index" {
  41222. export * from "babylonjs/Culling/Octrees/octree";
  41223. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41224. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41225. }
  41226. declare module "babylonjs/Culling/index" {
  41227. export * from "babylonjs/Culling/boundingBox";
  41228. export * from "babylonjs/Culling/boundingInfo";
  41229. export * from "babylonjs/Culling/boundingSphere";
  41230. export * from "babylonjs/Culling/Octrees/index";
  41231. export * from "babylonjs/Culling/ray";
  41232. }
  41233. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41234. import { IDisposable, Scene } from "babylonjs/scene";
  41235. import { Nullable } from "babylonjs/types";
  41236. import { Observable } from "babylonjs/Misc/observable";
  41237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41238. /**
  41239. * Renders a layer on top of an existing scene
  41240. */
  41241. export class UtilityLayerRenderer implements IDisposable {
  41242. /** the original scene that will be rendered on top of */
  41243. originalScene: Scene;
  41244. private _pointerCaptures;
  41245. private _lastPointerEvents;
  41246. private static _DefaultUtilityLayer;
  41247. private static _DefaultKeepDepthUtilityLayer;
  41248. /**
  41249. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41250. */
  41251. pickUtilitySceneFirst: boolean;
  41252. /**
  41253. * 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)
  41254. */
  41255. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41256. /**
  41257. * 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)
  41258. */
  41259. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41260. /**
  41261. * The scene that is rendered on top of the original scene
  41262. */
  41263. utilityLayerScene: Scene;
  41264. /**
  41265. * If the utility layer should automatically be rendered on top of existing scene
  41266. */
  41267. shouldRender: boolean;
  41268. /**
  41269. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41270. */
  41271. onlyCheckPointerDownEvents: boolean;
  41272. /**
  41273. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41274. */
  41275. processAllEvents: boolean;
  41276. /**
  41277. * Observable raised when the pointer move from the utility layer scene to the main scene
  41278. */
  41279. onPointerOutObservable: Observable<number>;
  41280. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41281. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41282. private _afterRenderObserver;
  41283. private _sceneDisposeObserver;
  41284. private _originalPointerObserver;
  41285. /**
  41286. * Instantiates a UtilityLayerRenderer
  41287. * @param originalScene the original scene that will be rendered on top of
  41288. * @param handleEvents boolean indicating if the utility layer should handle events
  41289. */
  41290. constructor(
  41291. /** the original scene that will be rendered on top of */
  41292. originalScene: Scene, handleEvents?: boolean);
  41293. private _notifyObservers;
  41294. /**
  41295. * Renders the utility layers scene on top of the original scene
  41296. */
  41297. render(): void;
  41298. /**
  41299. * Disposes of the renderer
  41300. */
  41301. dispose(): void;
  41302. private _updateCamera;
  41303. }
  41304. }
  41305. declare module "babylonjs/Gizmos/gizmo" {
  41306. import { Nullable } from "babylonjs/types";
  41307. import { IDisposable } from "babylonjs/scene";
  41308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41309. import { Mesh } from "babylonjs/Meshes/mesh";
  41310. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41311. /**
  41312. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41313. */
  41314. export class Gizmo implements IDisposable {
  41315. /** The utility layer the gizmo will be added to */
  41316. gizmoLayer: UtilityLayerRenderer;
  41317. /**
  41318. * The root mesh of the gizmo
  41319. */
  41320. protected _rootMesh: Mesh;
  41321. private _attachedMesh;
  41322. /**
  41323. * Ratio for the scale of the gizmo (Default: 1)
  41324. */
  41325. scaleRatio: number;
  41326. private _tmpMatrix;
  41327. /**
  41328. * If a custom mesh has been set (Default: false)
  41329. */
  41330. protected _customMeshSet: boolean;
  41331. /**
  41332. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41333. * * When set, interactions will be enabled
  41334. */
  41335. attachedMesh: Nullable<AbstractMesh>;
  41336. /**
  41337. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41338. * @param mesh The mesh to replace the default mesh of the gizmo
  41339. */
  41340. setCustomMesh(mesh: Mesh): void;
  41341. /**
  41342. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41343. */
  41344. updateGizmoRotationToMatchAttachedMesh: boolean;
  41345. /**
  41346. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41347. */
  41348. updateGizmoPositionToMatchAttachedMesh: boolean;
  41349. /**
  41350. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41351. */
  41352. protected _updateScale: boolean;
  41353. protected _interactionsEnabled: boolean;
  41354. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41355. private _beforeRenderObserver;
  41356. /**
  41357. * Creates a gizmo
  41358. * @param gizmoLayer The utility layer the gizmo will be added to
  41359. */
  41360. constructor(
  41361. /** The utility layer the gizmo will be added to */
  41362. gizmoLayer?: UtilityLayerRenderer);
  41363. private _tempVector;
  41364. /**
  41365. * @hidden
  41366. * Updates the gizmo to match the attached mesh's position/rotation
  41367. */
  41368. protected _update(): void;
  41369. /**
  41370. * Disposes of the gizmo
  41371. */
  41372. dispose(): void;
  41373. }
  41374. }
  41375. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41376. import { Observable } from "babylonjs/Misc/observable";
  41377. import { Nullable } from "babylonjs/types";
  41378. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41379. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41381. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41382. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41383. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41384. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41385. import { Scene } from "babylonjs/scene";
  41386. /**
  41387. * Single axis drag gizmo
  41388. */
  41389. export class AxisDragGizmo extends Gizmo {
  41390. /**
  41391. * Drag behavior responsible for the gizmos dragging interactions
  41392. */
  41393. dragBehavior: PointerDragBehavior;
  41394. private _pointerObserver;
  41395. /**
  41396. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41397. */
  41398. snapDistance: number;
  41399. /**
  41400. * Event that fires each time the gizmo snaps to a new location.
  41401. * * snapDistance is the the change in distance
  41402. */
  41403. onSnapObservable: Observable<{
  41404. snapDistance: number;
  41405. }>;
  41406. /** @hidden */
  41407. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41408. /** @hidden */
  41409. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41410. /**
  41411. * Creates an AxisDragGizmo
  41412. * @param gizmoLayer The utility layer the gizmo will be added to
  41413. * @param dragAxis The axis which the gizmo will be able to drag on
  41414. * @param color The color of the gizmo
  41415. */
  41416. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41417. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41418. /**
  41419. * Disposes of the gizmo
  41420. */
  41421. dispose(): void;
  41422. }
  41423. }
  41424. declare module "babylonjs/Debug/axesViewer" {
  41425. import { Vector3 } from "babylonjs/Maths/math";
  41426. import { Nullable } from "babylonjs/types";
  41427. import { Scene } from "babylonjs/scene";
  41428. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41429. /**
  41430. * The Axes viewer will show 3 axes in a specific point in space
  41431. */
  41432. export class AxesViewer {
  41433. private _xAxis;
  41434. private _yAxis;
  41435. private _zAxis;
  41436. private _scaleLinesFactor;
  41437. private _instanced;
  41438. /**
  41439. * Gets the hosting scene
  41440. */
  41441. scene: Scene;
  41442. /**
  41443. * Gets or sets a number used to scale line length
  41444. */
  41445. scaleLines: number;
  41446. /** Gets the node hierarchy used to render x-axis */
  41447. readonly xAxis: TransformNode;
  41448. /** Gets the node hierarchy used to render y-axis */
  41449. readonly yAxis: TransformNode;
  41450. /** Gets the node hierarchy used to render z-axis */
  41451. readonly zAxis: TransformNode;
  41452. /**
  41453. * Creates a new AxesViewer
  41454. * @param scene defines the hosting scene
  41455. * @param scaleLines defines a number used to scale line length (1 by default)
  41456. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41457. * @param xAxis defines the node hierarchy used to render the x-axis
  41458. * @param yAxis defines the node hierarchy used to render the y-axis
  41459. * @param zAxis defines the node hierarchy used to render the z-axis
  41460. */
  41461. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41462. /**
  41463. * Force the viewer to update
  41464. * @param position defines the position of the viewer
  41465. * @param xaxis defines the x axis of the viewer
  41466. * @param yaxis defines the y axis of the viewer
  41467. * @param zaxis defines the z axis of the viewer
  41468. */
  41469. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41470. /**
  41471. * Creates an instance of this axes viewer.
  41472. * @returns a new axes viewer with instanced meshes
  41473. */
  41474. createInstance(): AxesViewer;
  41475. /** Releases resources */
  41476. dispose(): void;
  41477. private static _SetRenderingGroupId;
  41478. }
  41479. }
  41480. declare module "babylonjs/Debug/boneAxesViewer" {
  41481. import { Nullable } from "babylonjs/types";
  41482. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41483. import { Vector3 } from "babylonjs/Maths/math";
  41484. import { Mesh } from "babylonjs/Meshes/mesh";
  41485. import { Bone } from "babylonjs/Bones/bone";
  41486. import { Scene } from "babylonjs/scene";
  41487. /**
  41488. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41489. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41490. */
  41491. export class BoneAxesViewer extends AxesViewer {
  41492. /**
  41493. * Gets or sets the target mesh where to display the axes viewer
  41494. */
  41495. mesh: Nullable<Mesh>;
  41496. /**
  41497. * Gets or sets the target bone where to display the axes viewer
  41498. */
  41499. bone: Nullable<Bone>;
  41500. /** Gets current position */
  41501. pos: Vector3;
  41502. /** Gets direction of X axis */
  41503. xaxis: Vector3;
  41504. /** Gets direction of Y axis */
  41505. yaxis: Vector3;
  41506. /** Gets direction of Z axis */
  41507. zaxis: Vector3;
  41508. /**
  41509. * Creates a new BoneAxesViewer
  41510. * @param scene defines the hosting scene
  41511. * @param bone defines the target bone
  41512. * @param mesh defines the target mesh
  41513. * @param scaleLines defines a scaling factor for line length (1 by default)
  41514. */
  41515. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41516. /**
  41517. * Force the viewer to update
  41518. */
  41519. update(): void;
  41520. /** Releases resources */
  41521. dispose(): void;
  41522. }
  41523. }
  41524. declare module "babylonjs/Debug/debugLayer" {
  41525. import { Observable } from "babylonjs/Misc/observable";
  41526. import { Scene } from "babylonjs/scene";
  41527. /**
  41528. * Interface used to define scene explorer extensibility option
  41529. */
  41530. export interface IExplorerExtensibilityOption {
  41531. /**
  41532. * Define the option label
  41533. */
  41534. label: string;
  41535. /**
  41536. * Defines the action to execute on click
  41537. */
  41538. action: (entity: any) => void;
  41539. }
  41540. /**
  41541. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41542. */
  41543. export interface IExplorerExtensibilityGroup {
  41544. /**
  41545. * Defines a predicate to test if a given type mut be extended
  41546. */
  41547. predicate: (entity: any) => boolean;
  41548. /**
  41549. * Gets the list of options added to a type
  41550. */
  41551. entries: IExplorerExtensibilityOption[];
  41552. }
  41553. /**
  41554. * Interface used to define the options to use to create the Inspector
  41555. */
  41556. export interface IInspectorOptions {
  41557. /**
  41558. * Display in overlay mode (default: false)
  41559. */
  41560. overlay?: boolean;
  41561. /**
  41562. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41563. */
  41564. globalRoot?: HTMLElement;
  41565. /**
  41566. * Display the Scene explorer
  41567. */
  41568. showExplorer?: boolean;
  41569. /**
  41570. * Display the property inspector
  41571. */
  41572. showInspector?: boolean;
  41573. /**
  41574. * Display in embed mode (both panes on the right)
  41575. */
  41576. embedMode?: boolean;
  41577. /**
  41578. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41579. */
  41580. handleResize?: boolean;
  41581. /**
  41582. * Allow the panes to popup (default: true)
  41583. */
  41584. enablePopup?: boolean;
  41585. /**
  41586. * Allow the panes to be closed by users (default: true)
  41587. */
  41588. enableClose?: boolean;
  41589. /**
  41590. * Optional list of extensibility entries
  41591. */
  41592. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41593. }
  41594. module "babylonjs/scene" {
  41595. interface Scene {
  41596. /**
  41597. * @hidden
  41598. * Backing field
  41599. */
  41600. _debugLayer: DebugLayer;
  41601. /**
  41602. * Gets the debug layer (aka Inspector) associated with the scene
  41603. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41604. */
  41605. debugLayer: DebugLayer;
  41606. }
  41607. }
  41608. /**
  41609. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41610. * what is happening in your scene
  41611. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41612. */
  41613. export class DebugLayer {
  41614. /**
  41615. * Define the url to get the inspector script from.
  41616. * By default it uses the babylonjs CDN.
  41617. * @ignoreNaming
  41618. */
  41619. static InspectorURL: string;
  41620. private _scene;
  41621. private BJSINSPECTOR;
  41622. /**
  41623. * Observable triggered when a property is changed through the inspector.
  41624. */
  41625. onPropertyChangedObservable: Observable<{
  41626. object: any;
  41627. property: string;
  41628. value: any;
  41629. initialValue: any;
  41630. }>;
  41631. /**
  41632. * Instantiates a new debug layer.
  41633. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41634. * what is happening in your scene
  41635. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41636. * @param scene Defines the scene to inspect
  41637. */
  41638. constructor(scene: Scene);
  41639. /** Creates the inspector window. */
  41640. private _createInspector;
  41641. /** Get the inspector from bundle or global */
  41642. private _getGlobalInspector;
  41643. /**
  41644. * Get if the inspector is visible or not.
  41645. * @returns true if visible otherwise, false
  41646. */
  41647. isVisible(): boolean;
  41648. /**
  41649. * Hide the inspector and close its window.
  41650. */
  41651. hide(): void;
  41652. /**
  41653. * Launch the debugLayer.
  41654. * @param config Define the configuration of the inspector
  41655. */
  41656. show(config?: IInspectorOptions): void;
  41657. }
  41658. }
  41659. declare module "babylonjs/Debug/physicsViewer" {
  41660. import { Nullable } from "babylonjs/types";
  41661. import { Scene } from "babylonjs/scene";
  41662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41663. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41664. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41665. /**
  41666. * Used to show the physics impostor around the specific mesh
  41667. */
  41668. export class PhysicsViewer {
  41669. /** @hidden */
  41670. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41671. /** @hidden */
  41672. protected _meshes: Array<Nullable<AbstractMesh>>;
  41673. /** @hidden */
  41674. protected _scene: Nullable<Scene>;
  41675. /** @hidden */
  41676. protected _numMeshes: number;
  41677. /** @hidden */
  41678. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41679. private _renderFunction;
  41680. private _utilityLayer;
  41681. private _debugBoxMesh;
  41682. private _debugSphereMesh;
  41683. private _debugMaterial;
  41684. /**
  41685. * Creates a new PhysicsViewer
  41686. * @param scene defines the hosting scene
  41687. */
  41688. constructor(scene: Scene);
  41689. /** @hidden */
  41690. protected _updateDebugMeshes(): void;
  41691. /**
  41692. * Renders a specified physic impostor
  41693. * @param impostor defines the impostor to render
  41694. * @returns the new debug mesh used to render the impostor
  41695. */
  41696. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41697. /**
  41698. * Hides a specified physic impostor
  41699. * @param impostor defines the impostor to hide
  41700. */
  41701. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41702. private _getDebugMaterial;
  41703. private _getDebugBoxMesh;
  41704. private _getDebugSphereMesh;
  41705. private _getDebugMesh;
  41706. /** Releases all resources */
  41707. dispose(): void;
  41708. }
  41709. }
  41710. declare module "babylonjs/Debug/rayHelper" {
  41711. import { Nullable } from "babylonjs/types";
  41712. import { Ray } from "babylonjs/Culling/ray";
  41713. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41714. import { Scene } from "babylonjs/scene";
  41715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41716. /**
  41717. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41718. * in order to better appreciate the issue one might have.
  41719. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41720. */
  41721. export class RayHelper {
  41722. /**
  41723. * Defines the ray we are currently tryin to visualize.
  41724. */
  41725. ray: Nullable<Ray>;
  41726. private _renderPoints;
  41727. private _renderLine;
  41728. private _renderFunction;
  41729. private _scene;
  41730. private _updateToMeshFunction;
  41731. private _attachedToMesh;
  41732. private _meshSpaceDirection;
  41733. private _meshSpaceOrigin;
  41734. /**
  41735. * Helper function to create a colored helper in a scene in one line.
  41736. * @param ray Defines the ray we are currently tryin to visualize
  41737. * @param scene Defines the scene the ray is used in
  41738. * @param color Defines the color we want to see the ray in
  41739. * @returns The newly created ray helper.
  41740. */
  41741. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41742. /**
  41743. * Instantiate a new ray helper.
  41744. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41745. * in order to better appreciate the issue one might have.
  41746. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41747. * @param ray Defines the ray we are currently tryin to visualize
  41748. */
  41749. constructor(ray: Ray);
  41750. /**
  41751. * Shows the ray we are willing to debug.
  41752. * @param scene Defines the scene the ray needs to be rendered in
  41753. * @param color Defines the color the ray needs to be rendered in
  41754. */
  41755. show(scene: Scene, color?: Color3): void;
  41756. /**
  41757. * Hides the ray we are debugging.
  41758. */
  41759. hide(): void;
  41760. private _render;
  41761. /**
  41762. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41763. * @param mesh Defines the mesh we want the helper attached to
  41764. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41765. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41766. * @param length Defines the length of the ray
  41767. */
  41768. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41769. /**
  41770. * Detach the ray helper from the mesh it has previously been attached to.
  41771. */
  41772. detachFromMesh(): void;
  41773. private _updateToMesh;
  41774. /**
  41775. * Dispose the helper and release its associated resources.
  41776. */
  41777. dispose(): void;
  41778. }
  41779. }
  41780. declare module "babylonjs/Debug/skeletonViewer" {
  41781. import { Color3 } from "babylonjs/Maths/math";
  41782. import { Scene } from "babylonjs/scene";
  41783. import { Nullable } from "babylonjs/types";
  41784. import { Skeleton } from "babylonjs/Bones/skeleton";
  41785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41786. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41787. /**
  41788. * Class used to render a debug view of a given skeleton
  41789. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41790. */
  41791. export class SkeletonViewer {
  41792. /** defines the skeleton to render */
  41793. skeleton: Skeleton;
  41794. /** defines the mesh attached to the skeleton */
  41795. mesh: AbstractMesh;
  41796. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41797. autoUpdateBonesMatrices: boolean;
  41798. /** defines the rendering group id to use with the viewer */
  41799. renderingGroupId: number;
  41800. /** Gets or sets the color used to render the skeleton */
  41801. color: Color3;
  41802. private _scene;
  41803. private _debugLines;
  41804. private _debugMesh;
  41805. private _isEnabled;
  41806. private _renderFunction;
  41807. private _utilityLayer;
  41808. /**
  41809. * Returns the mesh used to render the bones
  41810. */
  41811. readonly debugMesh: Nullable<LinesMesh>;
  41812. /**
  41813. * Creates a new SkeletonViewer
  41814. * @param skeleton defines the skeleton to render
  41815. * @param mesh defines the mesh attached to the skeleton
  41816. * @param scene defines the hosting scene
  41817. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41818. * @param renderingGroupId defines the rendering group id to use with the viewer
  41819. */
  41820. constructor(
  41821. /** defines the skeleton to render */
  41822. skeleton: Skeleton,
  41823. /** defines the mesh attached to the skeleton */
  41824. mesh: AbstractMesh, scene: Scene,
  41825. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41826. autoUpdateBonesMatrices?: boolean,
  41827. /** defines the rendering group id to use with the viewer */
  41828. renderingGroupId?: number);
  41829. /** Gets or sets a boolean indicating if the viewer is enabled */
  41830. isEnabled: boolean;
  41831. private _getBonePosition;
  41832. private _getLinesForBonesWithLength;
  41833. private _getLinesForBonesNoLength;
  41834. /** Update the viewer to sync with current skeleton state */
  41835. update(): void;
  41836. /** Release associated resources */
  41837. dispose(): void;
  41838. }
  41839. }
  41840. declare module "babylonjs/Debug/index" {
  41841. export * from "babylonjs/Debug/axesViewer";
  41842. export * from "babylonjs/Debug/boneAxesViewer";
  41843. export * from "babylonjs/Debug/debugLayer";
  41844. export * from "babylonjs/Debug/physicsViewer";
  41845. export * from "babylonjs/Debug/rayHelper";
  41846. export * from "babylonjs/Debug/skeletonViewer";
  41847. }
  41848. declare module "babylonjs/Engines/nullEngine" {
  41849. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41850. import { Scene } from "babylonjs/scene";
  41851. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41852. import { Engine } from "babylonjs/Engines/engine";
  41853. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41854. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41855. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41856. import { Effect } from "babylonjs/Materials/effect";
  41857. /**
  41858. * Options to create the null engine
  41859. */
  41860. export class NullEngineOptions {
  41861. /**
  41862. * Render width (Default: 512)
  41863. */
  41864. renderWidth: number;
  41865. /**
  41866. * Render height (Default: 256)
  41867. */
  41868. renderHeight: number;
  41869. /**
  41870. * Texture size (Default: 512)
  41871. */
  41872. textureSize: number;
  41873. /**
  41874. * If delta time between frames should be constant
  41875. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41876. */
  41877. deterministicLockstep: boolean;
  41878. /**
  41879. * Maximum about of steps between frames (Default: 4)
  41880. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41881. */
  41882. lockstepMaxSteps: number;
  41883. }
  41884. /**
  41885. * The null engine class provides support for headless version of babylon.js.
  41886. * This can be used in server side scenario or for testing purposes
  41887. */
  41888. export class NullEngine extends Engine {
  41889. private _options;
  41890. /**
  41891. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41892. */
  41893. isDeterministicLockStep(): boolean;
  41894. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41895. getLockstepMaxSteps(): number;
  41896. /**
  41897. * Sets hardware scaling, used to save performance if needed
  41898. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41899. */
  41900. getHardwareScalingLevel(): number;
  41901. constructor(options?: NullEngineOptions);
  41902. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41903. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41904. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41905. getRenderWidth(useScreen?: boolean): number;
  41906. getRenderHeight(useScreen?: boolean): number;
  41907. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41908. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41909. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41910. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41911. bindSamplers(effect: Effect): void;
  41912. enableEffect(effect: Effect): void;
  41913. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41914. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41915. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41916. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41917. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41918. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41919. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41920. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41921. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41922. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41923. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41924. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41925. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41926. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41927. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41928. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41929. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41930. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41931. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41932. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41933. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41934. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41935. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41936. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41937. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41938. bindBuffers(vertexBuffers: {
  41939. [key: string]: VertexBuffer;
  41940. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41941. wipeCaches(bruteForce?: boolean): void;
  41942. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41943. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41944. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41945. /** @hidden */
  41946. _createTexture(): WebGLTexture;
  41947. /** @hidden */
  41948. _releaseTexture(texture: InternalTexture): void;
  41949. 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;
  41950. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41951. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41952. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41953. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41954. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41955. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41956. areAllEffectsReady(): boolean;
  41957. /**
  41958. * @hidden
  41959. * Get the current error code of the webGL context
  41960. * @returns the error code
  41961. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41962. */
  41963. getError(): number;
  41964. /** @hidden */
  41965. _getUnpackAlignement(): number;
  41966. /** @hidden */
  41967. _unpackFlipY(value: boolean): void;
  41968. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41969. /**
  41970. * Updates a dynamic vertex buffer.
  41971. * @param vertexBuffer the vertex buffer to update
  41972. * @param data the data used to update the vertex buffer
  41973. * @param byteOffset the byte offset of the data (optional)
  41974. * @param byteLength the byte length of the data (optional)
  41975. */
  41976. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41977. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41978. /** @hidden */
  41979. _bindTexture(channel: number, texture: InternalTexture): void;
  41980. /** @hidden */
  41981. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41982. releaseEffects(): void;
  41983. displayLoadingUI(): void;
  41984. hideLoadingUI(): void;
  41985. /** @hidden */
  41986. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41987. /** @hidden */
  41988. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41989. /** @hidden */
  41990. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41991. /** @hidden */
  41992. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41993. }
  41994. }
  41995. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41996. import { Nullable, int } from "babylonjs/types";
  41997. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41998. /** @hidden */
  41999. export class _OcclusionDataStorage {
  42000. /** @hidden */
  42001. occlusionInternalRetryCounter: number;
  42002. /** @hidden */
  42003. isOcclusionQueryInProgress: boolean;
  42004. /** @hidden */
  42005. isOccluded: boolean;
  42006. /** @hidden */
  42007. occlusionRetryCount: number;
  42008. /** @hidden */
  42009. occlusionType: number;
  42010. /** @hidden */
  42011. occlusionQueryAlgorithmType: number;
  42012. }
  42013. module "babylonjs/Engines/engine" {
  42014. interface Engine {
  42015. /**
  42016. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42017. * @return the new query
  42018. */
  42019. createQuery(): WebGLQuery;
  42020. /**
  42021. * Delete and release a webGL query
  42022. * @param query defines the query to delete
  42023. * @return the current engine
  42024. */
  42025. deleteQuery(query: WebGLQuery): Engine;
  42026. /**
  42027. * Check if a given query has resolved and got its value
  42028. * @param query defines the query to check
  42029. * @returns true if the query got its value
  42030. */
  42031. isQueryResultAvailable(query: WebGLQuery): boolean;
  42032. /**
  42033. * Gets the value of a given query
  42034. * @param query defines the query to check
  42035. * @returns the value of the query
  42036. */
  42037. getQueryResult(query: WebGLQuery): number;
  42038. /**
  42039. * Initiates an occlusion query
  42040. * @param algorithmType defines the algorithm to use
  42041. * @param query defines the query to use
  42042. * @returns the current engine
  42043. * @see http://doc.babylonjs.com/features/occlusionquery
  42044. */
  42045. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42046. /**
  42047. * Ends an occlusion query
  42048. * @see http://doc.babylonjs.com/features/occlusionquery
  42049. * @param algorithmType defines the algorithm to use
  42050. * @returns the current engine
  42051. */
  42052. endOcclusionQuery(algorithmType: number): Engine;
  42053. /**
  42054. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42055. * Please note that only one query can be issued at a time
  42056. * @returns a time token used to track the time span
  42057. */
  42058. startTimeQuery(): Nullable<_TimeToken>;
  42059. /**
  42060. * Ends a time query
  42061. * @param token defines the token used to measure the time span
  42062. * @returns the time spent (in ns)
  42063. */
  42064. endTimeQuery(token: _TimeToken): int;
  42065. /** @hidden */
  42066. _currentNonTimestampToken: Nullable<_TimeToken>;
  42067. /** @hidden */
  42068. _createTimeQuery(): WebGLQuery;
  42069. /** @hidden */
  42070. _deleteTimeQuery(query: WebGLQuery): void;
  42071. /** @hidden */
  42072. _getGlAlgorithmType(algorithmType: number): number;
  42073. /** @hidden */
  42074. _getTimeQueryResult(query: WebGLQuery): any;
  42075. /** @hidden */
  42076. _getTimeQueryAvailability(query: WebGLQuery): any;
  42077. }
  42078. }
  42079. module "babylonjs/Meshes/abstractMesh" {
  42080. interface AbstractMesh {
  42081. /**
  42082. * Backing filed
  42083. * @hidden
  42084. */
  42085. __occlusionDataStorage: _OcclusionDataStorage;
  42086. /**
  42087. * Access property
  42088. * @hidden
  42089. */
  42090. _occlusionDataStorage: _OcclusionDataStorage;
  42091. /**
  42092. * 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.
  42093. * The default value is -1 which means don't break the query and wait till the result
  42094. * @see http://doc.babylonjs.com/features/occlusionquery
  42095. */
  42096. occlusionRetryCount: number;
  42097. /**
  42098. * 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:
  42099. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42100. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42101. * * 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.
  42102. * @see http://doc.babylonjs.com/features/occlusionquery
  42103. */
  42104. occlusionType: number;
  42105. /**
  42106. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42107. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42108. * * 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.
  42109. * @see http://doc.babylonjs.com/features/occlusionquery
  42110. */
  42111. occlusionQueryAlgorithmType: number;
  42112. /**
  42113. * 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
  42114. * @see http://doc.babylonjs.com/features/occlusionquery
  42115. */
  42116. isOccluded: boolean;
  42117. /**
  42118. * Flag to check the progress status of the query
  42119. * @see http://doc.babylonjs.com/features/occlusionquery
  42120. */
  42121. isOcclusionQueryInProgress: boolean;
  42122. }
  42123. }
  42124. }
  42125. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42126. import { Nullable } from "babylonjs/types";
  42127. /** @hidden */
  42128. export var _forceTransformFeedbackToBundle: boolean;
  42129. module "babylonjs/Engines/engine" {
  42130. interface Engine {
  42131. /**
  42132. * Creates a webGL transform feedback object
  42133. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42134. * @returns the webGL transform feedback object
  42135. */
  42136. createTransformFeedback(): WebGLTransformFeedback;
  42137. /**
  42138. * Delete a webGL transform feedback object
  42139. * @param value defines the webGL transform feedback object to delete
  42140. */
  42141. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42142. /**
  42143. * Bind a webGL transform feedback object to the webgl context
  42144. * @param value defines the webGL transform feedback object to bind
  42145. */
  42146. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42147. /**
  42148. * Begins a transform feedback operation
  42149. * @param usePoints defines if points or triangles must be used
  42150. */
  42151. beginTransformFeedback(usePoints: boolean): void;
  42152. /**
  42153. * Ends a transform feedback operation
  42154. */
  42155. endTransformFeedback(): void;
  42156. /**
  42157. * Specify the varyings to use with transform feedback
  42158. * @param program defines the associated webGL program
  42159. * @param value defines the list of strings representing the varying names
  42160. */
  42161. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42162. /**
  42163. * Bind a webGL buffer for a transform feedback operation
  42164. * @param value defines the webGL buffer to bind
  42165. */
  42166. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42167. }
  42168. }
  42169. }
  42170. declare module "babylonjs/Engines/Extensions/index" {
  42171. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42172. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42173. }
  42174. declare module "babylonjs/Engines/index" {
  42175. export * from "babylonjs/Engines/constants";
  42176. export * from "babylonjs/Engines/engine";
  42177. export * from "babylonjs/Engines/engineStore";
  42178. export * from "babylonjs/Engines/nullEngine";
  42179. export * from "babylonjs/Engines/Extensions/index";
  42180. }
  42181. declare module "babylonjs/Events/clipboardEvents" {
  42182. /**
  42183. * Gather the list of clipboard event types as constants.
  42184. */
  42185. export class ClipboardEventTypes {
  42186. /**
  42187. * The clipboard event is fired when a copy command is active (pressed).
  42188. */
  42189. static readonly COPY: number;
  42190. /**
  42191. * The clipboard event is fired when a cut command is active (pressed).
  42192. */
  42193. static readonly CUT: number;
  42194. /**
  42195. * The clipboard event is fired when a paste command is active (pressed).
  42196. */
  42197. static readonly PASTE: number;
  42198. }
  42199. /**
  42200. * This class is used to store clipboard related info for the onClipboardObservable event.
  42201. */
  42202. export class ClipboardInfo {
  42203. /**
  42204. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42205. */
  42206. type: number;
  42207. /**
  42208. * Defines the related dom event
  42209. */
  42210. event: ClipboardEvent;
  42211. /**
  42212. *Creates an instance of ClipboardInfo.
  42213. * @param {number} type
  42214. * @param {ClipboardEvent} event
  42215. */
  42216. constructor(
  42217. /**
  42218. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42219. */
  42220. type: number,
  42221. /**
  42222. * Defines the related dom event
  42223. */
  42224. event: ClipboardEvent);
  42225. /**
  42226. * Get the clipboard event's type from the keycode.
  42227. * @param keyCode Defines the keyCode for the current keyboard event.
  42228. * @return {number}
  42229. */
  42230. static GetTypeFromCharacter(keyCode: number): number;
  42231. }
  42232. }
  42233. declare module "babylonjs/Events/index" {
  42234. export * from "babylonjs/Events/keyboardEvents";
  42235. export * from "babylonjs/Events/pointerEvents";
  42236. export * from "babylonjs/Events/clipboardEvents";
  42237. }
  42238. declare module "babylonjs/Loading/sceneLoader" {
  42239. import { Observable } from "babylonjs/Misc/observable";
  42240. import { Nullable } from "babylonjs/types";
  42241. import { Scene } from "babylonjs/scene";
  42242. import { Engine } from "babylonjs/Engines/engine";
  42243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42244. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42245. import { AssetContainer } from "babylonjs/assetContainer";
  42246. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42247. import { Skeleton } from "babylonjs/Bones/skeleton";
  42248. /**
  42249. * Class used to represent data loading progression
  42250. */
  42251. export class SceneLoaderProgressEvent {
  42252. /** defines if data length to load can be evaluated */
  42253. readonly lengthComputable: boolean;
  42254. /** defines the loaded data length */
  42255. readonly loaded: number;
  42256. /** defines the data length to load */
  42257. readonly total: number;
  42258. /**
  42259. * Create a new progress event
  42260. * @param lengthComputable defines if data length to load can be evaluated
  42261. * @param loaded defines the loaded data length
  42262. * @param total defines the data length to load
  42263. */
  42264. constructor(
  42265. /** defines if data length to load can be evaluated */
  42266. lengthComputable: boolean,
  42267. /** defines the loaded data length */
  42268. loaded: number,
  42269. /** defines the data length to load */
  42270. total: number);
  42271. /**
  42272. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42273. * @param event defines the source event
  42274. * @returns a new SceneLoaderProgressEvent
  42275. */
  42276. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42277. }
  42278. /**
  42279. * Interface used by SceneLoader plugins to define supported file extensions
  42280. */
  42281. export interface ISceneLoaderPluginExtensions {
  42282. /**
  42283. * Defines the list of supported extensions
  42284. */
  42285. [extension: string]: {
  42286. isBinary: boolean;
  42287. };
  42288. }
  42289. /**
  42290. * Interface used by SceneLoader plugin factory
  42291. */
  42292. export interface ISceneLoaderPluginFactory {
  42293. /**
  42294. * Defines the name of the factory
  42295. */
  42296. name: string;
  42297. /**
  42298. * Function called to create a new plugin
  42299. * @return the new plugin
  42300. */
  42301. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42302. /**
  42303. * Boolean indicating if the plugin can direct load specific data
  42304. */
  42305. canDirectLoad?: (data: string) => boolean;
  42306. }
  42307. /**
  42308. * Interface used to define a SceneLoader plugin
  42309. */
  42310. export interface ISceneLoaderPlugin {
  42311. /**
  42312. * The friendly name of this plugin.
  42313. */
  42314. name: string;
  42315. /**
  42316. * The file extensions supported by this plugin.
  42317. */
  42318. extensions: string | ISceneLoaderPluginExtensions;
  42319. /**
  42320. * Import meshes into a scene.
  42321. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42322. * @param scene The scene to import into
  42323. * @param data The data to import
  42324. * @param rootUrl The root url for scene and resources
  42325. * @param meshes The meshes array to import into
  42326. * @param particleSystems The particle systems array to import into
  42327. * @param skeletons The skeletons array to import into
  42328. * @param onError The callback when import fails
  42329. * @returns True if successful or false otherwise
  42330. */
  42331. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42332. /**
  42333. * Load into a scene.
  42334. * @param scene The scene to load into
  42335. * @param data The data to import
  42336. * @param rootUrl The root url for scene and resources
  42337. * @param onError The callback when import fails
  42338. * @returns true if successful or false otherwise
  42339. */
  42340. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42341. /**
  42342. * The callback that returns true if the data can be directly loaded.
  42343. */
  42344. canDirectLoad?: (data: string) => boolean;
  42345. /**
  42346. * The callback that allows custom handling of the root url based on the response url.
  42347. */
  42348. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42349. /**
  42350. * Load into an asset container.
  42351. * @param scene The scene to load into
  42352. * @param data The data to import
  42353. * @param rootUrl The root url for scene and resources
  42354. * @param onError The callback when import fails
  42355. * @returns The loaded asset container
  42356. */
  42357. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42358. }
  42359. /**
  42360. * Interface used to define an async SceneLoader plugin
  42361. */
  42362. export interface ISceneLoaderPluginAsync {
  42363. /**
  42364. * The friendly name of this plugin.
  42365. */
  42366. name: string;
  42367. /**
  42368. * The file extensions supported by this plugin.
  42369. */
  42370. extensions: string | ISceneLoaderPluginExtensions;
  42371. /**
  42372. * Import meshes into a scene.
  42373. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42374. * @param scene The scene to import into
  42375. * @param data The data to import
  42376. * @param rootUrl The root url for scene and resources
  42377. * @param onProgress The callback when the load progresses
  42378. * @param fileName Defines the name of the file to load
  42379. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42380. */
  42381. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42382. meshes: AbstractMesh[];
  42383. particleSystems: IParticleSystem[];
  42384. skeletons: Skeleton[];
  42385. animationGroups: AnimationGroup[];
  42386. }>;
  42387. /**
  42388. * Load into a scene.
  42389. * @param scene The scene to load into
  42390. * @param data The data to import
  42391. * @param rootUrl The root url for scene and resources
  42392. * @param onProgress The callback when the load progresses
  42393. * @param fileName Defines the name of the file to load
  42394. * @returns Nothing
  42395. */
  42396. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42397. /**
  42398. * The callback that returns true if the data can be directly loaded.
  42399. */
  42400. canDirectLoad?: (data: string) => boolean;
  42401. /**
  42402. * The callback that allows custom handling of the root url based on the response url.
  42403. */
  42404. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42405. /**
  42406. * Load into an asset container.
  42407. * @param scene The scene to load into
  42408. * @param data The data to import
  42409. * @param rootUrl The root url for scene and resources
  42410. * @param onProgress The callback when the load progresses
  42411. * @param fileName Defines the name of the file to load
  42412. * @returns The loaded asset container
  42413. */
  42414. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42415. }
  42416. /**
  42417. * Class used to load scene from various file formats using registered plugins
  42418. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42419. */
  42420. export class SceneLoader {
  42421. /**
  42422. * No logging while loading
  42423. */
  42424. static readonly NO_LOGGING: number;
  42425. /**
  42426. * Minimal logging while loading
  42427. */
  42428. static readonly MINIMAL_LOGGING: number;
  42429. /**
  42430. * Summary logging while loading
  42431. */
  42432. static readonly SUMMARY_LOGGING: number;
  42433. /**
  42434. * Detailled logging while loading
  42435. */
  42436. static readonly DETAILED_LOGGING: number;
  42437. /**
  42438. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42439. */
  42440. static ForceFullSceneLoadingForIncremental: boolean;
  42441. /**
  42442. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42443. */
  42444. static ShowLoadingScreen: boolean;
  42445. /**
  42446. * Defines the current logging level (while loading the scene)
  42447. * @ignorenaming
  42448. */
  42449. static loggingLevel: number;
  42450. /**
  42451. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42452. */
  42453. static CleanBoneMatrixWeights: boolean;
  42454. /**
  42455. * Event raised when a plugin is used to load a scene
  42456. */
  42457. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42458. private static _registeredPlugins;
  42459. private static _getDefaultPlugin;
  42460. private static _getPluginForExtension;
  42461. private static _getPluginForDirectLoad;
  42462. private static _getPluginForFilename;
  42463. private static _getDirectLoad;
  42464. private static _loadData;
  42465. private static _getFileInfo;
  42466. /**
  42467. * Gets a plugin that can load the given extension
  42468. * @param extension defines the extension to load
  42469. * @returns a plugin or null if none works
  42470. */
  42471. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42472. /**
  42473. * Gets a boolean indicating that the given extension can be loaded
  42474. * @param extension defines the extension to load
  42475. * @returns true if the extension is supported
  42476. */
  42477. static IsPluginForExtensionAvailable(extension: string): boolean;
  42478. /**
  42479. * Adds a new plugin to the list of registered plugins
  42480. * @param plugin defines the plugin to add
  42481. */
  42482. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42483. /**
  42484. * Import meshes into a scene
  42485. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42486. * @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)
  42487. * @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)
  42488. * @param scene the instance of BABYLON.Scene to append to
  42489. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42490. * @param onProgress a callback with a progress event for each file being loaded
  42491. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42492. * @param pluginExtension the extension used to determine the plugin
  42493. * @returns The loaded plugin
  42494. */
  42495. 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>;
  42496. /**
  42497. * Import meshes into a scene
  42498. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42499. * @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)
  42500. * @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)
  42501. * @param scene the instance of BABYLON.Scene to append to
  42502. * @param onProgress a callback with a progress event for each file being loaded
  42503. * @param pluginExtension the extension used to determine the plugin
  42504. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42505. */
  42506. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42507. meshes: AbstractMesh[];
  42508. particleSystems: IParticleSystem[];
  42509. skeletons: Skeleton[];
  42510. animationGroups: AnimationGroup[];
  42511. }>;
  42512. /**
  42513. * Load a scene
  42514. * @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)
  42515. * @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)
  42516. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42517. * @param onSuccess a callback with the scene when import succeeds
  42518. * @param onProgress a callback with a progress event for each file being loaded
  42519. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42520. * @param pluginExtension the extension used to determine the plugin
  42521. * @returns The loaded plugin
  42522. */
  42523. 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>;
  42524. /**
  42525. * Load a scene
  42526. * @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)
  42527. * @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)
  42528. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42529. * @param onProgress a callback with a progress event for each file being loaded
  42530. * @param pluginExtension the extension used to determine the plugin
  42531. * @returns The loaded scene
  42532. */
  42533. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42534. /**
  42535. * Append a scene
  42536. * @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)
  42537. * @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)
  42538. * @param scene is the instance of BABYLON.Scene to append to
  42539. * @param onSuccess a callback with the scene when import succeeds
  42540. * @param onProgress a callback with a progress event for each file being loaded
  42541. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42542. * @param pluginExtension the extension used to determine the plugin
  42543. * @returns The loaded plugin
  42544. */
  42545. 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>;
  42546. /**
  42547. * Append a scene
  42548. * @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)
  42549. * @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)
  42550. * @param scene is the instance of BABYLON.Scene to append to
  42551. * @param onProgress a callback with a progress event for each file being loaded
  42552. * @param pluginExtension the extension used to determine the plugin
  42553. * @returns The given scene
  42554. */
  42555. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42556. /**
  42557. * Load a scene into an asset container
  42558. * @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)
  42559. * @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)
  42560. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42561. * @param onSuccess a callback with the scene when import succeeds
  42562. * @param onProgress a callback with a progress event for each file being loaded
  42563. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42564. * @param pluginExtension the extension used to determine the plugin
  42565. * @returns The loaded plugin
  42566. */
  42567. 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>;
  42568. /**
  42569. * Load a scene into an asset container
  42570. * @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)
  42571. * @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)
  42572. * @param scene is the instance of Scene to append to
  42573. * @param onProgress a callback with a progress event for each file being loaded
  42574. * @param pluginExtension the extension used to determine the plugin
  42575. * @returns The loaded asset container
  42576. */
  42577. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42578. }
  42579. }
  42580. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42581. import { Scene } from "babylonjs/scene";
  42582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42583. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42584. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42585. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42586. /**
  42587. * Google Daydream controller
  42588. */
  42589. export class DaydreamController extends WebVRController {
  42590. /**
  42591. * Base Url for the controller model.
  42592. */
  42593. static MODEL_BASE_URL: string;
  42594. /**
  42595. * File name for the controller model.
  42596. */
  42597. static MODEL_FILENAME: string;
  42598. /**
  42599. * Gamepad Id prefix used to identify Daydream Controller.
  42600. */
  42601. static readonly GAMEPAD_ID_PREFIX: string;
  42602. /**
  42603. * Creates a new DaydreamController from a gamepad
  42604. * @param vrGamepad the gamepad that the controller should be created from
  42605. */
  42606. constructor(vrGamepad: any);
  42607. /**
  42608. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42609. * @param scene scene in which to add meshes
  42610. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42611. */
  42612. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42613. /**
  42614. * Called once for each button that changed state since the last frame
  42615. * @param buttonIdx Which button index changed
  42616. * @param state New state of the button
  42617. * @param changes Which properties on the state changed since last frame
  42618. */
  42619. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42620. }
  42621. }
  42622. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42623. import { Scene } from "babylonjs/scene";
  42624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42625. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42626. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42627. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42628. /**
  42629. * Gear VR Controller
  42630. */
  42631. export class GearVRController extends WebVRController {
  42632. /**
  42633. * Base Url for the controller model.
  42634. */
  42635. static MODEL_BASE_URL: string;
  42636. /**
  42637. * File name for the controller model.
  42638. */
  42639. static MODEL_FILENAME: string;
  42640. /**
  42641. * Gamepad Id prefix used to identify this controller.
  42642. */
  42643. static readonly GAMEPAD_ID_PREFIX: string;
  42644. private readonly _buttonIndexToObservableNameMap;
  42645. /**
  42646. * Creates a new GearVRController from a gamepad
  42647. * @param vrGamepad the gamepad that the controller should be created from
  42648. */
  42649. constructor(vrGamepad: any);
  42650. /**
  42651. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42652. * @param scene scene in which to add meshes
  42653. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42654. */
  42655. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42656. /**
  42657. * Called once for each button that changed state since the last frame
  42658. * @param buttonIdx Which button index changed
  42659. * @param state New state of the button
  42660. * @param changes Which properties on the state changed since last frame
  42661. */
  42662. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42663. }
  42664. }
  42665. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42666. import { Scene } from "babylonjs/scene";
  42667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42668. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42669. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42670. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42671. /**
  42672. * Generic Controller
  42673. */
  42674. export class GenericController extends WebVRController {
  42675. /**
  42676. * Base Url for the controller model.
  42677. */
  42678. static readonly MODEL_BASE_URL: string;
  42679. /**
  42680. * File name for the controller model.
  42681. */
  42682. static readonly MODEL_FILENAME: string;
  42683. /**
  42684. * Creates a new GenericController from a gamepad
  42685. * @param vrGamepad the gamepad that the controller should be created from
  42686. */
  42687. constructor(vrGamepad: any);
  42688. /**
  42689. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42690. * @param scene scene in which to add meshes
  42691. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42692. */
  42693. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42694. /**
  42695. * Called once for each button that changed state since the last frame
  42696. * @param buttonIdx Which button index changed
  42697. * @param state New state of the button
  42698. * @param changes Which properties on the state changed since last frame
  42699. */
  42700. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42701. }
  42702. }
  42703. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42704. import { Observable } from "babylonjs/Misc/observable";
  42705. import { Scene } from "babylonjs/scene";
  42706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42707. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42708. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42709. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42710. /**
  42711. * Oculus Touch Controller
  42712. */
  42713. export class OculusTouchController extends WebVRController {
  42714. /**
  42715. * Base Url for the controller model.
  42716. */
  42717. static MODEL_BASE_URL: string;
  42718. /**
  42719. * File name for the left controller model.
  42720. */
  42721. static MODEL_LEFT_FILENAME: string;
  42722. /**
  42723. * File name for the right controller model.
  42724. */
  42725. static MODEL_RIGHT_FILENAME: string;
  42726. /**
  42727. * Fired when the secondary trigger on this controller is modified
  42728. */
  42729. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42730. /**
  42731. * Fired when the thumb rest on this controller is modified
  42732. */
  42733. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42734. /**
  42735. * Creates a new OculusTouchController from a gamepad
  42736. * @param vrGamepad the gamepad that the controller should be created from
  42737. */
  42738. constructor(vrGamepad: any);
  42739. /**
  42740. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42741. * @param scene scene in which to add meshes
  42742. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42743. */
  42744. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42745. /**
  42746. * Fired when the A button on this controller is modified
  42747. */
  42748. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42749. /**
  42750. * Fired when the B button on this controller is modified
  42751. */
  42752. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42753. /**
  42754. * Fired when the X button on this controller is modified
  42755. */
  42756. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42757. /**
  42758. * Fired when the Y button on this controller is modified
  42759. */
  42760. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42761. /**
  42762. * Called once for each button that changed state since the last frame
  42763. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42764. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42765. * 2) secondary trigger (same)
  42766. * 3) A (right) X (left), touch, pressed = value
  42767. * 4) B / Y
  42768. * 5) thumb rest
  42769. * @param buttonIdx Which button index changed
  42770. * @param state New state of the button
  42771. * @param changes Which properties on the state changed since last frame
  42772. */
  42773. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42774. }
  42775. }
  42776. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42777. import { Scene } from "babylonjs/scene";
  42778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42779. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42780. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42781. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42782. import { Observable } from "babylonjs/Misc/observable";
  42783. /**
  42784. * Vive Controller
  42785. */
  42786. export class ViveController extends WebVRController {
  42787. /**
  42788. * Base Url for the controller model.
  42789. */
  42790. static MODEL_BASE_URL: string;
  42791. /**
  42792. * File name for the controller model.
  42793. */
  42794. static MODEL_FILENAME: string;
  42795. /**
  42796. * Creates a new ViveController from a gamepad
  42797. * @param vrGamepad the gamepad that the controller should be created from
  42798. */
  42799. constructor(vrGamepad: any);
  42800. /**
  42801. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42802. * @param scene scene in which to add meshes
  42803. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42804. */
  42805. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42806. /**
  42807. * Fired when the left button on this controller is modified
  42808. */
  42809. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42810. /**
  42811. * Fired when the right button on this controller is modified
  42812. */
  42813. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42814. /**
  42815. * Fired when the menu button on this controller is modified
  42816. */
  42817. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42818. /**
  42819. * Called once for each button that changed state since the last frame
  42820. * Vive mapping:
  42821. * 0: touchpad
  42822. * 1: trigger
  42823. * 2: left AND right buttons
  42824. * 3: menu button
  42825. * @param buttonIdx Which button index changed
  42826. * @param state New state of the button
  42827. * @param changes Which properties on the state changed since last frame
  42828. */
  42829. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42830. }
  42831. }
  42832. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42833. import { Observable } from "babylonjs/Misc/observable";
  42834. import { Scene } from "babylonjs/scene";
  42835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42836. import { Ray } from "babylonjs/Culling/ray";
  42837. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42838. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42839. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42840. /**
  42841. * Defines the WindowsMotionController object that the state of the windows motion controller
  42842. */
  42843. export class WindowsMotionController extends WebVRController {
  42844. /**
  42845. * The base url used to load the left and right controller models
  42846. */
  42847. static MODEL_BASE_URL: string;
  42848. /**
  42849. * The name of the left controller model file
  42850. */
  42851. static MODEL_LEFT_FILENAME: string;
  42852. /**
  42853. * The name of the right controller model file
  42854. */
  42855. static MODEL_RIGHT_FILENAME: string;
  42856. /**
  42857. * The controller name prefix for this controller type
  42858. */
  42859. static readonly GAMEPAD_ID_PREFIX: string;
  42860. /**
  42861. * The controller id pattern for this controller type
  42862. */
  42863. private static readonly GAMEPAD_ID_PATTERN;
  42864. private _loadedMeshInfo;
  42865. private readonly _mapping;
  42866. /**
  42867. * Fired when the trackpad on this controller is clicked
  42868. */
  42869. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42870. /**
  42871. * Fired when the trackpad on this controller is modified
  42872. */
  42873. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42874. /**
  42875. * The current x and y values of this controller's trackpad
  42876. */
  42877. trackpad: StickValues;
  42878. /**
  42879. * Creates a new WindowsMotionController from a gamepad
  42880. * @param vrGamepad the gamepad that the controller should be created from
  42881. */
  42882. constructor(vrGamepad: any);
  42883. /**
  42884. * Fired when the trigger on this controller is modified
  42885. */
  42886. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42887. /**
  42888. * Fired when the menu button on this controller is modified
  42889. */
  42890. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42891. /**
  42892. * Fired when the grip button on this controller is modified
  42893. */
  42894. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42895. /**
  42896. * Fired when the thumbstick button on this controller is modified
  42897. */
  42898. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42899. /**
  42900. * Fired when the touchpad button on this controller is modified
  42901. */
  42902. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42903. /**
  42904. * Fired when the touchpad values on this controller are modified
  42905. */
  42906. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42907. private _updateTrackpad;
  42908. /**
  42909. * Called once per frame by the engine.
  42910. */
  42911. update(): void;
  42912. /**
  42913. * Called once for each button that changed state since the last frame
  42914. * @param buttonIdx Which button index changed
  42915. * @param state New state of the button
  42916. * @param changes Which properties on the state changed since last frame
  42917. */
  42918. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42919. /**
  42920. * Moves the buttons on the controller mesh based on their current state
  42921. * @param buttonName the name of the button to move
  42922. * @param buttonValue the value of the button which determines the buttons new position
  42923. */
  42924. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42925. /**
  42926. * Moves the axis on the controller mesh based on its current state
  42927. * @param axis the index of the axis
  42928. * @param axisValue the value of the axis which determines the meshes new position
  42929. * @hidden
  42930. */
  42931. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42932. /**
  42933. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42934. * @param scene scene in which to add meshes
  42935. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42936. */
  42937. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42938. /**
  42939. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42940. * can be transformed by button presses and axes values, based on this._mapping.
  42941. *
  42942. * @param scene scene in which the meshes exist
  42943. * @param meshes list of meshes that make up the controller model to process
  42944. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42945. */
  42946. private processModel;
  42947. private createMeshInfo;
  42948. /**
  42949. * Gets the ray of the controller in the direction the controller is pointing
  42950. * @param length the length the resulting ray should be
  42951. * @returns a ray in the direction the controller is pointing
  42952. */
  42953. getForwardRay(length?: number): Ray;
  42954. /**
  42955. * Disposes of the controller
  42956. */
  42957. dispose(): void;
  42958. }
  42959. }
  42960. declare module "babylonjs/Gamepads/Controllers/index" {
  42961. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42962. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42963. export * from "babylonjs/Gamepads/Controllers/genericController";
  42964. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42965. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42966. export * from "babylonjs/Gamepads/Controllers/viveController";
  42967. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42968. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42969. }
  42970. declare module "babylonjs/Gamepads/gamepadManager" {
  42971. import { Observable } from "babylonjs/Misc/observable";
  42972. import { Nullable } from "babylonjs/types";
  42973. import { Scene } from "babylonjs/scene";
  42974. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42975. /**
  42976. * Manager for handling gamepads
  42977. */
  42978. export class GamepadManager {
  42979. private _scene?;
  42980. private _babylonGamepads;
  42981. private _oneGamepadConnected;
  42982. /** @hidden */
  42983. _isMonitoring: boolean;
  42984. private _gamepadEventSupported;
  42985. private _gamepadSupport;
  42986. /**
  42987. * observable to be triggered when the gamepad controller has been connected
  42988. */
  42989. onGamepadConnectedObservable: Observable<Gamepad>;
  42990. /**
  42991. * observable to be triggered when the gamepad controller has been disconnected
  42992. */
  42993. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42994. private _onGamepadConnectedEvent;
  42995. private _onGamepadDisconnectedEvent;
  42996. /**
  42997. * Initializes the gamepad manager
  42998. * @param _scene BabylonJS scene
  42999. */
  43000. constructor(_scene?: Scene | undefined);
  43001. /**
  43002. * The gamepads in the game pad manager
  43003. */
  43004. readonly gamepads: Gamepad[];
  43005. /**
  43006. * Get the gamepad controllers based on type
  43007. * @param type The type of gamepad controller
  43008. * @returns Nullable gamepad
  43009. */
  43010. getGamepadByType(type?: number): Nullable<Gamepad>;
  43011. /**
  43012. * Disposes the gamepad manager
  43013. */
  43014. dispose(): void;
  43015. private _addNewGamepad;
  43016. private _startMonitoringGamepads;
  43017. private _stopMonitoringGamepads;
  43018. /** @hidden */
  43019. _checkGamepadsStatus(): void;
  43020. private _updateGamepadObjects;
  43021. }
  43022. }
  43023. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43024. import { Nullable } from "babylonjs/types";
  43025. import { Scene } from "babylonjs/scene";
  43026. import { ISceneComponent } from "babylonjs/sceneComponent";
  43027. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43028. module "babylonjs/scene" {
  43029. interface Scene {
  43030. /** @hidden */
  43031. _gamepadManager: Nullable<GamepadManager>;
  43032. /**
  43033. * Gets the gamepad manager associated with the scene
  43034. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43035. */
  43036. gamepadManager: GamepadManager;
  43037. }
  43038. }
  43039. module "babylonjs/Cameras/freeCameraInputsManager" {
  43040. /**
  43041. * Interface representing a free camera inputs manager
  43042. */
  43043. interface FreeCameraInputsManager {
  43044. /**
  43045. * Adds gamepad input support to the FreeCameraInputsManager.
  43046. * @returns the FreeCameraInputsManager
  43047. */
  43048. addGamepad(): FreeCameraInputsManager;
  43049. }
  43050. }
  43051. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43052. /**
  43053. * Interface representing an arc rotate camera inputs manager
  43054. */
  43055. interface ArcRotateCameraInputsManager {
  43056. /**
  43057. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43058. * @returns the camera inputs manager
  43059. */
  43060. addGamepad(): ArcRotateCameraInputsManager;
  43061. }
  43062. }
  43063. /**
  43064. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43065. */
  43066. export class GamepadSystemSceneComponent implements ISceneComponent {
  43067. /**
  43068. * The component name helpfull to identify the component in the list of scene components.
  43069. */
  43070. readonly name: string;
  43071. /**
  43072. * The scene the component belongs to.
  43073. */
  43074. scene: Scene;
  43075. /**
  43076. * Creates a new instance of the component for the given scene
  43077. * @param scene Defines the scene to register the component in
  43078. */
  43079. constructor(scene: Scene);
  43080. /**
  43081. * Registers the component in a given scene
  43082. */
  43083. register(): void;
  43084. /**
  43085. * Rebuilds the elements related to this component in case of
  43086. * context lost for instance.
  43087. */
  43088. rebuild(): void;
  43089. /**
  43090. * Disposes the component and the associated ressources
  43091. */
  43092. dispose(): void;
  43093. private _beforeCameraUpdate;
  43094. }
  43095. }
  43096. declare module "babylonjs/Gamepads/index" {
  43097. export * from "babylonjs/Gamepads/Controllers/index";
  43098. export * from "babylonjs/Gamepads/gamepad";
  43099. export * from "babylonjs/Gamepads/gamepadManager";
  43100. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43101. export * from "babylonjs/Gamepads/xboxGamepad";
  43102. }
  43103. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43104. import { Observable } from "babylonjs/Misc/observable";
  43105. import { Nullable } from "babylonjs/types";
  43106. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43108. import { Mesh } from "babylonjs/Meshes/mesh";
  43109. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43110. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43111. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43112. /**
  43113. * Single axis scale gizmo
  43114. */
  43115. export class AxisScaleGizmo extends Gizmo {
  43116. private _coloredMaterial;
  43117. /**
  43118. * Drag behavior responsible for the gizmos dragging interactions
  43119. */
  43120. dragBehavior: PointerDragBehavior;
  43121. private _pointerObserver;
  43122. /**
  43123. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43124. */
  43125. snapDistance: number;
  43126. /**
  43127. * Event that fires each time the gizmo snaps to a new location.
  43128. * * snapDistance is the the change in distance
  43129. */
  43130. onSnapObservable: Observable<{
  43131. snapDistance: number;
  43132. }>;
  43133. /**
  43134. * If the scaling operation should be done on all axis (default: false)
  43135. */
  43136. uniformScaling: boolean;
  43137. /**
  43138. * Creates an AxisScaleGizmo
  43139. * @param gizmoLayer The utility layer the gizmo will be added to
  43140. * @param dragAxis The axis which the gizmo will be able to scale on
  43141. * @param color The color of the gizmo
  43142. */
  43143. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43144. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43145. /**
  43146. * Disposes of the gizmo
  43147. */
  43148. dispose(): void;
  43149. /**
  43150. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43151. * @param mesh The mesh to replace the default mesh of the gizmo
  43152. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43153. */
  43154. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43155. }
  43156. }
  43157. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43158. import { Observable } from "babylonjs/Misc/observable";
  43159. import { Nullable } from "babylonjs/types";
  43160. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43162. import { Mesh } from "babylonjs/Meshes/mesh";
  43163. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43164. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43165. /**
  43166. * Bounding box gizmo
  43167. */
  43168. export class BoundingBoxGizmo extends Gizmo {
  43169. private _lineBoundingBox;
  43170. private _rotateSpheresParent;
  43171. private _scaleBoxesParent;
  43172. private _boundingDimensions;
  43173. private _renderObserver;
  43174. private _pointerObserver;
  43175. private _scaleDragSpeed;
  43176. private _tmpQuaternion;
  43177. private _tmpVector;
  43178. private _tmpRotationMatrix;
  43179. /**
  43180. * 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)
  43181. */
  43182. ignoreChildren: boolean;
  43183. /**
  43184. * 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)
  43185. */
  43186. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43187. /**
  43188. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43189. */
  43190. rotationSphereSize: number;
  43191. /**
  43192. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43193. */
  43194. scaleBoxSize: number;
  43195. /**
  43196. * 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)
  43197. */
  43198. fixedDragMeshScreenSize: boolean;
  43199. /**
  43200. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43201. */
  43202. fixedDragMeshScreenSizeDistanceFactor: number;
  43203. /**
  43204. * Fired when a rotation sphere or scale box is dragged
  43205. */
  43206. onDragStartObservable: Observable<{}>;
  43207. /**
  43208. * Fired when a scale box is dragged
  43209. */
  43210. onScaleBoxDragObservable: Observable<{}>;
  43211. /**
  43212. * Fired when a scale box drag is ended
  43213. */
  43214. onScaleBoxDragEndObservable: Observable<{}>;
  43215. /**
  43216. * Fired when a rotation sphere is dragged
  43217. */
  43218. onRotationSphereDragObservable: Observable<{}>;
  43219. /**
  43220. * Fired when a rotation sphere drag is ended
  43221. */
  43222. onRotationSphereDragEndObservable: Observable<{}>;
  43223. /**
  43224. * 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)
  43225. */
  43226. scalePivot: Nullable<Vector3>;
  43227. private _anchorMesh;
  43228. private _existingMeshScale;
  43229. private _dragMesh;
  43230. private pointerDragBehavior;
  43231. /**
  43232. * Creates an BoundingBoxGizmo
  43233. * @param gizmoLayer The utility layer the gizmo will be added to
  43234. * @param color The color of the gizmo
  43235. */
  43236. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43237. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43238. private _selectNode;
  43239. /**
  43240. * Updates the bounding box information for the Gizmo
  43241. */
  43242. updateBoundingBox(): void;
  43243. private _updateRotationSpheres;
  43244. private _updateScaleBoxes;
  43245. /**
  43246. * Enables rotation on the specified axis and disables rotation on the others
  43247. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43248. */
  43249. setEnabledRotationAxis(axis: string): void;
  43250. /**
  43251. * Enables/disables scaling
  43252. * @param enable if scaling should be enabled
  43253. */
  43254. setEnabledScaling(enable: boolean): void;
  43255. private _updateDummy;
  43256. /**
  43257. * Enables a pointer drag behavior on the bounding box of the gizmo
  43258. */
  43259. enableDragBehavior(): void;
  43260. /**
  43261. * Disposes of the gizmo
  43262. */
  43263. dispose(): void;
  43264. /**
  43265. * 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)
  43266. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43267. * @returns the bounding box mesh with the passed in mesh as a child
  43268. */
  43269. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43270. /**
  43271. * CustomMeshes are not supported by this gizmo
  43272. * @param mesh The mesh to replace the default mesh of the gizmo
  43273. */
  43274. setCustomMesh(mesh: Mesh): void;
  43275. }
  43276. }
  43277. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43278. import { Observable } from "babylonjs/Misc/observable";
  43279. import { Nullable } from "babylonjs/types";
  43280. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43282. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43283. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43284. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43285. /**
  43286. * Single plane rotation gizmo
  43287. */
  43288. export class PlaneRotationGizmo extends Gizmo {
  43289. /**
  43290. * Drag behavior responsible for the gizmos dragging interactions
  43291. */
  43292. dragBehavior: PointerDragBehavior;
  43293. private _pointerObserver;
  43294. /**
  43295. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43296. */
  43297. snapDistance: number;
  43298. /**
  43299. * Event that fires each time the gizmo snaps to a new location.
  43300. * * snapDistance is the the change in distance
  43301. */
  43302. onSnapObservable: Observable<{
  43303. snapDistance: number;
  43304. }>;
  43305. /**
  43306. * Creates a PlaneRotationGizmo
  43307. * @param gizmoLayer The utility layer the gizmo will be added to
  43308. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43309. * @param color The color of the gizmo
  43310. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43311. */
  43312. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43313. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43314. /**
  43315. * Disposes of the gizmo
  43316. */
  43317. dispose(): void;
  43318. }
  43319. }
  43320. declare module "babylonjs/Gizmos/rotationGizmo" {
  43321. import { Observable } from "babylonjs/Misc/observable";
  43322. import { Nullable } from "babylonjs/types";
  43323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43324. import { Mesh } from "babylonjs/Meshes/mesh";
  43325. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43326. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43327. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43328. /**
  43329. * Gizmo that enables rotating a mesh along 3 axis
  43330. */
  43331. export class RotationGizmo extends Gizmo {
  43332. /**
  43333. * Internal gizmo used for interactions on the x axis
  43334. */
  43335. xGizmo: PlaneRotationGizmo;
  43336. /**
  43337. * Internal gizmo used for interactions on the y axis
  43338. */
  43339. yGizmo: PlaneRotationGizmo;
  43340. /**
  43341. * Internal gizmo used for interactions on the z axis
  43342. */
  43343. zGizmo: PlaneRotationGizmo;
  43344. /** Fires an event when any of it's sub gizmos are dragged */
  43345. onDragStartObservable: Observable<{}>;
  43346. /** Fires an event when any of it's sub gizmos are released from dragging */
  43347. onDragEndObservable: Observable<{}>;
  43348. attachedMesh: Nullable<AbstractMesh>;
  43349. /**
  43350. * Creates a RotationGizmo
  43351. * @param gizmoLayer The utility layer the gizmo will be added to
  43352. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43353. */
  43354. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43355. updateGizmoRotationToMatchAttachedMesh: boolean;
  43356. /**
  43357. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43358. */
  43359. snapDistance: number;
  43360. /**
  43361. * Ratio for the scale of the gizmo (Default: 1)
  43362. */
  43363. scaleRatio: number;
  43364. /**
  43365. * Disposes of the gizmo
  43366. */
  43367. dispose(): void;
  43368. /**
  43369. * CustomMeshes are not supported by this gizmo
  43370. * @param mesh The mesh to replace the default mesh of the gizmo
  43371. */
  43372. setCustomMesh(mesh: Mesh): void;
  43373. }
  43374. }
  43375. declare module "babylonjs/Gizmos/positionGizmo" {
  43376. import { Observable } from "babylonjs/Misc/observable";
  43377. import { Nullable } from "babylonjs/types";
  43378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43379. import { Mesh } from "babylonjs/Meshes/mesh";
  43380. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43381. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43382. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43383. /**
  43384. * Gizmo that enables dragging a mesh along 3 axis
  43385. */
  43386. export class PositionGizmo extends Gizmo {
  43387. /**
  43388. * Internal gizmo used for interactions on the x axis
  43389. */
  43390. xGizmo: AxisDragGizmo;
  43391. /**
  43392. * Internal gizmo used for interactions on the y axis
  43393. */
  43394. yGizmo: AxisDragGizmo;
  43395. /**
  43396. * Internal gizmo used for interactions on the z axis
  43397. */
  43398. zGizmo: AxisDragGizmo;
  43399. /** Fires an event when any of it's sub gizmos are dragged */
  43400. onDragStartObservable: Observable<{}>;
  43401. /** Fires an event when any of it's sub gizmos are released from dragging */
  43402. onDragEndObservable: Observable<{}>;
  43403. attachedMesh: Nullable<AbstractMesh>;
  43404. /**
  43405. * Creates a PositionGizmo
  43406. * @param gizmoLayer The utility layer the gizmo will be added to
  43407. */
  43408. constructor(gizmoLayer?: UtilityLayerRenderer);
  43409. updateGizmoRotationToMatchAttachedMesh: boolean;
  43410. /**
  43411. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43412. */
  43413. snapDistance: number;
  43414. /**
  43415. * Ratio for the scale of the gizmo (Default: 1)
  43416. */
  43417. scaleRatio: number;
  43418. /**
  43419. * Disposes of the gizmo
  43420. */
  43421. dispose(): void;
  43422. /**
  43423. * CustomMeshes are not supported by this gizmo
  43424. * @param mesh The mesh to replace the default mesh of the gizmo
  43425. */
  43426. setCustomMesh(mesh: Mesh): void;
  43427. }
  43428. }
  43429. declare module "babylonjs/Gizmos/scaleGizmo" {
  43430. import { Observable } from "babylonjs/Misc/observable";
  43431. import { Nullable } from "babylonjs/types";
  43432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43433. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43434. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43435. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43436. /**
  43437. * Gizmo that enables scaling a mesh along 3 axis
  43438. */
  43439. export class ScaleGizmo extends Gizmo {
  43440. /**
  43441. * Internal gizmo used for interactions on the x axis
  43442. */
  43443. xGizmo: AxisScaleGizmo;
  43444. /**
  43445. * Internal gizmo used for interactions on the y axis
  43446. */
  43447. yGizmo: AxisScaleGizmo;
  43448. /**
  43449. * Internal gizmo used for interactions on the z axis
  43450. */
  43451. zGizmo: AxisScaleGizmo;
  43452. /**
  43453. * Internal gizmo used to scale all axis equally
  43454. */
  43455. uniformScaleGizmo: AxisScaleGizmo;
  43456. /** Fires an event when any of it's sub gizmos are dragged */
  43457. onDragStartObservable: Observable<{}>;
  43458. /** Fires an event when any of it's sub gizmos are released from dragging */
  43459. onDragEndObservable: Observable<{}>;
  43460. attachedMesh: Nullable<AbstractMesh>;
  43461. /**
  43462. * Creates a ScaleGizmo
  43463. * @param gizmoLayer The utility layer the gizmo will be added to
  43464. */
  43465. constructor(gizmoLayer?: UtilityLayerRenderer);
  43466. updateGizmoRotationToMatchAttachedMesh: boolean;
  43467. /**
  43468. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43469. */
  43470. snapDistance: number;
  43471. /**
  43472. * Ratio for the scale of the gizmo (Default: 1)
  43473. */
  43474. scaleRatio: number;
  43475. /**
  43476. * Disposes of the gizmo
  43477. */
  43478. dispose(): void;
  43479. }
  43480. }
  43481. declare module "babylonjs/Gizmos/gizmoManager" {
  43482. import { Observable } from "babylonjs/Misc/observable";
  43483. import { Nullable } from "babylonjs/types";
  43484. import { Scene, IDisposable } from "babylonjs/scene";
  43485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43486. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43487. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43488. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43489. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43490. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43491. /**
  43492. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43493. */
  43494. export class GizmoManager implements IDisposable {
  43495. private scene;
  43496. /**
  43497. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43498. */
  43499. gizmos: {
  43500. positionGizmo: Nullable<PositionGizmo>;
  43501. rotationGizmo: Nullable<RotationGizmo>;
  43502. scaleGizmo: Nullable<ScaleGizmo>;
  43503. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43504. };
  43505. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43506. clearGizmoOnEmptyPointerEvent: boolean;
  43507. /** Fires an event when the manager is attached to a mesh */
  43508. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43509. private _gizmosEnabled;
  43510. private _pointerObserver;
  43511. private _attachedMesh;
  43512. private _boundingBoxColor;
  43513. private _defaultUtilityLayer;
  43514. private _defaultKeepDepthUtilityLayer;
  43515. /**
  43516. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43517. */
  43518. boundingBoxDragBehavior: SixDofDragBehavior;
  43519. /**
  43520. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43521. */
  43522. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43523. /**
  43524. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43525. */
  43526. usePointerToAttachGizmos: boolean;
  43527. /**
  43528. * Instatiates a gizmo manager
  43529. * @param scene the scene to overlay the gizmos on top of
  43530. */
  43531. constructor(scene: Scene);
  43532. /**
  43533. * Attaches a set of gizmos to the specified mesh
  43534. * @param mesh The mesh the gizmo's should be attached to
  43535. */
  43536. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43537. /**
  43538. * If the position gizmo is enabled
  43539. */
  43540. positionGizmoEnabled: boolean;
  43541. /**
  43542. * If the rotation gizmo is enabled
  43543. */
  43544. rotationGizmoEnabled: boolean;
  43545. /**
  43546. * If the scale gizmo is enabled
  43547. */
  43548. scaleGizmoEnabled: boolean;
  43549. /**
  43550. * If the boundingBox gizmo is enabled
  43551. */
  43552. boundingBoxGizmoEnabled: boolean;
  43553. /**
  43554. * Disposes of the gizmo manager
  43555. */
  43556. dispose(): void;
  43557. }
  43558. }
  43559. declare module "babylonjs/Gizmos/index" {
  43560. export * from "babylonjs/Gizmos/axisDragGizmo";
  43561. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43562. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43563. export * from "babylonjs/Gizmos/gizmo";
  43564. export * from "babylonjs/Gizmos/gizmoManager";
  43565. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43566. export * from "babylonjs/Gizmos/positionGizmo";
  43567. export * from "babylonjs/Gizmos/rotationGizmo";
  43568. export * from "babylonjs/Gizmos/scaleGizmo";
  43569. }
  43570. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43571. /** @hidden */
  43572. export var backgroundFragmentDeclaration: {
  43573. name: string;
  43574. shader: string;
  43575. };
  43576. }
  43577. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43578. /** @hidden */
  43579. export var backgroundUboDeclaration: {
  43580. name: string;
  43581. shader: string;
  43582. };
  43583. }
  43584. declare module "babylonjs/Shaders/background.fragment" {
  43585. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43586. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43587. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43588. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43589. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43590. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43591. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43592. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43593. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43594. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43595. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43596. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43597. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43598. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43599. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43600. /** @hidden */
  43601. export var backgroundPixelShader: {
  43602. name: string;
  43603. shader: string;
  43604. };
  43605. }
  43606. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43607. /** @hidden */
  43608. export var backgroundVertexDeclaration: {
  43609. name: string;
  43610. shader: string;
  43611. };
  43612. }
  43613. declare module "babylonjs/Shaders/background.vertex" {
  43614. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43615. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43616. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43617. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43618. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43619. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43620. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43621. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43622. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43623. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43624. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43625. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43626. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43627. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43628. /** @hidden */
  43629. export var backgroundVertexShader: {
  43630. name: string;
  43631. shader: string;
  43632. };
  43633. }
  43634. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43635. import { Nullable, int, float } from "babylonjs/types";
  43636. import { Scene } from "babylonjs/scene";
  43637. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43638. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43640. import { Mesh } from "babylonjs/Meshes/mesh";
  43641. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43642. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43643. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43644. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43645. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43646. import "babylonjs/Shaders/background.fragment";
  43647. import "babylonjs/Shaders/background.vertex";
  43648. /**
  43649. * Background material used to create an efficient environement around your scene.
  43650. */
  43651. export class BackgroundMaterial extends PushMaterial {
  43652. /**
  43653. * Standard reflectance value at parallel view angle.
  43654. */
  43655. static StandardReflectance0: number;
  43656. /**
  43657. * Standard reflectance value at grazing angle.
  43658. */
  43659. static StandardReflectance90: number;
  43660. protected _primaryColor: Color3;
  43661. /**
  43662. * Key light Color (multiply against the environement texture)
  43663. */
  43664. primaryColor: Color3;
  43665. protected __perceptualColor: Nullable<Color3>;
  43666. /**
  43667. * Experimental Internal Use Only.
  43668. *
  43669. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43670. * This acts as a helper to set the primary color to a more "human friendly" value.
  43671. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43672. * output color as close as possible from the chosen value.
  43673. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43674. * part of lighting setup.)
  43675. */
  43676. _perceptualColor: Nullable<Color3>;
  43677. protected _primaryColorShadowLevel: float;
  43678. /**
  43679. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43680. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43681. */
  43682. primaryColorShadowLevel: float;
  43683. protected _primaryColorHighlightLevel: float;
  43684. /**
  43685. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43686. * The primary color is used at the level chosen to define what the white area would look.
  43687. */
  43688. primaryColorHighlightLevel: float;
  43689. protected _reflectionTexture: Nullable<BaseTexture>;
  43690. /**
  43691. * Reflection Texture used in the material.
  43692. * Should be author in a specific way for the best result (refer to the documentation).
  43693. */
  43694. reflectionTexture: Nullable<BaseTexture>;
  43695. protected _reflectionBlur: float;
  43696. /**
  43697. * Reflection Texture level of blur.
  43698. *
  43699. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43700. * texture twice.
  43701. */
  43702. reflectionBlur: float;
  43703. protected _diffuseTexture: Nullable<BaseTexture>;
  43704. /**
  43705. * Diffuse Texture used in the material.
  43706. * Should be author in a specific way for the best result (refer to the documentation).
  43707. */
  43708. diffuseTexture: Nullable<BaseTexture>;
  43709. protected _shadowLights: Nullable<IShadowLight[]>;
  43710. /**
  43711. * Specify the list of lights casting shadow on the material.
  43712. * All scene shadow lights will be included if null.
  43713. */
  43714. shadowLights: Nullable<IShadowLight[]>;
  43715. protected _shadowLevel: float;
  43716. /**
  43717. * Helps adjusting the shadow to a softer level if required.
  43718. * 0 means black shadows and 1 means no shadows.
  43719. */
  43720. shadowLevel: float;
  43721. protected _sceneCenter: Vector3;
  43722. /**
  43723. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43724. * It is usually zero but might be interesting to modify according to your setup.
  43725. */
  43726. sceneCenter: Vector3;
  43727. protected _opacityFresnel: boolean;
  43728. /**
  43729. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43730. * This helps ensuring a nice transition when the camera goes under the ground.
  43731. */
  43732. opacityFresnel: boolean;
  43733. protected _reflectionFresnel: boolean;
  43734. /**
  43735. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43736. * This helps adding a mirror texture on the ground.
  43737. */
  43738. reflectionFresnel: boolean;
  43739. protected _reflectionFalloffDistance: number;
  43740. /**
  43741. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43742. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43743. */
  43744. reflectionFalloffDistance: number;
  43745. protected _reflectionAmount: number;
  43746. /**
  43747. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43748. */
  43749. reflectionAmount: number;
  43750. protected _reflectionReflectance0: number;
  43751. /**
  43752. * This specifies the weight of the reflection at grazing angle.
  43753. */
  43754. reflectionReflectance0: number;
  43755. protected _reflectionReflectance90: number;
  43756. /**
  43757. * This specifies the weight of the reflection at a perpendicular point of view.
  43758. */
  43759. reflectionReflectance90: number;
  43760. /**
  43761. * Sets the reflection reflectance fresnel values according to the default standard
  43762. * empirically know to work well :-)
  43763. */
  43764. reflectionStandardFresnelWeight: number;
  43765. protected _useRGBColor: boolean;
  43766. /**
  43767. * Helps to directly use the maps channels instead of their level.
  43768. */
  43769. useRGBColor: boolean;
  43770. protected _enableNoise: boolean;
  43771. /**
  43772. * This helps reducing the banding effect that could occur on the background.
  43773. */
  43774. enableNoise: boolean;
  43775. /**
  43776. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43777. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43778. * Recommended to be keep at 1.0 except for special cases.
  43779. */
  43780. fovMultiplier: number;
  43781. private _fovMultiplier;
  43782. /**
  43783. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43784. */
  43785. useEquirectangularFOV: boolean;
  43786. private _maxSimultaneousLights;
  43787. /**
  43788. * Number of Simultaneous lights allowed on the material.
  43789. */
  43790. maxSimultaneousLights: int;
  43791. /**
  43792. * Default configuration related to image processing available in the Background Material.
  43793. */
  43794. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43795. /**
  43796. * Keep track of the image processing observer to allow dispose and replace.
  43797. */
  43798. private _imageProcessingObserver;
  43799. /**
  43800. * Attaches a new image processing configuration to the PBR Material.
  43801. * @param configuration (if null the scene configuration will be use)
  43802. */
  43803. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43804. /**
  43805. * Gets the image processing configuration used either in this material.
  43806. */
  43807. /**
  43808. * Sets the Default image processing configuration used either in the this material.
  43809. *
  43810. * If sets to null, the scene one is in use.
  43811. */
  43812. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43813. /**
  43814. * Gets wether the color curves effect is enabled.
  43815. */
  43816. /**
  43817. * Sets wether the color curves effect is enabled.
  43818. */
  43819. cameraColorCurvesEnabled: boolean;
  43820. /**
  43821. * Gets wether the color grading effect is enabled.
  43822. */
  43823. /**
  43824. * Gets wether the color grading effect is enabled.
  43825. */
  43826. cameraColorGradingEnabled: boolean;
  43827. /**
  43828. * Gets wether tonemapping is enabled or not.
  43829. */
  43830. /**
  43831. * Sets wether tonemapping is enabled or not
  43832. */
  43833. cameraToneMappingEnabled: boolean;
  43834. /**
  43835. * The camera exposure used on this material.
  43836. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43837. * This corresponds to a photographic exposure.
  43838. */
  43839. /**
  43840. * The camera exposure used on this material.
  43841. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43842. * This corresponds to a photographic exposure.
  43843. */
  43844. cameraExposure: float;
  43845. /**
  43846. * Gets The camera contrast used on this material.
  43847. */
  43848. /**
  43849. * Sets The camera contrast used on this material.
  43850. */
  43851. cameraContrast: float;
  43852. /**
  43853. * Gets the Color Grading 2D Lookup Texture.
  43854. */
  43855. /**
  43856. * Sets the Color Grading 2D Lookup Texture.
  43857. */
  43858. cameraColorGradingTexture: Nullable<BaseTexture>;
  43859. /**
  43860. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43861. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43862. * 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;
  43863. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43864. */
  43865. /**
  43866. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43867. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43868. * 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;
  43869. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43870. */
  43871. cameraColorCurves: Nullable<ColorCurves>;
  43872. /**
  43873. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43874. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43875. */
  43876. switchToBGR: boolean;
  43877. private _renderTargets;
  43878. private _reflectionControls;
  43879. private _white;
  43880. private _primaryShadowColor;
  43881. private _primaryHighlightColor;
  43882. /**
  43883. * Instantiates a Background Material in the given scene
  43884. * @param name The friendly name of the material
  43885. * @param scene The scene to add the material to
  43886. */
  43887. constructor(name: string, scene: Scene);
  43888. /**
  43889. * Gets a boolean indicating that current material needs to register RTT
  43890. */
  43891. readonly hasRenderTargetTextures: boolean;
  43892. /**
  43893. * The entire material has been created in order to prevent overdraw.
  43894. * @returns false
  43895. */
  43896. needAlphaTesting(): boolean;
  43897. /**
  43898. * The entire material has been created in order to prevent overdraw.
  43899. * @returns true if blending is enable
  43900. */
  43901. needAlphaBlending(): boolean;
  43902. /**
  43903. * Checks wether the material is ready to be rendered for a given mesh.
  43904. * @param mesh The mesh to render
  43905. * @param subMesh The submesh to check against
  43906. * @param useInstances Specify wether or not the material is used with instances
  43907. * @returns true if all the dependencies are ready (Textures, Effects...)
  43908. */
  43909. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43910. /**
  43911. * Compute the primary color according to the chosen perceptual color.
  43912. */
  43913. private _computePrimaryColorFromPerceptualColor;
  43914. /**
  43915. * Compute the highlights and shadow colors according to their chosen levels.
  43916. */
  43917. private _computePrimaryColors;
  43918. /**
  43919. * Build the uniform buffer used in the material.
  43920. */
  43921. buildUniformLayout(): void;
  43922. /**
  43923. * Unbind the material.
  43924. */
  43925. unbind(): void;
  43926. /**
  43927. * Bind only the world matrix to the material.
  43928. * @param world The world matrix to bind.
  43929. */
  43930. bindOnlyWorldMatrix(world: Matrix): void;
  43931. /**
  43932. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43933. * @param world The world matrix to bind.
  43934. * @param subMesh The submesh to bind for.
  43935. */
  43936. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43937. /**
  43938. * Dispose the material.
  43939. * @param forceDisposeEffect Force disposal of the associated effect.
  43940. * @param forceDisposeTextures Force disposal of the associated textures.
  43941. */
  43942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43943. /**
  43944. * Clones the material.
  43945. * @param name The cloned name.
  43946. * @returns The cloned material.
  43947. */
  43948. clone(name: string): BackgroundMaterial;
  43949. /**
  43950. * Serializes the current material to its JSON representation.
  43951. * @returns The JSON representation.
  43952. */
  43953. serialize(): any;
  43954. /**
  43955. * Gets the class name of the material
  43956. * @returns "BackgroundMaterial"
  43957. */
  43958. getClassName(): string;
  43959. /**
  43960. * Parse a JSON input to create back a background material.
  43961. * @param source The JSON data to parse
  43962. * @param scene The scene to create the parsed material in
  43963. * @param rootUrl The root url of the assets the material depends upon
  43964. * @returns the instantiated BackgroundMaterial.
  43965. */
  43966. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43967. }
  43968. }
  43969. declare module "babylonjs/Helpers/environmentHelper" {
  43970. import { Observable } from "babylonjs/Misc/observable";
  43971. import { Nullable } from "babylonjs/types";
  43972. import { Scene } from "babylonjs/scene";
  43973. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43975. import { Mesh } from "babylonjs/Meshes/mesh";
  43976. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43977. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43978. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43979. /**
  43980. * Represents the different options available during the creation of
  43981. * a Environment helper.
  43982. *
  43983. * This can control the default ground, skybox and image processing setup of your scene.
  43984. */
  43985. export interface IEnvironmentHelperOptions {
  43986. /**
  43987. * Specifies wether or not to create a ground.
  43988. * True by default.
  43989. */
  43990. createGround: boolean;
  43991. /**
  43992. * Specifies the ground size.
  43993. * 15 by default.
  43994. */
  43995. groundSize: number;
  43996. /**
  43997. * The texture used on the ground for the main color.
  43998. * Comes from the BabylonJS CDN by default.
  43999. *
  44000. * Remarks: Can be either a texture or a url.
  44001. */
  44002. groundTexture: string | BaseTexture;
  44003. /**
  44004. * The color mixed in the ground texture by default.
  44005. * BabylonJS clearColor by default.
  44006. */
  44007. groundColor: Color3;
  44008. /**
  44009. * Specifies the ground opacity.
  44010. * 1 by default.
  44011. */
  44012. groundOpacity: number;
  44013. /**
  44014. * Enables the ground to receive shadows.
  44015. * True by default.
  44016. */
  44017. enableGroundShadow: boolean;
  44018. /**
  44019. * Helps preventing the shadow to be fully black on the ground.
  44020. * 0.5 by default.
  44021. */
  44022. groundShadowLevel: number;
  44023. /**
  44024. * Creates a mirror texture attach to the ground.
  44025. * false by default.
  44026. */
  44027. enableGroundMirror: boolean;
  44028. /**
  44029. * Specifies the ground mirror size ratio.
  44030. * 0.3 by default as the default kernel is 64.
  44031. */
  44032. groundMirrorSizeRatio: number;
  44033. /**
  44034. * Specifies the ground mirror blur kernel size.
  44035. * 64 by default.
  44036. */
  44037. groundMirrorBlurKernel: number;
  44038. /**
  44039. * Specifies the ground mirror visibility amount.
  44040. * 1 by default
  44041. */
  44042. groundMirrorAmount: number;
  44043. /**
  44044. * Specifies the ground mirror reflectance weight.
  44045. * This uses the standard weight of the background material to setup the fresnel effect
  44046. * of the mirror.
  44047. * 1 by default.
  44048. */
  44049. groundMirrorFresnelWeight: number;
  44050. /**
  44051. * Specifies the ground mirror Falloff distance.
  44052. * This can helps reducing the size of the reflection.
  44053. * 0 by Default.
  44054. */
  44055. groundMirrorFallOffDistance: number;
  44056. /**
  44057. * Specifies the ground mirror texture type.
  44058. * Unsigned Int by Default.
  44059. */
  44060. groundMirrorTextureType: number;
  44061. /**
  44062. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44063. * the shown objects.
  44064. */
  44065. groundYBias: number;
  44066. /**
  44067. * Specifies wether or not to create a skybox.
  44068. * True by default.
  44069. */
  44070. createSkybox: boolean;
  44071. /**
  44072. * Specifies the skybox size.
  44073. * 20 by default.
  44074. */
  44075. skyboxSize: number;
  44076. /**
  44077. * The texture used on the skybox for the main color.
  44078. * Comes from the BabylonJS CDN by default.
  44079. *
  44080. * Remarks: Can be either a texture or a url.
  44081. */
  44082. skyboxTexture: string | BaseTexture;
  44083. /**
  44084. * The color mixed in the skybox texture by default.
  44085. * BabylonJS clearColor by default.
  44086. */
  44087. skyboxColor: Color3;
  44088. /**
  44089. * The background rotation around the Y axis of the scene.
  44090. * This helps aligning the key lights of your scene with the background.
  44091. * 0 by default.
  44092. */
  44093. backgroundYRotation: number;
  44094. /**
  44095. * Compute automatically the size of the elements to best fit with the scene.
  44096. */
  44097. sizeAuto: boolean;
  44098. /**
  44099. * Default position of the rootMesh if autoSize is not true.
  44100. */
  44101. rootPosition: Vector3;
  44102. /**
  44103. * Sets up the image processing in the scene.
  44104. * true by default.
  44105. */
  44106. setupImageProcessing: boolean;
  44107. /**
  44108. * The texture used as your environment texture in the scene.
  44109. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44110. *
  44111. * Remarks: Can be either a texture or a url.
  44112. */
  44113. environmentTexture: string | BaseTexture;
  44114. /**
  44115. * The value of the exposure to apply to the scene.
  44116. * 0.6 by default if setupImageProcessing is true.
  44117. */
  44118. cameraExposure: number;
  44119. /**
  44120. * The value of the contrast to apply to the scene.
  44121. * 1.6 by default if setupImageProcessing is true.
  44122. */
  44123. cameraContrast: number;
  44124. /**
  44125. * Specifies wether or not tonemapping should be enabled in the scene.
  44126. * true by default if setupImageProcessing is true.
  44127. */
  44128. toneMappingEnabled: boolean;
  44129. }
  44130. /**
  44131. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44132. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44133. * It also helps with the default setup of your imageProcessing configuration.
  44134. */
  44135. export class EnvironmentHelper {
  44136. /**
  44137. * Default ground texture URL.
  44138. */
  44139. private static _groundTextureCDNUrl;
  44140. /**
  44141. * Default skybox texture URL.
  44142. */
  44143. private static _skyboxTextureCDNUrl;
  44144. /**
  44145. * Default environment texture URL.
  44146. */
  44147. private static _environmentTextureCDNUrl;
  44148. /**
  44149. * Creates the default options for the helper.
  44150. */
  44151. private static _getDefaultOptions;
  44152. private _rootMesh;
  44153. /**
  44154. * Gets the root mesh created by the helper.
  44155. */
  44156. readonly rootMesh: Mesh;
  44157. private _skybox;
  44158. /**
  44159. * Gets the skybox created by the helper.
  44160. */
  44161. readonly skybox: Nullable<Mesh>;
  44162. private _skyboxTexture;
  44163. /**
  44164. * Gets the skybox texture created by the helper.
  44165. */
  44166. readonly skyboxTexture: Nullable<BaseTexture>;
  44167. private _skyboxMaterial;
  44168. /**
  44169. * Gets the skybox material created by the helper.
  44170. */
  44171. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44172. private _ground;
  44173. /**
  44174. * Gets the ground mesh created by the helper.
  44175. */
  44176. readonly ground: Nullable<Mesh>;
  44177. private _groundTexture;
  44178. /**
  44179. * Gets the ground texture created by the helper.
  44180. */
  44181. readonly groundTexture: Nullable<BaseTexture>;
  44182. private _groundMirror;
  44183. /**
  44184. * Gets the ground mirror created by the helper.
  44185. */
  44186. readonly groundMirror: Nullable<MirrorTexture>;
  44187. /**
  44188. * Gets the ground mirror render list to helps pushing the meshes
  44189. * you wish in the ground reflection.
  44190. */
  44191. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44192. private _groundMaterial;
  44193. /**
  44194. * Gets the ground material created by the helper.
  44195. */
  44196. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44197. /**
  44198. * Stores the creation options.
  44199. */
  44200. private readonly _scene;
  44201. private _options;
  44202. /**
  44203. * This observable will be notified with any error during the creation of the environment,
  44204. * mainly texture creation errors.
  44205. */
  44206. onErrorObservable: Observable<{
  44207. message?: string;
  44208. exception?: any;
  44209. }>;
  44210. /**
  44211. * constructor
  44212. * @param options
  44213. * @param scene The scene to add the material to
  44214. */
  44215. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44216. /**
  44217. * Updates the background according to the new options
  44218. * @param options
  44219. */
  44220. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44221. /**
  44222. * Sets the primary color of all the available elements.
  44223. * @param color the main color to affect to the ground and the background
  44224. */
  44225. setMainColor(color: Color3): void;
  44226. /**
  44227. * Setup the image processing according to the specified options.
  44228. */
  44229. private _setupImageProcessing;
  44230. /**
  44231. * Setup the environment texture according to the specified options.
  44232. */
  44233. private _setupEnvironmentTexture;
  44234. /**
  44235. * Setup the background according to the specified options.
  44236. */
  44237. private _setupBackground;
  44238. /**
  44239. * Get the scene sizes according to the setup.
  44240. */
  44241. private _getSceneSize;
  44242. /**
  44243. * Setup the ground according to the specified options.
  44244. */
  44245. private _setupGround;
  44246. /**
  44247. * Setup the ground material according to the specified options.
  44248. */
  44249. private _setupGroundMaterial;
  44250. /**
  44251. * Setup the ground diffuse texture according to the specified options.
  44252. */
  44253. private _setupGroundDiffuseTexture;
  44254. /**
  44255. * Setup the ground mirror texture according to the specified options.
  44256. */
  44257. private _setupGroundMirrorTexture;
  44258. /**
  44259. * Setup the ground to receive the mirror texture.
  44260. */
  44261. private _setupMirrorInGroundMaterial;
  44262. /**
  44263. * Setup the skybox according to the specified options.
  44264. */
  44265. private _setupSkybox;
  44266. /**
  44267. * Setup the skybox material according to the specified options.
  44268. */
  44269. private _setupSkyboxMaterial;
  44270. /**
  44271. * Setup the skybox reflection texture according to the specified options.
  44272. */
  44273. private _setupSkyboxReflectionTexture;
  44274. private _errorHandler;
  44275. /**
  44276. * Dispose all the elements created by the Helper.
  44277. */
  44278. dispose(): void;
  44279. }
  44280. }
  44281. declare module "babylonjs/Helpers/photoDome" {
  44282. import { Observable } from "babylonjs/Misc/observable";
  44283. import { Nullable } from "babylonjs/types";
  44284. import { Scene } from "babylonjs/scene";
  44285. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44286. import { Mesh } from "babylonjs/Meshes/mesh";
  44287. import { Texture } from "babylonjs/Materials/Textures/texture";
  44288. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44289. import "babylonjs/Meshes/meshBuilder";
  44290. /**
  44291. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44292. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44293. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44294. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44295. */
  44296. export class PhotoDome extends TransformNode {
  44297. private _useDirectMapping;
  44298. /**
  44299. * The texture being displayed on the sphere
  44300. */
  44301. protected _photoTexture: Texture;
  44302. /**
  44303. * Gets or sets the texture being displayed on the sphere
  44304. */
  44305. photoTexture: Texture;
  44306. /**
  44307. * Observable raised when an error occured while loading the 360 image
  44308. */
  44309. onLoadErrorObservable: Observable<string>;
  44310. /**
  44311. * The skybox material
  44312. */
  44313. protected _material: BackgroundMaterial;
  44314. /**
  44315. * The surface used for the skybox
  44316. */
  44317. protected _mesh: Mesh;
  44318. /**
  44319. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44320. * Also see the options.resolution property.
  44321. */
  44322. fovMultiplier: number;
  44323. /**
  44324. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44325. * @param name Element's name, child elements will append suffixes for their own names.
  44326. * @param urlsOfPhoto defines the url of the photo to display
  44327. * @param options defines an object containing optional or exposed sub element properties
  44328. * @param onError defines a callback called when an error occured while loading the texture
  44329. */
  44330. constructor(name: string, urlOfPhoto: string, options: {
  44331. resolution?: number;
  44332. size?: number;
  44333. useDirectMapping?: boolean;
  44334. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44335. /**
  44336. * Releases resources associated with this node.
  44337. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44338. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44339. */
  44340. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44341. }
  44342. }
  44343. declare module "babylonjs/Misc/textureTools" {
  44344. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44345. import { Texture } from "babylonjs/Materials/Textures/texture";
  44346. import { Scene } from "babylonjs/scene";
  44347. /**
  44348. * Class used to host texture specific utilities
  44349. */
  44350. export class TextureTools {
  44351. /**
  44352. * Uses the GPU to create a copy texture rescaled at a given size
  44353. * @param texture Texture to copy from
  44354. * @param width defines the desired width
  44355. * @param height defines the desired height
  44356. * @param useBilinearMode defines if bilinear mode has to be used
  44357. * @return the generated texture
  44358. */
  44359. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44360. /**
  44361. * Gets an environment BRDF texture for a given scene
  44362. * @param scene defines the hosting scene
  44363. * @returns the environment BRDF texture
  44364. */
  44365. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44366. private static _environmentBRDFBase64Texture;
  44367. }
  44368. }
  44369. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44370. /** @hidden */
  44371. export var pbrFragmentDeclaration: {
  44372. name: string;
  44373. shader: string;
  44374. };
  44375. }
  44376. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44377. /** @hidden */
  44378. export var pbrUboDeclaration: {
  44379. name: string;
  44380. shader: string;
  44381. };
  44382. }
  44383. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44384. /** @hidden */
  44385. export var pbrFunctions: {
  44386. name: string;
  44387. shader: string;
  44388. };
  44389. }
  44390. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44391. /** @hidden */
  44392. export var harmonicsFunctions: {
  44393. name: string;
  44394. shader: string;
  44395. };
  44396. }
  44397. declare module "babylonjs/Shaders/ShadersInclude/pbrLightFunctions" {
  44398. /** @hidden */
  44399. export var pbrLightFunctions: {
  44400. name: string;
  44401. shader: string;
  44402. };
  44403. }
  44404. declare module "babylonjs/Shaders/pbr.fragment" {
  44405. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44406. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44407. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44408. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44409. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44410. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44411. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44412. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44413. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44414. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44415. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44416. import "babylonjs/Shaders/ShadersInclude/pbrLightFunctions";
  44417. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44418. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44419. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44420. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44421. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44422. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44423. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44424. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44425. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44426. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44427. /** @hidden */
  44428. export var pbrPixelShader: {
  44429. name: string;
  44430. shader: string;
  44431. };
  44432. }
  44433. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44434. /** @hidden */
  44435. export var pbrVertexDeclaration: {
  44436. name: string;
  44437. shader: string;
  44438. };
  44439. }
  44440. declare module "babylonjs/Shaders/pbr.vertex" {
  44441. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44442. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44443. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44444. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44445. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44446. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44447. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44448. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44449. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44450. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44451. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44452. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44453. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44454. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44455. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44456. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44457. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44458. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44459. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44460. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44461. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44462. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44463. /** @hidden */
  44464. export var pbrVertexShader: {
  44465. name: string;
  44466. shader: string;
  44467. };
  44468. }
  44469. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44470. import { IAnimatable } from "babylonjs/Misc/tools";
  44471. import { Nullable } from "babylonjs/types";
  44472. import { Scene } from "babylonjs/scene";
  44473. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44476. import { Mesh } from "babylonjs/Meshes/mesh";
  44477. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44478. import { Material } from "babylonjs/Materials/material";
  44479. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44481. import "babylonjs/Shaders/pbr.fragment";
  44482. import "babylonjs/Shaders/pbr.vertex";
  44483. /**
  44484. * The Physically based material base class of BJS.
  44485. *
  44486. * This offers the main features of a standard PBR material.
  44487. * For more information, please refer to the documentation :
  44488. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44489. */
  44490. export abstract class PBRBaseMaterial extends PushMaterial {
  44491. /**
  44492. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44493. */
  44494. static readonly PBRMATERIAL_OPAQUE: number;
  44495. /**
  44496. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44497. */
  44498. static readonly PBRMATERIAL_ALPHATEST: number;
  44499. /**
  44500. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44501. */
  44502. static readonly PBRMATERIAL_ALPHABLEND: number;
  44503. /**
  44504. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44505. * They are also discarded below the alpha cutoff threshold to improve performances.
  44506. */
  44507. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44508. /**
  44509. * Defines the default value of how much AO map is occluding the analytical lights
  44510. * (point spot...).
  44511. */
  44512. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44513. /**
  44514. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44515. */
  44516. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44517. /**
  44518. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44519. * to enhance interoperability with other engines.
  44520. */
  44521. static readonly LIGHTFALLOFF_GLTF: number;
  44522. /**
  44523. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44524. * to enhance interoperability with other materials.
  44525. */
  44526. static readonly LIGHTFALLOFF_STANDARD: number;
  44527. /**
  44528. * Intensity of the direct lights e.g. the four lights available in your scene.
  44529. * This impacts both the direct diffuse and specular highlights.
  44530. */
  44531. protected _directIntensity: number;
  44532. /**
  44533. * Intensity of the emissive part of the material.
  44534. * This helps controlling the emissive effect without modifying the emissive color.
  44535. */
  44536. protected _emissiveIntensity: number;
  44537. /**
  44538. * Intensity of the environment e.g. how much the environment will light the object
  44539. * either through harmonics for rough material or through the refelction for shiny ones.
  44540. */
  44541. protected _environmentIntensity: number;
  44542. /**
  44543. * This is a special control allowing the reduction of the specular highlights coming from the
  44544. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44545. */
  44546. protected _specularIntensity: number;
  44547. /**
  44548. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44549. */
  44550. private _lightingInfos;
  44551. /**
  44552. * Debug Control allowing disabling the bump map on this material.
  44553. */
  44554. protected _disableBumpMap: boolean;
  44555. /**
  44556. * AKA Diffuse Texture in standard nomenclature.
  44557. */
  44558. protected _albedoTexture: BaseTexture;
  44559. /**
  44560. * AKA Occlusion Texture in other nomenclature.
  44561. */
  44562. protected _ambientTexture: BaseTexture;
  44563. /**
  44564. * AKA Occlusion Texture Intensity in other nomenclature.
  44565. */
  44566. protected _ambientTextureStrength: number;
  44567. /**
  44568. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44569. * 1 means it completely occludes it
  44570. * 0 mean it has no impact
  44571. */
  44572. protected _ambientTextureImpactOnAnalyticalLights: number;
  44573. /**
  44574. * Stores the alpha values in a texture.
  44575. */
  44576. protected _opacityTexture: BaseTexture;
  44577. /**
  44578. * Stores the reflection values in a texture.
  44579. */
  44580. protected _reflectionTexture: BaseTexture;
  44581. /**
  44582. * Stores the refraction values in a texture.
  44583. */
  44584. protected _refractionTexture: BaseTexture;
  44585. /**
  44586. * Stores the emissive values in a texture.
  44587. */
  44588. protected _emissiveTexture: BaseTexture;
  44589. /**
  44590. * AKA Specular texture in other nomenclature.
  44591. */
  44592. protected _reflectivityTexture: BaseTexture;
  44593. /**
  44594. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44595. */
  44596. protected _metallicTexture: BaseTexture;
  44597. /**
  44598. * Specifies the metallic scalar of the metallic/roughness workflow.
  44599. * Can also be used to scale the metalness values of the metallic texture.
  44600. */
  44601. protected _metallic: Nullable<number>;
  44602. /**
  44603. * Specifies the roughness scalar of the metallic/roughness workflow.
  44604. * Can also be used to scale the roughness values of the metallic texture.
  44605. */
  44606. protected _roughness: Nullable<number>;
  44607. /**
  44608. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44609. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44610. */
  44611. protected _microSurfaceTexture: BaseTexture;
  44612. /**
  44613. * Stores surface normal data used to displace a mesh in a texture.
  44614. */
  44615. protected _bumpTexture: BaseTexture;
  44616. /**
  44617. * Stores the pre-calculated light information of a mesh in a texture.
  44618. */
  44619. protected _lightmapTexture: BaseTexture;
  44620. /**
  44621. * The color of a material in ambient lighting.
  44622. */
  44623. protected _ambientColor: Color3;
  44624. /**
  44625. * AKA Diffuse Color in other nomenclature.
  44626. */
  44627. protected _albedoColor: Color3;
  44628. /**
  44629. * AKA Specular Color in other nomenclature.
  44630. */
  44631. protected _reflectivityColor: Color3;
  44632. /**
  44633. * The color applied when light is reflected from a material.
  44634. */
  44635. protected _reflectionColor: Color3;
  44636. /**
  44637. * The color applied when light is emitted from a material.
  44638. */
  44639. protected _emissiveColor: Color3;
  44640. /**
  44641. * AKA Glossiness in other nomenclature.
  44642. */
  44643. protected _microSurface: number;
  44644. /**
  44645. * source material index of refraction (IOR)' / 'destination material IOR.
  44646. */
  44647. protected _indexOfRefraction: number;
  44648. /**
  44649. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44650. */
  44651. protected _invertRefractionY: boolean;
  44652. /**
  44653. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44654. * Materials half opaque for instance using refraction could benefit from this control.
  44655. */
  44656. protected _linkRefractionWithTransparency: boolean;
  44657. /**
  44658. * Specifies that the material will use the light map as a show map.
  44659. */
  44660. protected _useLightmapAsShadowmap: boolean;
  44661. /**
  44662. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44663. * makes the reflect vector face the model (under horizon).
  44664. */
  44665. protected _useHorizonOcclusion: boolean;
  44666. /**
  44667. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44668. * too much the area relying on ambient texture to define their ambient occlusion.
  44669. */
  44670. protected _useRadianceOcclusion: boolean;
  44671. /**
  44672. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44673. */
  44674. protected _useAlphaFromAlbedoTexture: boolean;
  44675. /**
  44676. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44677. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44678. */
  44679. protected _useSpecularOverAlpha: boolean;
  44680. /**
  44681. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44682. */
  44683. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44684. /**
  44685. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44686. */
  44687. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44688. /**
  44689. * Specifies if the metallic texture contains the roughness information in its green channel.
  44690. */
  44691. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44692. /**
  44693. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44694. */
  44695. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44696. /**
  44697. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44698. */
  44699. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44700. /**
  44701. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44702. */
  44703. protected _useAmbientInGrayScale: boolean;
  44704. /**
  44705. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44706. * The material will try to infer what glossiness each pixel should be.
  44707. */
  44708. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44709. /**
  44710. * Defines the falloff type used in this material.
  44711. * It by default is Physical.
  44712. */
  44713. protected _lightFalloff: number;
  44714. /**
  44715. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44716. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44717. */
  44718. protected _useRadianceOverAlpha: boolean;
  44719. /**
  44720. * Allows using an object space normal map (instead of tangent space).
  44721. */
  44722. protected _useObjectSpaceNormalMap: boolean;
  44723. /**
  44724. * Allows using the bump map in parallax mode.
  44725. */
  44726. protected _useParallax: boolean;
  44727. /**
  44728. * Allows using the bump map in parallax occlusion mode.
  44729. */
  44730. protected _useParallaxOcclusion: boolean;
  44731. /**
  44732. * Controls the scale bias of the parallax mode.
  44733. */
  44734. protected _parallaxScaleBias: number;
  44735. /**
  44736. * If sets to true, disables all the lights affecting the material.
  44737. */
  44738. protected _disableLighting: boolean;
  44739. /**
  44740. * Number of Simultaneous lights allowed on the material.
  44741. */
  44742. protected _maxSimultaneousLights: number;
  44743. /**
  44744. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44745. */
  44746. protected _invertNormalMapX: boolean;
  44747. /**
  44748. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44749. */
  44750. protected _invertNormalMapY: boolean;
  44751. /**
  44752. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44753. */
  44754. protected _twoSidedLighting: boolean;
  44755. /**
  44756. * Defines the alpha limits in alpha test mode.
  44757. */
  44758. protected _alphaCutOff: number;
  44759. /**
  44760. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44761. */
  44762. protected _forceAlphaTest: boolean;
  44763. /**
  44764. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44765. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44766. */
  44767. protected _useAlphaFresnel: boolean;
  44768. /**
  44769. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44770. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44771. */
  44772. protected _useLinearAlphaFresnel: boolean;
  44773. /**
  44774. * The transparency mode of the material.
  44775. */
  44776. protected _transparencyMode: Nullable<number>;
  44777. /**
  44778. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44779. * from cos thetav and roughness:
  44780. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44781. */
  44782. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44783. /**
  44784. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44785. */
  44786. protected _forceIrradianceInFragment: boolean;
  44787. /**
  44788. * Force normal to face away from face.
  44789. */
  44790. protected _forceNormalForward: boolean;
  44791. /**
  44792. * Enables specular anti aliasing in the PBR shader.
  44793. * It will both interacts on the Geometry for analytical and IBL lighting.
  44794. * It also prefilter the roughness map based on the bump values.
  44795. */
  44796. protected _enableSpecularAntiAliasing: boolean;
  44797. /**
  44798. * Default configuration related to image processing available in the PBR Material.
  44799. */
  44800. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44801. /**
  44802. * Keep track of the image processing observer to allow dispose and replace.
  44803. */
  44804. private _imageProcessingObserver;
  44805. /**
  44806. * Attaches a new image processing configuration to the PBR Material.
  44807. * @param configuration
  44808. */
  44809. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44810. /**
  44811. * Stores the available render targets.
  44812. */
  44813. private _renderTargets;
  44814. /**
  44815. * Sets the global ambient color for the material used in lighting calculations.
  44816. */
  44817. private _globalAmbientColor;
  44818. /**
  44819. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44820. */
  44821. private _useLogarithmicDepth;
  44822. /**
  44823. * If set to true, no lighting calculations will be applied.
  44824. */
  44825. private _unlit;
  44826. /**
  44827. * Instantiates a new PBRMaterial instance.
  44828. *
  44829. * @param name The material name
  44830. * @param scene The scene the material will be use in.
  44831. */
  44832. constructor(name: string, scene: Scene);
  44833. /**
  44834. * Gets a boolean indicating that current material needs to register RTT
  44835. */
  44836. readonly hasRenderTargetTextures: boolean;
  44837. /**
  44838. * Gets the name of the material class.
  44839. */
  44840. getClassName(): string;
  44841. /**
  44842. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44843. */
  44844. /**
  44845. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44846. */
  44847. useLogarithmicDepth: boolean;
  44848. /**
  44849. * Gets the current transparency mode.
  44850. */
  44851. /**
  44852. * Sets the transparency mode of the material.
  44853. *
  44854. * | Value | Type | Description |
  44855. * | ----- | ----------------------------------- | ----------- |
  44856. * | 0 | OPAQUE | |
  44857. * | 1 | ALPHATEST | |
  44858. * | 2 | ALPHABLEND | |
  44859. * | 3 | ALPHATESTANDBLEND | |
  44860. *
  44861. */
  44862. transparencyMode: Nullable<number>;
  44863. /**
  44864. * Returns true if alpha blending should be disabled.
  44865. */
  44866. private readonly _disableAlphaBlending;
  44867. /**
  44868. * Specifies whether or not this material should be rendered in alpha blend mode.
  44869. */
  44870. needAlphaBlending(): boolean;
  44871. /**
  44872. * Specifies if the mesh will require alpha blending.
  44873. * @param mesh - BJS mesh.
  44874. */
  44875. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44876. /**
  44877. * Specifies whether or not this material should be rendered in alpha test mode.
  44878. */
  44879. needAlphaTesting(): boolean;
  44880. /**
  44881. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44882. */
  44883. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44884. /**
  44885. * Gets the texture used for the alpha test.
  44886. */
  44887. getAlphaTestTexture(): BaseTexture;
  44888. /**
  44889. * Specifies that the submesh is ready to be used.
  44890. * @param mesh - BJS mesh.
  44891. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44892. * @param useInstances - Specifies that instances should be used.
  44893. * @returns - boolean indicating that the submesh is ready or not.
  44894. */
  44895. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44896. /**
  44897. * Specifies if the material uses metallic roughness workflow.
  44898. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44899. */
  44900. isMetallicWorkflow(): boolean;
  44901. private _prepareEffect;
  44902. private _prepareDefines;
  44903. /**
  44904. * Force shader compilation
  44905. */
  44906. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44907. clipPlane: boolean;
  44908. }>): void;
  44909. /**
  44910. * Initializes the uniform buffer layout for the shader.
  44911. */
  44912. buildUniformLayout(): void;
  44913. /**
  44914. * Unbinds the textures.
  44915. */
  44916. unbind(): void;
  44917. /**
  44918. * Binds the submesh data.
  44919. * @param world - The world matrix.
  44920. * @param mesh - The BJS mesh.
  44921. * @param subMesh - A submesh of the BJS mesh.
  44922. */
  44923. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44924. /**
  44925. * Returns the animatable textures.
  44926. * @returns - Array of animatable textures.
  44927. */
  44928. getAnimatables(): IAnimatable[];
  44929. /**
  44930. * Returns the texture used for reflections.
  44931. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44932. */
  44933. private _getReflectionTexture;
  44934. /**
  44935. * Returns the texture used for refraction or null if none is used.
  44936. * @returns - Refection texture if present. If no refraction texture and refraction
  44937. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44938. */
  44939. private _getRefractionTexture;
  44940. /**
  44941. * Disposes the resources of the material.
  44942. * @param forceDisposeEffect - Forces the disposal of effects.
  44943. * @param forceDisposeTextures - Forces the disposal of all textures.
  44944. */
  44945. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44946. }
  44947. }
  44948. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  44949. import { Nullable } from "babylonjs/types";
  44950. import { Scene } from "babylonjs/scene";
  44951. import { Color3 } from "babylonjs/Maths/math";
  44952. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44953. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44954. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44955. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  44956. /**
  44957. * The Physically based material of BJS.
  44958. *
  44959. * This offers the main features of a standard PBR material.
  44960. * For more information, please refer to the documentation :
  44961. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44962. */
  44963. export class PBRMaterial extends PBRBaseMaterial {
  44964. /**
  44965. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44966. */
  44967. static readonly PBRMATERIAL_OPAQUE: number;
  44968. /**
  44969. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44970. */
  44971. static readonly PBRMATERIAL_ALPHATEST: number;
  44972. /**
  44973. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44974. */
  44975. static readonly PBRMATERIAL_ALPHABLEND: number;
  44976. /**
  44977. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44978. * They are also discarded below the alpha cutoff threshold to improve performances.
  44979. */
  44980. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44981. /**
  44982. * Defines the default value of how much AO map is occluding the analytical lights
  44983. * (point spot...).
  44984. */
  44985. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44986. /**
  44987. * Intensity of the direct lights e.g. the four lights available in your scene.
  44988. * This impacts both the direct diffuse and specular highlights.
  44989. */
  44990. directIntensity: number;
  44991. /**
  44992. * Intensity of the emissive part of the material.
  44993. * This helps controlling the emissive effect without modifying the emissive color.
  44994. */
  44995. emissiveIntensity: number;
  44996. /**
  44997. * Intensity of the environment e.g. how much the environment will light the object
  44998. * either through harmonics for rough material or through the refelction for shiny ones.
  44999. */
  45000. environmentIntensity: number;
  45001. /**
  45002. * This is a special control allowing the reduction of the specular highlights coming from the
  45003. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45004. */
  45005. specularIntensity: number;
  45006. /**
  45007. * Debug Control allowing disabling the bump map on this material.
  45008. */
  45009. disableBumpMap: boolean;
  45010. /**
  45011. * AKA Diffuse Texture in standard nomenclature.
  45012. */
  45013. albedoTexture: BaseTexture;
  45014. /**
  45015. * AKA Occlusion Texture in other nomenclature.
  45016. */
  45017. ambientTexture: BaseTexture;
  45018. /**
  45019. * AKA Occlusion Texture Intensity in other nomenclature.
  45020. */
  45021. ambientTextureStrength: number;
  45022. /**
  45023. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45024. * 1 means it completely occludes it
  45025. * 0 mean it has no impact
  45026. */
  45027. ambientTextureImpactOnAnalyticalLights: number;
  45028. /**
  45029. * Stores the alpha values in a texture.
  45030. */
  45031. opacityTexture: BaseTexture;
  45032. /**
  45033. * Stores the reflection values in a texture.
  45034. */
  45035. reflectionTexture: Nullable<BaseTexture>;
  45036. /**
  45037. * Stores the emissive values in a texture.
  45038. */
  45039. emissiveTexture: BaseTexture;
  45040. /**
  45041. * AKA Specular texture in other nomenclature.
  45042. */
  45043. reflectivityTexture: BaseTexture;
  45044. /**
  45045. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45046. */
  45047. metallicTexture: BaseTexture;
  45048. /**
  45049. * Specifies the metallic scalar of the metallic/roughness workflow.
  45050. * Can also be used to scale the metalness values of the metallic texture.
  45051. */
  45052. metallic: Nullable<number>;
  45053. /**
  45054. * Specifies the roughness scalar of the metallic/roughness workflow.
  45055. * Can also be used to scale the roughness values of the metallic texture.
  45056. */
  45057. roughness: Nullable<number>;
  45058. /**
  45059. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45060. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45061. */
  45062. microSurfaceTexture: BaseTexture;
  45063. /**
  45064. * Stores surface normal data used to displace a mesh in a texture.
  45065. */
  45066. bumpTexture: BaseTexture;
  45067. /**
  45068. * Stores the pre-calculated light information of a mesh in a texture.
  45069. */
  45070. lightmapTexture: BaseTexture;
  45071. /**
  45072. * Stores the refracted light information in a texture.
  45073. */
  45074. refractionTexture: BaseTexture;
  45075. /**
  45076. * The color of a material in ambient lighting.
  45077. */
  45078. ambientColor: Color3;
  45079. /**
  45080. * AKA Diffuse Color in other nomenclature.
  45081. */
  45082. albedoColor: Color3;
  45083. /**
  45084. * AKA Specular Color in other nomenclature.
  45085. */
  45086. reflectivityColor: Color3;
  45087. /**
  45088. * The color reflected from the material.
  45089. */
  45090. reflectionColor: Color3;
  45091. /**
  45092. * The color emitted from the material.
  45093. */
  45094. emissiveColor: Color3;
  45095. /**
  45096. * AKA Glossiness in other nomenclature.
  45097. */
  45098. microSurface: number;
  45099. /**
  45100. * source material index of refraction (IOR)' / 'destination material IOR.
  45101. */
  45102. indexOfRefraction: number;
  45103. /**
  45104. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45105. */
  45106. invertRefractionY: boolean;
  45107. /**
  45108. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45109. * Materials half opaque for instance using refraction could benefit from this control.
  45110. */
  45111. linkRefractionWithTransparency: boolean;
  45112. /**
  45113. * If true, the light map contains occlusion information instead of lighting info.
  45114. */
  45115. useLightmapAsShadowmap: boolean;
  45116. /**
  45117. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45118. */
  45119. useAlphaFromAlbedoTexture: boolean;
  45120. /**
  45121. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45122. */
  45123. forceAlphaTest: boolean;
  45124. /**
  45125. * Defines the alpha limits in alpha test mode.
  45126. */
  45127. alphaCutOff: number;
  45128. /**
  45129. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45130. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45131. */
  45132. useSpecularOverAlpha: boolean;
  45133. /**
  45134. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45135. */
  45136. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45137. /**
  45138. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45139. */
  45140. useRoughnessFromMetallicTextureAlpha: boolean;
  45141. /**
  45142. * Specifies if the metallic texture contains the roughness information in its green channel.
  45143. */
  45144. useRoughnessFromMetallicTextureGreen: boolean;
  45145. /**
  45146. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45147. */
  45148. useMetallnessFromMetallicTextureBlue: boolean;
  45149. /**
  45150. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45151. */
  45152. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45153. /**
  45154. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45155. */
  45156. useAmbientInGrayScale: boolean;
  45157. /**
  45158. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45159. * The material will try to infer what glossiness each pixel should be.
  45160. */
  45161. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45162. /**
  45163. * BJS is using an harcoded light falloff based on a manually sets up range.
  45164. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45165. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45166. */
  45167. /**
  45168. * BJS is using an harcoded light falloff based on a manually sets up range.
  45169. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45170. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45171. */
  45172. usePhysicalLightFalloff: boolean;
  45173. /**
  45174. * In order to support the falloff compatibility with gltf, a special mode has been added
  45175. * to reproduce the gltf light falloff.
  45176. */
  45177. /**
  45178. * In order to support the falloff compatibility with gltf, a special mode has been added
  45179. * to reproduce the gltf light falloff.
  45180. */
  45181. useGLTFLightFalloff: boolean;
  45182. /**
  45183. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45184. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45185. */
  45186. useRadianceOverAlpha: boolean;
  45187. /**
  45188. * Allows using an object space normal map (instead of tangent space).
  45189. */
  45190. useObjectSpaceNormalMap: boolean;
  45191. /**
  45192. * Allows using the bump map in parallax mode.
  45193. */
  45194. useParallax: boolean;
  45195. /**
  45196. * Allows using the bump map in parallax occlusion mode.
  45197. */
  45198. useParallaxOcclusion: boolean;
  45199. /**
  45200. * Controls the scale bias of the parallax mode.
  45201. */
  45202. parallaxScaleBias: number;
  45203. /**
  45204. * If sets to true, disables all the lights affecting the material.
  45205. */
  45206. disableLighting: boolean;
  45207. /**
  45208. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45209. */
  45210. forceIrradianceInFragment: boolean;
  45211. /**
  45212. * Number of Simultaneous lights allowed on the material.
  45213. */
  45214. maxSimultaneousLights: number;
  45215. /**
  45216. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45217. */
  45218. invertNormalMapX: boolean;
  45219. /**
  45220. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45221. */
  45222. invertNormalMapY: boolean;
  45223. /**
  45224. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45225. */
  45226. twoSidedLighting: boolean;
  45227. /**
  45228. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45229. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45230. */
  45231. useAlphaFresnel: boolean;
  45232. /**
  45233. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45234. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45235. */
  45236. useLinearAlphaFresnel: boolean;
  45237. /**
  45238. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45239. * And/Or occlude the blended part.
  45240. */
  45241. environmentBRDFTexture: Nullable<BaseTexture>;
  45242. /**
  45243. * Force normal to face away from face.
  45244. */
  45245. forceNormalForward: boolean;
  45246. /**
  45247. * Enables specular anti aliasing in the PBR shader.
  45248. * It will both interacts on the Geometry for analytical and IBL lighting.
  45249. * It also prefilter the roughness map based on the bump values.
  45250. */
  45251. enableSpecularAntiAliasing: boolean;
  45252. /**
  45253. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45254. * makes the reflect vector face the model (under horizon).
  45255. */
  45256. useHorizonOcclusion: boolean;
  45257. /**
  45258. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45259. * too much the area relying on ambient texture to define their ambient occlusion.
  45260. */
  45261. useRadianceOcclusion: boolean;
  45262. /**
  45263. * If set to true, no lighting calculations will be applied.
  45264. */
  45265. unlit: boolean;
  45266. /**
  45267. * Gets the image processing configuration used either in this material.
  45268. */
  45269. /**
  45270. * Sets the Default image processing configuration used either in the this material.
  45271. *
  45272. * If sets to null, the scene one is in use.
  45273. */
  45274. imageProcessingConfiguration: ImageProcessingConfiguration;
  45275. /**
  45276. * Gets wether the color curves effect is enabled.
  45277. */
  45278. /**
  45279. * Sets wether the color curves effect is enabled.
  45280. */
  45281. cameraColorCurvesEnabled: boolean;
  45282. /**
  45283. * Gets wether the color grading effect is enabled.
  45284. */
  45285. /**
  45286. * Gets wether the color grading effect is enabled.
  45287. */
  45288. cameraColorGradingEnabled: boolean;
  45289. /**
  45290. * Gets wether tonemapping is enabled or not.
  45291. */
  45292. /**
  45293. * Sets wether tonemapping is enabled or not
  45294. */
  45295. cameraToneMappingEnabled: boolean;
  45296. /**
  45297. * The camera exposure used on this material.
  45298. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45299. * This corresponds to a photographic exposure.
  45300. */
  45301. /**
  45302. * The camera exposure used on this material.
  45303. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45304. * This corresponds to a photographic exposure.
  45305. */
  45306. cameraExposure: number;
  45307. /**
  45308. * Gets The camera contrast used on this material.
  45309. */
  45310. /**
  45311. * Sets The camera contrast used on this material.
  45312. */
  45313. cameraContrast: number;
  45314. /**
  45315. * Gets the Color Grading 2D Lookup Texture.
  45316. */
  45317. /**
  45318. * Sets the Color Grading 2D Lookup Texture.
  45319. */
  45320. cameraColorGradingTexture: Nullable<BaseTexture>;
  45321. /**
  45322. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45323. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45324. * 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;
  45325. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45326. */
  45327. /**
  45328. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45329. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45330. * 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;
  45331. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45332. */
  45333. cameraColorCurves: Nullable<ColorCurves>;
  45334. /**
  45335. * Instantiates a new PBRMaterial instance.
  45336. *
  45337. * @param name The material name
  45338. * @param scene The scene the material will be use in.
  45339. */
  45340. constructor(name: string, scene: Scene);
  45341. /**
  45342. * Returns the name of this material class.
  45343. */
  45344. getClassName(): string;
  45345. /**
  45346. * Returns an array of the actively used textures.
  45347. * @returns - Array of BaseTextures
  45348. */
  45349. getActiveTextures(): BaseTexture[];
  45350. /**
  45351. * Checks to see if a texture is used in the material.
  45352. * @param texture - Base texture to use.
  45353. * @returns - Boolean specifying if a texture is used in the material.
  45354. */
  45355. hasTexture(texture: BaseTexture): boolean;
  45356. /**
  45357. * Makes a duplicate of the current material.
  45358. * @param name - name to use for the new material.
  45359. */
  45360. clone(name: string): PBRMaterial;
  45361. /**
  45362. * Serializes this PBR Material.
  45363. * @returns - An object with the serialized material.
  45364. */
  45365. serialize(): any;
  45366. /**
  45367. * Parses a PBR Material from a serialized object.
  45368. * @param source - Serialized object.
  45369. * @param scene - BJS scene instance.
  45370. * @param rootUrl - url for the scene object
  45371. * @returns - PBRMaterial
  45372. */
  45373. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45374. }
  45375. }
  45376. declare module "babylonjs/Helpers/sceneHelpers" {
  45377. import { Nullable } from "babylonjs/types";
  45378. import { Mesh } from "babylonjs/Meshes/mesh";
  45379. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45380. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  45381. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45382. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  45383. import "babylonjs/Meshes/meshBuilder";
  45384. /** @hidden */
  45385. export var _forceSceneHelpersToBundle: boolean;
  45386. module "babylonjs/scene" {
  45387. interface Scene {
  45388. /**
  45389. * Creates a default light for the scene.
  45390. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45391. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45392. */
  45393. createDefaultLight(replace?: boolean): void;
  45394. /**
  45395. * Creates a default camera for the scene.
  45396. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45397. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45398. * @param replace has default false, when true replaces the active camera in the scene
  45399. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45400. */
  45401. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45402. /**
  45403. * Creates a default camera and a default light.
  45404. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45405. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45406. * @param replace has the default false, when true replaces the active camera/light in the scene
  45407. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45408. */
  45409. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45410. /**
  45411. * Creates a new sky box
  45412. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45413. * @param environmentTexture defines the texture to use as environment texture
  45414. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45415. * @param scale defines the overall scale of the skybox
  45416. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45417. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45418. * @returns a new mesh holding the sky box
  45419. */
  45420. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45421. /**
  45422. * Creates a new environment
  45423. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45424. * @param options defines the options you can use to configure the environment
  45425. * @returns the new EnvironmentHelper
  45426. */
  45427. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45428. /**
  45429. * Creates a new VREXperienceHelper
  45430. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45431. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45432. * @returns a new VREXperienceHelper
  45433. */
  45434. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45435. /**
  45436. * Creates a new XREXperienceHelper
  45437. * @see http://doc.babylonjs.com/how_to/webxr
  45438. * @returns a promise for a new XREXperienceHelper
  45439. */
  45440. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45441. }
  45442. }
  45443. }
  45444. declare module "babylonjs/Helpers/videoDome" {
  45445. import { Scene } from "babylonjs/scene";
  45446. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45447. import { Mesh } from "babylonjs/Meshes/mesh";
  45448. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  45449. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45450. import "babylonjs/Meshes/meshBuilder";
  45451. /**
  45452. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45453. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45454. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45455. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45456. */
  45457. export class VideoDome extends TransformNode {
  45458. private _useDirectMapping;
  45459. /**
  45460. * The video texture being displayed on the sphere
  45461. */
  45462. protected _videoTexture: VideoTexture;
  45463. /**
  45464. * Gets the video texture being displayed on the sphere
  45465. */
  45466. readonly videoTexture: VideoTexture;
  45467. /**
  45468. * The skybox material
  45469. */
  45470. protected _material: BackgroundMaterial;
  45471. /**
  45472. * The surface used for the skybox
  45473. */
  45474. protected _mesh: Mesh;
  45475. /**
  45476. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45477. * Also see the options.resolution property.
  45478. */
  45479. fovMultiplier: number;
  45480. /**
  45481. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45482. * @param name Element's name, child elements will append suffixes for their own names.
  45483. * @param urlsOrVideo defines the url(s) or the video element to use
  45484. * @param options An object containing optional or exposed sub element properties
  45485. */
  45486. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45487. resolution?: number;
  45488. clickToPlay?: boolean;
  45489. autoPlay?: boolean;
  45490. loop?: boolean;
  45491. size?: number;
  45492. poster?: string;
  45493. useDirectMapping?: boolean;
  45494. }, scene: Scene);
  45495. /**
  45496. * Releases resources associated with this node.
  45497. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45498. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45499. */
  45500. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45501. }
  45502. }
  45503. declare module "babylonjs/Helpers/index" {
  45504. export * from "babylonjs/Helpers/environmentHelper";
  45505. export * from "babylonjs/Helpers/photoDome";
  45506. export * from "babylonjs/Helpers/sceneHelpers";
  45507. export * from "babylonjs/Helpers/videoDome";
  45508. }
  45509. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45510. import { PerfCounter } from "babylonjs/Misc/tools";
  45511. import { IDisposable } from "babylonjs/scene";
  45512. import { Engine } from "babylonjs/Engines/engine";
  45513. /**
  45514. * This class can be used to get instrumentation data from a Babylon engine
  45515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45516. */
  45517. export class EngineInstrumentation implements IDisposable {
  45518. /**
  45519. * Define the instrumented engine.
  45520. */
  45521. engine: Engine;
  45522. private _captureGPUFrameTime;
  45523. private _gpuFrameTimeToken;
  45524. private _gpuFrameTime;
  45525. private _captureShaderCompilationTime;
  45526. private _shaderCompilationTime;
  45527. private _onBeginFrameObserver;
  45528. private _onEndFrameObserver;
  45529. private _onBeforeShaderCompilationObserver;
  45530. private _onAfterShaderCompilationObserver;
  45531. /**
  45532. * Gets the perf counter used for GPU frame time
  45533. */
  45534. readonly gpuFrameTimeCounter: PerfCounter;
  45535. /**
  45536. * Gets the GPU frame time capture status
  45537. */
  45538. /**
  45539. * Enable or disable the GPU frame time capture
  45540. */
  45541. captureGPUFrameTime: boolean;
  45542. /**
  45543. * Gets the perf counter used for shader compilation time
  45544. */
  45545. readonly shaderCompilationTimeCounter: PerfCounter;
  45546. /**
  45547. * Gets the shader compilation time capture status
  45548. */
  45549. /**
  45550. * Enable or disable the shader compilation time capture
  45551. */
  45552. captureShaderCompilationTime: boolean;
  45553. /**
  45554. * Instantiates a new engine instrumentation.
  45555. * This class can be used to get instrumentation data from a Babylon engine
  45556. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45557. * @param engine Defines the engine to instrument
  45558. */
  45559. constructor(
  45560. /**
  45561. * Define the instrumented engine.
  45562. */
  45563. engine: Engine);
  45564. /**
  45565. * Dispose and release associated resources.
  45566. */
  45567. dispose(): void;
  45568. }
  45569. }
  45570. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45571. import { PerfCounter } from "babylonjs/Misc/tools";
  45572. import { Scene, IDisposable } from "babylonjs/scene";
  45573. /**
  45574. * This class can be used to get instrumentation data from a Babylon engine
  45575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45576. */
  45577. export class SceneInstrumentation implements IDisposable {
  45578. /**
  45579. * Defines the scene to instrument
  45580. */
  45581. scene: Scene;
  45582. private _captureActiveMeshesEvaluationTime;
  45583. private _activeMeshesEvaluationTime;
  45584. private _captureRenderTargetsRenderTime;
  45585. private _renderTargetsRenderTime;
  45586. private _captureFrameTime;
  45587. private _frameTime;
  45588. private _captureRenderTime;
  45589. private _renderTime;
  45590. private _captureInterFrameTime;
  45591. private _interFrameTime;
  45592. private _captureParticlesRenderTime;
  45593. private _particlesRenderTime;
  45594. private _captureSpritesRenderTime;
  45595. private _spritesRenderTime;
  45596. private _capturePhysicsTime;
  45597. private _physicsTime;
  45598. private _captureAnimationsTime;
  45599. private _animationsTime;
  45600. private _captureCameraRenderTime;
  45601. private _cameraRenderTime;
  45602. private _onBeforeActiveMeshesEvaluationObserver;
  45603. private _onAfterActiveMeshesEvaluationObserver;
  45604. private _onBeforeRenderTargetsRenderObserver;
  45605. private _onAfterRenderTargetsRenderObserver;
  45606. private _onAfterRenderObserver;
  45607. private _onBeforeDrawPhaseObserver;
  45608. private _onAfterDrawPhaseObserver;
  45609. private _onBeforeAnimationsObserver;
  45610. private _onBeforeParticlesRenderingObserver;
  45611. private _onAfterParticlesRenderingObserver;
  45612. private _onBeforeSpritesRenderingObserver;
  45613. private _onAfterSpritesRenderingObserver;
  45614. private _onBeforePhysicsObserver;
  45615. private _onAfterPhysicsObserver;
  45616. private _onAfterAnimationsObserver;
  45617. private _onBeforeCameraRenderObserver;
  45618. private _onAfterCameraRenderObserver;
  45619. /**
  45620. * Gets the perf counter used for active meshes evaluation time
  45621. */
  45622. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45623. /**
  45624. * Gets the active meshes evaluation time capture status
  45625. */
  45626. /**
  45627. * Enable or disable the active meshes evaluation time capture
  45628. */
  45629. captureActiveMeshesEvaluationTime: boolean;
  45630. /**
  45631. * Gets the perf counter used for render targets render time
  45632. */
  45633. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45634. /**
  45635. * Gets the render targets render time capture status
  45636. */
  45637. /**
  45638. * Enable or disable the render targets render time capture
  45639. */
  45640. captureRenderTargetsRenderTime: boolean;
  45641. /**
  45642. * Gets the perf counter used for particles render time
  45643. */
  45644. readonly particlesRenderTimeCounter: PerfCounter;
  45645. /**
  45646. * Gets the particles render time capture status
  45647. */
  45648. /**
  45649. * Enable or disable the particles render time capture
  45650. */
  45651. captureParticlesRenderTime: boolean;
  45652. /**
  45653. * Gets the perf counter used for sprites render time
  45654. */
  45655. readonly spritesRenderTimeCounter: PerfCounter;
  45656. /**
  45657. * Gets the sprites render time capture status
  45658. */
  45659. /**
  45660. * Enable or disable the sprites render time capture
  45661. */
  45662. captureSpritesRenderTime: boolean;
  45663. /**
  45664. * Gets the perf counter used for physics time
  45665. */
  45666. readonly physicsTimeCounter: PerfCounter;
  45667. /**
  45668. * Gets the physics time capture status
  45669. */
  45670. /**
  45671. * Enable or disable the physics time capture
  45672. */
  45673. capturePhysicsTime: boolean;
  45674. /**
  45675. * Gets the perf counter used for animations time
  45676. */
  45677. readonly animationsTimeCounter: PerfCounter;
  45678. /**
  45679. * Gets the animations time capture status
  45680. */
  45681. /**
  45682. * Enable or disable the animations time capture
  45683. */
  45684. captureAnimationsTime: boolean;
  45685. /**
  45686. * Gets the perf counter used for frame time capture
  45687. */
  45688. readonly frameTimeCounter: PerfCounter;
  45689. /**
  45690. * Gets the frame time capture status
  45691. */
  45692. /**
  45693. * Enable or disable the frame time capture
  45694. */
  45695. captureFrameTime: boolean;
  45696. /**
  45697. * Gets the perf counter used for inter-frames time capture
  45698. */
  45699. readonly interFrameTimeCounter: PerfCounter;
  45700. /**
  45701. * Gets the inter-frames time capture status
  45702. */
  45703. /**
  45704. * Enable or disable the inter-frames time capture
  45705. */
  45706. captureInterFrameTime: boolean;
  45707. /**
  45708. * Gets the perf counter used for render time capture
  45709. */
  45710. readonly renderTimeCounter: PerfCounter;
  45711. /**
  45712. * Gets the render time capture status
  45713. */
  45714. /**
  45715. * Enable or disable the render time capture
  45716. */
  45717. captureRenderTime: boolean;
  45718. /**
  45719. * Gets the perf counter used for camera render time capture
  45720. */
  45721. readonly cameraRenderTimeCounter: PerfCounter;
  45722. /**
  45723. * Gets the camera render time capture status
  45724. */
  45725. /**
  45726. * Enable or disable the camera render time capture
  45727. */
  45728. captureCameraRenderTime: boolean;
  45729. /**
  45730. * Gets the perf counter used for draw calls
  45731. */
  45732. readonly drawCallsCounter: PerfCounter;
  45733. /**
  45734. * Gets the perf counter used for texture collisions
  45735. */
  45736. readonly textureCollisionsCounter: PerfCounter;
  45737. /**
  45738. * Instantiates a new scene instrumentation.
  45739. * This class can be used to get instrumentation data from a Babylon engine
  45740. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45741. * @param scene Defines the scene to instrument
  45742. */
  45743. constructor(
  45744. /**
  45745. * Defines the scene to instrument
  45746. */
  45747. scene: Scene);
  45748. /**
  45749. * Dispose and release associated resources.
  45750. */
  45751. dispose(): void;
  45752. }
  45753. }
  45754. declare module "babylonjs/Instrumentation/index" {
  45755. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45756. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45757. export * from "babylonjs/Instrumentation/timeToken";
  45758. }
  45759. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45760. /** @hidden */
  45761. export var glowMapGenerationPixelShader: {
  45762. name: string;
  45763. shader: string;
  45764. };
  45765. }
  45766. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45767. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45768. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45769. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45770. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45771. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45772. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45773. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45774. /** @hidden */
  45775. export var glowMapGenerationVertexShader: {
  45776. name: string;
  45777. shader: string;
  45778. };
  45779. }
  45780. declare module "babylonjs/Layers/effectLayer" {
  45781. import { Observable } from "babylonjs/Misc/observable";
  45782. import { Nullable } from "babylonjs/types";
  45783. import { Camera } from "babylonjs/Cameras/camera";
  45784. import { Scene } from "babylonjs/scene";
  45785. import { Color4, ISize } from "babylonjs/Maths/math";
  45786. import { Engine } from "babylonjs/Engines/engine";
  45787. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45789. import { Mesh } from "babylonjs/Meshes/mesh";
  45790. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45791. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45792. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45793. import { Effect } from "babylonjs/Materials/effect";
  45794. import { Material } from "babylonjs/Materials/material";
  45795. import "babylonjs/Shaders/glowMapGeneration.fragment";
  45796. import "babylonjs/Shaders/glowMapGeneration.vertex";
  45797. /**
  45798. * Effect layer options. This helps customizing the behaviour
  45799. * of the effect layer.
  45800. */
  45801. export interface IEffectLayerOptions {
  45802. /**
  45803. * Multiplication factor apply to the canvas size to compute the render target size
  45804. * used to generated the objects (the smaller the faster).
  45805. */
  45806. mainTextureRatio: number;
  45807. /**
  45808. * Enforces a fixed size texture to ensure effect stability across devices.
  45809. */
  45810. mainTextureFixedSize?: number;
  45811. /**
  45812. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45813. */
  45814. alphaBlendingMode: number;
  45815. /**
  45816. * The camera attached to the layer.
  45817. */
  45818. camera: Nullable<Camera>;
  45819. /**
  45820. * The rendering group to draw the layer in.
  45821. */
  45822. renderingGroupId: number;
  45823. }
  45824. /**
  45825. * The effect layer Helps adding post process effect blended with the main pass.
  45826. *
  45827. * This can be for instance use to generate glow or higlight effects on the scene.
  45828. *
  45829. * The effect layer class can not be used directly and is intented to inherited from to be
  45830. * customized per effects.
  45831. */
  45832. export abstract class EffectLayer {
  45833. private _vertexBuffers;
  45834. private _indexBuffer;
  45835. private _cachedDefines;
  45836. private _effectLayerMapGenerationEffect;
  45837. private _effectLayerOptions;
  45838. private _mergeEffect;
  45839. protected _scene: Scene;
  45840. protected _engine: Engine;
  45841. protected _maxSize: number;
  45842. protected _mainTextureDesiredSize: ISize;
  45843. protected _mainTexture: RenderTargetTexture;
  45844. protected _shouldRender: boolean;
  45845. protected _postProcesses: PostProcess[];
  45846. protected _textures: BaseTexture[];
  45847. protected _emissiveTextureAndColor: {
  45848. texture: Nullable<BaseTexture>;
  45849. color: Color4;
  45850. };
  45851. /**
  45852. * The name of the layer
  45853. */
  45854. name: string;
  45855. /**
  45856. * The clear color of the texture used to generate the glow map.
  45857. */
  45858. neutralColor: Color4;
  45859. /**
  45860. * Specifies wether the highlight layer is enabled or not.
  45861. */
  45862. isEnabled: boolean;
  45863. /**
  45864. * Gets the camera attached to the layer.
  45865. */
  45866. readonly camera: Nullable<Camera>;
  45867. /**
  45868. * Gets the rendering group id the layer should render in.
  45869. */
  45870. readonly renderingGroupId: number;
  45871. /**
  45872. * An event triggered when the effect layer has been disposed.
  45873. */
  45874. onDisposeObservable: Observable<EffectLayer>;
  45875. /**
  45876. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45877. */
  45878. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45879. /**
  45880. * An event triggered when the generated texture is being merged in the scene.
  45881. */
  45882. onBeforeComposeObservable: Observable<EffectLayer>;
  45883. /**
  45884. * An event triggered when the generated texture has been merged in the scene.
  45885. */
  45886. onAfterComposeObservable: Observable<EffectLayer>;
  45887. /**
  45888. * An event triggered when the efffect layer changes its size.
  45889. */
  45890. onSizeChangedObservable: Observable<EffectLayer>;
  45891. /** @hidden */
  45892. static _SceneComponentInitialization: (scene: Scene) => void;
  45893. /**
  45894. * Instantiates a new effect Layer and references it in the scene.
  45895. * @param name The name of the layer
  45896. * @param scene The scene to use the layer in
  45897. */
  45898. constructor(
  45899. /** The Friendly of the effect in the scene */
  45900. name: string, scene: Scene);
  45901. /**
  45902. * Get the effect name of the layer.
  45903. * @return The effect name
  45904. */
  45905. abstract getEffectName(): string;
  45906. /**
  45907. * Checks for the readiness of the element composing the layer.
  45908. * @param subMesh the mesh to check for
  45909. * @param useInstances specify wether or not to use instances to render the mesh
  45910. * @return true if ready otherwise, false
  45911. */
  45912. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45913. /**
  45914. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45915. * @returns true if the effect requires stencil during the main canvas render pass.
  45916. */
  45917. abstract needStencil(): boolean;
  45918. /**
  45919. * Create the merge effect. This is the shader use to blit the information back
  45920. * to the main canvas at the end of the scene rendering.
  45921. * @returns The effect containing the shader used to merge the effect on the main canvas
  45922. */
  45923. protected abstract _createMergeEffect(): Effect;
  45924. /**
  45925. * Creates the render target textures and post processes used in the effect layer.
  45926. */
  45927. protected abstract _createTextureAndPostProcesses(): void;
  45928. /**
  45929. * Implementation specific of rendering the generating effect on the main canvas.
  45930. * @param effect The effect used to render through
  45931. */
  45932. protected abstract _internalRender(effect: Effect): void;
  45933. /**
  45934. * Sets the required values for both the emissive texture and and the main color.
  45935. */
  45936. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45937. /**
  45938. * Free any resources and references associated to a mesh.
  45939. * Internal use
  45940. * @param mesh The mesh to free.
  45941. */
  45942. abstract _disposeMesh(mesh: Mesh): void;
  45943. /**
  45944. * Serializes this layer (Glow or Highlight for example)
  45945. * @returns a serialized layer object
  45946. */
  45947. abstract serialize?(): any;
  45948. /**
  45949. * Initializes the effect layer with the required options.
  45950. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45951. */
  45952. protected _init(options: Partial<IEffectLayerOptions>): void;
  45953. /**
  45954. * Generates the index buffer of the full screen quad blending to the main canvas.
  45955. */
  45956. private _generateIndexBuffer;
  45957. /**
  45958. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45959. */
  45960. private _genrateVertexBuffer;
  45961. /**
  45962. * Sets the main texture desired size which is the closest power of two
  45963. * of the engine canvas size.
  45964. */
  45965. private _setMainTextureSize;
  45966. /**
  45967. * Creates the main texture for the effect layer.
  45968. */
  45969. protected _createMainTexture(): void;
  45970. /**
  45971. * Adds specific effects defines.
  45972. * @param defines The defines to add specifics to.
  45973. */
  45974. protected _addCustomEffectDefines(defines: string[]): void;
  45975. /**
  45976. * Checks for the readiness of the element composing the layer.
  45977. * @param subMesh the mesh to check for
  45978. * @param useInstances specify wether or not to use instances to render the mesh
  45979. * @param emissiveTexture the associated emissive texture used to generate the glow
  45980. * @return true if ready otherwise, false
  45981. */
  45982. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45983. /**
  45984. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45985. */
  45986. render(): void;
  45987. /**
  45988. * Determine if a given mesh will be used in the current effect.
  45989. * @param mesh mesh to test
  45990. * @returns true if the mesh will be used
  45991. */
  45992. hasMesh(mesh: AbstractMesh): boolean;
  45993. /**
  45994. * Returns true if the layer contains information to display, otherwise false.
  45995. * @returns true if the glow layer should be rendered
  45996. */
  45997. shouldRender(): boolean;
  45998. /**
  45999. * Returns true if the mesh should render, otherwise false.
  46000. * @param mesh The mesh to render
  46001. * @returns true if it should render otherwise false
  46002. */
  46003. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46004. /**
  46005. * Returns true if the mesh can be rendered, otherwise false.
  46006. * @param mesh The mesh to render
  46007. * @param material The material used on the mesh
  46008. * @returns true if it can be rendered otherwise false
  46009. */
  46010. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46011. /**
  46012. * Returns true if the mesh should render, otherwise false.
  46013. * @param mesh The mesh to render
  46014. * @returns true if it should render otherwise false
  46015. */
  46016. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46017. /**
  46018. * Renders the submesh passed in parameter to the generation map.
  46019. */
  46020. protected _renderSubMesh(subMesh: SubMesh): void;
  46021. /**
  46022. * Rebuild the required buffers.
  46023. * @hidden Internal use only.
  46024. */
  46025. _rebuild(): void;
  46026. /**
  46027. * Dispose only the render target textures and post process.
  46028. */
  46029. private _disposeTextureAndPostProcesses;
  46030. /**
  46031. * Dispose the highlight layer and free resources.
  46032. */
  46033. dispose(): void;
  46034. /**
  46035. * Gets the class name of the effect layer
  46036. * @returns the string with the class name of the effect layer
  46037. */
  46038. getClassName(): string;
  46039. /**
  46040. * Creates an effect layer from parsed effect layer data
  46041. * @param parsedEffectLayer defines effect layer data
  46042. * @param scene defines the current scene
  46043. * @param rootUrl defines the root URL containing the effect layer information
  46044. * @returns a parsed effect Layer
  46045. */
  46046. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46047. }
  46048. }
  46049. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  46050. import { Scene } from "babylonjs/scene";
  46051. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46052. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46053. import { AbstractScene } from "babylonjs/abstractScene";
  46054. module "babylonjs/abstractScene" {
  46055. interface AbstractScene {
  46056. /**
  46057. * The list of effect layers (highlights/glow) added to the scene
  46058. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46059. * @see http://doc.babylonjs.com/how_to/glow_layer
  46060. */
  46061. effectLayers: Array<EffectLayer>;
  46062. /**
  46063. * Removes the given effect layer from this scene.
  46064. * @param toRemove defines the effect layer to remove
  46065. * @returns the index of the removed effect layer
  46066. */
  46067. removeEffectLayer(toRemove: EffectLayer): number;
  46068. /**
  46069. * Adds the given effect layer to this scene
  46070. * @param newEffectLayer defines the effect layer to add
  46071. */
  46072. addEffectLayer(newEffectLayer: EffectLayer): void;
  46073. }
  46074. }
  46075. /**
  46076. * Defines the layer scene component responsible to manage any effect layers
  46077. * in a given scene.
  46078. */
  46079. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46080. /**
  46081. * The component name helpfull to identify the component in the list of scene components.
  46082. */
  46083. readonly name: string;
  46084. /**
  46085. * The scene the component belongs to.
  46086. */
  46087. scene: Scene;
  46088. private _engine;
  46089. private _renderEffects;
  46090. private _needStencil;
  46091. private _previousStencilState;
  46092. /**
  46093. * Creates a new instance of the component for the given scene
  46094. * @param scene Defines the scene to register the component in
  46095. */
  46096. constructor(scene: Scene);
  46097. /**
  46098. * Registers the component in a given scene
  46099. */
  46100. register(): void;
  46101. /**
  46102. * Rebuilds the elements related to this component in case of
  46103. * context lost for instance.
  46104. */
  46105. rebuild(): void;
  46106. /**
  46107. * Serializes the component data to the specified json object
  46108. * @param serializationObject The object to serialize to
  46109. */
  46110. serialize(serializationObject: any): void;
  46111. /**
  46112. * Adds all the element from the container to the scene
  46113. * @param container the container holding the elements
  46114. */
  46115. addFromContainer(container: AbstractScene): void;
  46116. /**
  46117. * Removes all the elements in the container from the scene
  46118. * @param container contains the elements to remove
  46119. */
  46120. removeFromContainer(container: AbstractScene): void;
  46121. /**
  46122. * Disposes the component and the associated ressources.
  46123. */
  46124. dispose(): void;
  46125. private _isReadyForMesh;
  46126. private _renderMainTexture;
  46127. private _setStencil;
  46128. private _setStencilBack;
  46129. private _draw;
  46130. private _drawCamera;
  46131. private _drawRenderingGroup;
  46132. }
  46133. }
  46134. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  46135. /** @hidden */
  46136. export var glowMapMergePixelShader: {
  46137. name: string;
  46138. shader: string;
  46139. };
  46140. }
  46141. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  46142. /** @hidden */
  46143. export var glowMapMergeVertexShader: {
  46144. name: string;
  46145. shader: string;
  46146. };
  46147. }
  46148. declare module "babylonjs/Layers/glowLayer" {
  46149. import { Nullable } from "babylonjs/types";
  46150. import { Camera } from "babylonjs/Cameras/camera";
  46151. import { Scene } from "babylonjs/scene";
  46152. import { Color4 } from "babylonjs/Maths/math";
  46153. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46155. import { Mesh } from "babylonjs/Meshes/mesh";
  46156. import { Texture } from "babylonjs/Materials/Textures/texture";
  46157. import { Effect } from "babylonjs/Materials/effect";
  46158. import { Material } from "babylonjs/Materials/material";
  46159. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46160. import "babylonjs/Shaders/glowMapMerge.fragment";
  46161. import "babylonjs/Shaders/glowMapMerge.vertex";
  46162. module "babylonjs/abstractScene" {
  46163. interface AbstractScene {
  46164. /**
  46165. * Return a the first highlight layer of the scene with a given name.
  46166. * @param name The name of the highlight layer to look for.
  46167. * @return The highlight layer if found otherwise null.
  46168. */
  46169. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46170. }
  46171. }
  46172. /**
  46173. * Glow layer options. This helps customizing the behaviour
  46174. * of the glow layer.
  46175. */
  46176. export interface IGlowLayerOptions {
  46177. /**
  46178. * Multiplication factor apply to the canvas size to compute the render target size
  46179. * used to generated the glowing objects (the smaller the faster).
  46180. */
  46181. mainTextureRatio: number;
  46182. /**
  46183. * Enforces a fixed size texture to ensure resize independant blur.
  46184. */
  46185. mainTextureFixedSize?: number;
  46186. /**
  46187. * How big is the kernel of the blur texture.
  46188. */
  46189. blurKernelSize: number;
  46190. /**
  46191. * The camera attached to the layer.
  46192. */
  46193. camera: Nullable<Camera>;
  46194. /**
  46195. * Enable MSAA by chosing the number of samples.
  46196. */
  46197. mainTextureSamples?: number;
  46198. /**
  46199. * The rendering group to draw the layer in.
  46200. */
  46201. renderingGroupId: number;
  46202. }
  46203. /**
  46204. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46205. *
  46206. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46207. * glowy meshes to your scene.
  46208. *
  46209. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46210. */
  46211. export class GlowLayer extends EffectLayer {
  46212. /**
  46213. * Effect Name of the layer.
  46214. */
  46215. static readonly EffectName: string;
  46216. /**
  46217. * The default blur kernel size used for the glow.
  46218. */
  46219. static DefaultBlurKernelSize: number;
  46220. /**
  46221. * The default texture size ratio used for the glow.
  46222. */
  46223. static DefaultTextureRatio: number;
  46224. /**
  46225. * Sets the kernel size of the blur.
  46226. */
  46227. /**
  46228. * Gets the kernel size of the blur.
  46229. */
  46230. blurKernelSize: number;
  46231. /**
  46232. * Sets the glow intensity.
  46233. */
  46234. /**
  46235. * Gets the glow intensity.
  46236. */
  46237. intensity: number;
  46238. private _options;
  46239. private _intensity;
  46240. private _horizontalBlurPostprocess1;
  46241. private _verticalBlurPostprocess1;
  46242. private _horizontalBlurPostprocess2;
  46243. private _verticalBlurPostprocess2;
  46244. private _blurTexture1;
  46245. private _blurTexture2;
  46246. private _postProcesses1;
  46247. private _postProcesses2;
  46248. private _includedOnlyMeshes;
  46249. private _excludedMeshes;
  46250. /**
  46251. * Callback used to let the user override the color selection on a per mesh basis
  46252. */
  46253. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46254. /**
  46255. * Callback used to let the user override the texture selection on a per mesh basis
  46256. */
  46257. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46258. /**
  46259. * Instantiates a new glow Layer and references it to the scene.
  46260. * @param name The name of the layer
  46261. * @param scene The scene to use the layer in
  46262. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46263. */
  46264. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46265. /**
  46266. * Get the effect name of the layer.
  46267. * @return The effect name
  46268. */
  46269. getEffectName(): string;
  46270. /**
  46271. * Create the merge effect. This is the shader use to blit the information back
  46272. * to the main canvas at the end of the scene rendering.
  46273. */
  46274. protected _createMergeEffect(): Effect;
  46275. /**
  46276. * Creates the render target textures and post processes used in the glow layer.
  46277. */
  46278. protected _createTextureAndPostProcesses(): void;
  46279. /**
  46280. * Checks for the readiness of the element composing the layer.
  46281. * @param subMesh the mesh to check for
  46282. * @param useInstances specify wether or not to use instances to render the mesh
  46283. * @param emissiveTexture the associated emissive texture used to generate the glow
  46284. * @return true if ready otherwise, false
  46285. */
  46286. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46287. /**
  46288. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46289. */
  46290. needStencil(): boolean;
  46291. /**
  46292. * Returns true if the mesh can be rendered, otherwise false.
  46293. * @param mesh The mesh to render
  46294. * @param material The material used on the mesh
  46295. * @returns true if it can be rendered otherwise false
  46296. */
  46297. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46298. /**
  46299. * Implementation specific of rendering the generating effect on the main canvas.
  46300. * @param effect The effect used to render through
  46301. */
  46302. protected _internalRender(effect: Effect): void;
  46303. /**
  46304. * Sets the required values for both the emissive texture and and the main color.
  46305. */
  46306. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46307. /**
  46308. * Returns true if the mesh should render, otherwise false.
  46309. * @param mesh The mesh to render
  46310. * @returns true if it should render otherwise false
  46311. */
  46312. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46313. /**
  46314. * Adds specific effects defines.
  46315. * @param defines The defines to add specifics to.
  46316. */
  46317. protected _addCustomEffectDefines(defines: string[]): void;
  46318. /**
  46319. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46320. * @param mesh The mesh to exclude from the glow layer
  46321. */
  46322. addExcludedMesh(mesh: Mesh): void;
  46323. /**
  46324. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46325. * @param mesh The mesh to remove
  46326. */
  46327. removeExcludedMesh(mesh: Mesh): void;
  46328. /**
  46329. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46330. * @param mesh The mesh to include in the glow layer
  46331. */
  46332. addIncludedOnlyMesh(mesh: Mesh): void;
  46333. /**
  46334. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46335. * @param mesh The mesh to remove
  46336. */
  46337. removeIncludedOnlyMesh(mesh: Mesh): void;
  46338. /**
  46339. * Determine if a given mesh will be used in the glow layer
  46340. * @param mesh The mesh to test
  46341. * @returns true if the mesh will be highlighted by the current glow layer
  46342. */
  46343. hasMesh(mesh: AbstractMesh): boolean;
  46344. /**
  46345. * Free any resources and references associated to a mesh.
  46346. * Internal use
  46347. * @param mesh The mesh to free.
  46348. * @hidden
  46349. */
  46350. _disposeMesh(mesh: Mesh): void;
  46351. /**
  46352. * Gets the class name of the effect layer
  46353. * @returns the string with the class name of the effect layer
  46354. */
  46355. getClassName(): string;
  46356. /**
  46357. * Serializes this glow layer
  46358. * @returns a serialized glow layer object
  46359. */
  46360. serialize(): any;
  46361. /**
  46362. * Creates a Glow Layer from parsed glow layer data
  46363. * @param parsedGlowLayer defines glow layer data
  46364. * @param scene defines the current scene
  46365. * @param rootUrl defines the root URL containing the glow layer information
  46366. * @returns a parsed Glow Layer
  46367. */
  46368. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46369. }
  46370. }
  46371. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  46372. /** @hidden */
  46373. export var glowBlurPostProcessPixelShader: {
  46374. name: string;
  46375. shader: string;
  46376. };
  46377. }
  46378. declare module "babylonjs/Layers/highlightLayer" {
  46379. import { Observable } from "babylonjs/Misc/observable";
  46380. import { Nullable } from "babylonjs/types";
  46381. import { Camera } from "babylonjs/Cameras/camera";
  46382. import { Scene } from "babylonjs/scene";
  46383. import { Color3, Color4 } from "babylonjs/Maths/math";
  46384. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46386. import { Mesh } from "babylonjs/Meshes/mesh";
  46387. import { Effect } from "babylonjs/Materials/effect";
  46388. import { Material } from "babylonjs/Materials/material";
  46389. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46390. import "babylonjs/Shaders/glowMapMerge.fragment";
  46391. import "babylonjs/Shaders/glowMapMerge.vertex";
  46392. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  46393. module "babylonjs/abstractScene" {
  46394. interface AbstractScene {
  46395. /**
  46396. * Return a the first highlight layer of the scene with a given name.
  46397. * @param name The name of the highlight layer to look for.
  46398. * @return The highlight layer if found otherwise null.
  46399. */
  46400. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46401. }
  46402. }
  46403. /**
  46404. * Highlight layer options. This helps customizing the behaviour
  46405. * of the highlight layer.
  46406. */
  46407. export interface IHighlightLayerOptions {
  46408. /**
  46409. * Multiplication factor apply to the canvas size to compute the render target size
  46410. * used to generated the glowing objects (the smaller the faster).
  46411. */
  46412. mainTextureRatio: number;
  46413. /**
  46414. * Enforces a fixed size texture to ensure resize independant blur.
  46415. */
  46416. mainTextureFixedSize?: number;
  46417. /**
  46418. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46419. * of the picture to blur (the smaller the faster).
  46420. */
  46421. blurTextureSizeRatio: number;
  46422. /**
  46423. * How big in texel of the blur texture is the vertical blur.
  46424. */
  46425. blurVerticalSize: number;
  46426. /**
  46427. * How big in texel of the blur texture is the horizontal blur.
  46428. */
  46429. blurHorizontalSize: number;
  46430. /**
  46431. * Alpha blending mode used to apply the blur. Default is combine.
  46432. */
  46433. alphaBlendingMode: number;
  46434. /**
  46435. * The camera attached to the layer.
  46436. */
  46437. camera: Nullable<Camera>;
  46438. /**
  46439. * Should we display highlight as a solid stroke?
  46440. */
  46441. isStroke?: boolean;
  46442. /**
  46443. * The rendering group to draw the layer in.
  46444. */
  46445. renderingGroupId: number;
  46446. }
  46447. /**
  46448. * The highlight layer Helps adding a glow effect around a mesh.
  46449. *
  46450. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46451. * glowy meshes to your scene.
  46452. *
  46453. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46454. */
  46455. export class HighlightLayer extends EffectLayer {
  46456. name: string;
  46457. /**
  46458. * Effect Name of the highlight layer.
  46459. */
  46460. static readonly EffectName: string;
  46461. /**
  46462. * The neutral color used during the preparation of the glow effect.
  46463. * This is black by default as the blend operation is a blend operation.
  46464. */
  46465. static NeutralColor: Color4;
  46466. /**
  46467. * Stencil value used for glowing meshes.
  46468. */
  46469. static GlowingMeshStencilReference: number;
  46470. /**
  46471. * Stencil value used for the other meshes in the scene.
  46472. */
  46473. static NormalMeshStencilReference: number;
  46474. /**
  46475. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46476. */
  46477. innerGlow: boolean;
  46478. /**
  46479. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46480. */
  46481. outerGlow: boolean;
  46482. /**
  46483. * Specifies the horizontal size of the blur.
  46484. */
  46485. /**
  46486. * Gets the horizontal size of the blur.
  46487. */
  46488. blurHorizontalSize: number;
  46489. /**
  46490. * Specifies the vertical size of the blur.
  46491. */
  46492. /**
  46493. * Gets the vertical size of the blur.
  46494. */
  46495. blurVerticalSize: number;
  46496. /**
  46497. * An event triggered when the highlight layer is being blurred.
  46498. */
  46499. onBeforeBlurObservable: Observable<HighlightLayer>;
  46500. /**
  46501. * An event triggered when the highlight layer has been blurred.
  46502. */
  46503. onAfterBlurObservable: Observable<HighlightLayer>;
  46504. private _instanceGlowingMeshStencilReference;
  46505. private _options;
  46506. private _downSamplePostprocess;
  46507. private _horizontalBlurPostprocess;
  46508. private _verticalBlurPostprocess;
  46509. private _blurTexture;
  46510. private _meshes;
  46511. private _excludedMeshes;
  46512. /**
  46513. * Instantiates a new highlight Layer and references it to the scene..
  46514. * @param name The name of the layer
  46515. * @param scene The scene to use the layer in
  46516. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46517. */
  46518. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46519. /**
  46520. * Get the effect name of the layer.
  46521. * @return The effect name
  46522. */
  46523. getEffectName(): string;
  46524. /**
  46525. * Create the merge effect. This is the shader use to blit the information back
  46526. * to the main canvas at the end of the scene rendering.
  46527. */
  46528. protected _createMergeEffect(): Effect;
  46529. /**
  46530. * Creates the render target textures and post processes used in the highlight layer.
  46531. */
  46532. protected _createTextureAndPostProcesses(): void;
  46533. /**
  46534. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46535. */
  46536. needStencil(): boolean;
  46537. /**
  46538. * Checks for the readiness of the element composing the layer.
  46539. * @param subMesh the mesh to check for
  46540. * @param useInstances specify wether or not to use instances to render the mesh
  46541. * @param emissiveTexture the associated emissive texture used to generate the glow
  46542. * @return true if ready otherwise, false
  46543. */
  46544. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46545. /**
  46546. * Implementation specific of rendering the generating effect on the main canvas.
  46547. * @param effect The effect used to render through
  46548. */
  46549. protected _internalRender(effect: Effect): void;
  46550. /**
  46551. * Returns true if the layer contains information to display, otherwise false.
  46552. */
  46553. shouldRender(): boolean;
  46554. /**
  46555. * Returns true if the mesh should render, otherwise false.
  46556. * @param mesh The mesh to render
  46557. * @returns true if it should render otherwise false
  46558. */
  46559. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46560. /**
  46561. * Sets the required values for both the emissive texture and and the main color.
  46562. */
  46563. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46564. /**
  46565. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46566. * @param mesh The mesh to exclude from the highlight layer
  46567. */
  46568. addExcludedMesh(mesh: Mesh): void;
  46569. /**
  46570. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46571. * @param mesh The mesh to highlight
  46572. */
  46573. removeExcludedMesh(mesh: Mesh): void;
  46574. /**
  46575. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46576. * @param mesh mesh to test
  46577. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46578. */
  46579. hasMesh(mesh: AbstractMesh): boolean;
  46580. /**
  46581. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46582. * @param mesh The mesh to highlight
  46583. * @param color The color of the highlight
  46584. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46585. */
  46586. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46587. /**
  46588. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46589. * @param mesh The mesh to highlight
  46590. */
  46591. removeMesh(mesh: Mesh): void;
  46592. /**
  46593. * Force the stencil to the normal expected value for none glowing parts
  46594. */
  46595. private _defaultStencilReference;
  46596. /**
  46597. * Free any resources and references associated to a mesh.
  46598. * Internal use
  46599. * @param mesh The mesh to free.
  46600. * @hidden
  46601. */
  46602. _disposeMesh(mesh: Mesh): void;
  46603. /**
  46604. * Dispose the highlight layer and free resources.
  46605. */
  46606. dispose(): void;
  46607. /**
  46608. * Gets the class name of the effect layer
  46609. * @returns the string with the class name of the effect layer
  46610. */
  46611. getClassName(): string;
  46612. /**
  46613. * Serializes this Highlight layer
  46614. * @returns a serialized Highlight layer object
  46615. */
  46616. serialize(): any;
  46617. /**
  46618. * Creates a Highlight layer from parsed Highlight layer data
  46619. * @param parsedHightlightLayer defines the Highlight layer data
  46620. * @param scene defines the current scene
  46621. * @param rootUrl defines the root URL containing the Highlight layer information
  46622. * @returns a parsed Highlight layer
  46623. */
  46624. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46625. }
  46626. }
  46627. declare module "babylonjs/Layers/index" {
  46628. export * from "babylonjs/Layers/effectLayer";
  46629. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46630. export * from "babylonjs/Layers/glowLayer";
  46631. export * from "babylonjs/Layers/highlightLayer";
  46632. export * from "babylonjs/Layers/layer";
  46633. export * from "babylonjs/Layers/layerSceneComponent";
  46634. }
  46635. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46636. /** @hidden */
  46637. export var lensFlarePixelShader: {
  46638. name: string;
  46639. shader: string;
  46640. };
  46641. }
  46642. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46643. /** @hidden */
  46644. export var lensFlareVertexShader: {
  46645. name: string;
  46646. shader: string;
  46647. };
  46648. }
  46649. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46650. import { Scene } from "babylonjs/scene";
  46651. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46653. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46654. import "babylonjs/Shaders/lensFlare.fragment";
  46655. import "babylonjs/Shaders/lensFlare.vertex";
  46656. /**
  46657. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46658. * It is usually composed of several `lensFlare`.
  46659. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46660. */
  46661. export class LensFlareSystem {
  46662. /**
  46663. * Define the name of the lens flare system
  46664. */
  46665. name: string;
  46666. /**
  46667. * List of lens flares used in this system.
  46668. */
  46669. lensFlares: LensFlare[];
  46670. /**
  46671. * Define a limit from the border the lens flare can be visible.
  46672. */
  46673. borderLimit: number;
  46674. /**
  46675. * Define a viewport border we do not want to see the lens flare in.
  46676. */
  46677. viewportBorder: number;
  46678. /**
  46679. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46680. */
  46681. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46682. /**
  46683. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46684. */
  46685. layerMask: number;
  46686. /**
  46687. * Define the id of the lens flare system in the scene.
  46688. * (equal to name by default)
  46689. */
  46690. id: string;
  46691. private _scene;
  46692. private _emitter;
  46693. private _vertexBuffers;
  46694. private _indexBuffer;
  46695. private _effect;
  46696. private _positionX;
  46697. private _positionY;
  46698. private _isEnabled;
  46699. /** @hidden */
  46700. static _SceneComponentInitialization: (scene: Scene) => void;
  46701. /**
  46702. * Instantiates a lens flare system.
  46703. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46704. * It is usually composed of several `lensFlare`.
  46705. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46706. * @param name Define the name of the lens flare system in the scene
  46707. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46708. * @param scene Define the scene the lens flare system belongs to
  46709. */
  46710. constructor(
  46711. /**
  46712. * Define the name of the lens flare system
  46713. */
  46714. name: string, emitter: any, scene: Scene);
  46715. /**
  46716. * Define if the lens flare system is enabled.
  46717. */
  46718. isEnabled: boolean;
  46719. /**
  46720. * Get the scene the effects belongs to.
  46721. * @returns the scene holding the lens flare system
  46722. */
  46723. getScene(): Scene;
  46724. /**
  46725. * Get the emitter of the lens flare system.
  46726. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46727. * @returns the emitter of the lens flare system
  46728. */
  46729. getEmitter(): any;
  46730. /**
  46731. * Set the emitter of the lens flare system.
  46732. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46733. * @param newEmitter Define the new emitter of the system
  46734. */
  46735. setEmitter(newEmitter: any): void;
  46736. /**
  46737. * Get the lens flare system emitter position.
  46738. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46739. * @returns the position
  46740. */
  46741. getEmitterPosition(): Vector3;
  46742. /**
  46743. * @hidden
  46744. */
  46745. computeEffectivePosition(globalViewport: Viewport): boolean;
  46746. /** @hidden */
  46747. _isVisible(): boolean;
  46748. /**
  46749. * @hidden
  46750. */
  46751. render(): boolean;
  46752. /**
  46753. * Dispose and release the lens flare with its associated resources.
  46754. */
  46755. dispose(): void;
  46756. /**
  46757. * Parse a lens flare system from a JSON repressentation
  46758. * @param parsedLensFlareSystem Define the JSON to parse
  46759. * @param scene Define the scene the parsed system should be instantiated in
  46760. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46761. * @returns the parsed system
  46762. */
  46763. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46764. /**
  46765. * Serialize the current Lens Flare System into a JSON representation.
  46766. * @returns the serialized JSON
  46767. */
  46768. serialize(): any;
  46769. }
  46770. }
  46771. declare module "babylonjs/LensFlares/lensFlare" {
  46772. import { Nullable } from "babylonjs/types";
  46773. import { Color3 } from "babylonjs/Maths/math";
  46774. import { Texture } from "babylonjs/Materials/Textures/texture";
  46775. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46776. /**
  46777. * This represents one of the lens effect in a `lensFlareSystem`.
  46778. * It controls one of the indiviual texture used in the effect.
  46779. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46780. */
  46781. export class LensFlare {
  46782. /**
  46783. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46784. */
  46785. size: number;
  46786. /**
  46787. * 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.
  46788. */
  46789. position: number;
  46790. /**
  46791. * Define the lens color.
  46792. */
  46793. color: Color3;
  46794. /**
  46795. * Define the lens texture.
  46796. */
  46797. texture: Nullable<Texture>;
  46798. /**
  46799. * Define the alpha mode to render this particular lens.
  46800. */
  46801. alphaMode: number;
  46802. private _system;
  46803. /**
  46804. * Creates a new Lens Flare.
  46805. * This represents one of the lens effect in a `lensFlareSystem`.
  46806. * It controls one of the indiviual texture used in the effect.
  46807. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46808. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46809. * @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.
  46810. * @param color Define the lens color
  46811. * @param imgUrl Define the lens texture url
  46812. * @param system Define the `lensFlareSystem` this flare is part of
  46813. * @returns The newly created Lens Flare
  46814. */
  46815. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46816. /**
  46817. * Instantiates a new Lens Flare.
  46818. * This represents one of the lens effect in a `lensFlareSystem`.
  46819. * It controls one of the indiviual texture used in the effect.
  46820. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46821. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46822. * @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.
  46823. * @param color Define the lens color
  46824. * @param imgUrl Define the lens texture url
  46825. * @param system Define the `lensFlareSystem` this flare is part of
  46826. */
  46827. constructor(
  46828. /**
  46829. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46830. */
  46831. size: number,
  46832. /**
  46833. * 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.
  46834. */
  46835. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46836. /**
  46837. * Dispose and release the lens flare with its associated resources.
  46838. */
  46839. dispose(): void;
  46840. }
  46841. }
  46842. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46843. import { Nullable } from "babylonjs/types";
  46844. import { Scene } from "babylonjs/scene";
  46845. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46846. import { AbstractScene } from "babylonjs/abstractScene";
  46847. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46848. module "babylonjs/abstractScene" {
  46849. interface AbstractScene {
  46850. /**
  46851. * The list of lens flare system added to the scene
  46852. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46853. */
  46854. lensFlareSystems: Array<LensFlareSystem>;
  46855. /**
  46856. * Removes the given lens flare system from this scene.
  46857. * @param toRemove The lens flare system to remove
  46858. * @returns The index of the removed lens flare system
  46859. */
  46860. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46861. /**
  46862. * Adds the given lens flare system to this scene
  46863. * @param newLensFlareSystem The lens flare system to add
  46864. */
  46865. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46866. /**
  46867. * Gets a lens flare system using its name
  46868. * @param name defines the name to look for
  46869. * @returns the lens flare system or null if not found
  46870. */
  46871. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46872. /**
  46873. * Gets a lens flare system using its id
  46874. * @param id defines the id to look for
  46875. * @returns the lens flare system or null if not found
  46876. */
  46877. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46878. }
  46879. }
  46880. /**
  46881. * Defines the lens flare scene component responsible to manage any lens flares
  46882. * in a given scene.
  46883. */
  46884. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46885. /**
  46886. * The component name helpfull to identify the component in the list of scene components.
  46887. */
  46888. readonly name: string;
  46889. /**
  46890. * The scene the component belongs to.
  46891. */
  46892. scene: Scene;
  46893. /**
  46894. * Creates a new instance of the component for the given scene
  46895. * @param scene Defines the scene to register the component in
  46896. */
  46897. constructor(scene: Scene);
  46898. /**
  46899. * Registers the component in a given scene
  46900. */
  46901. register(): void;
  46902. /**
  46903. * Rebuilds the elements related to this component in case of
  46904. * context lost for instance.
  46905. */
  46906. rebuild(): void;
  46907. /**
  46908. * Adds all the element from the container to the scene
  46909. * @param container the container holding the elements
  46910. */
  46911. addFromContainer(container: AbstractScene): void;
  46912. /**
  46913. * Removes all the elements in the container from the scene
  46914. * @param container contains the elements to remove
  46915. */
  46916. removeFromContainer(container: AbstractScene): void;
  46917. /**
  46918. * Serializes the component data to the specified json object
  46919. * @param serializationObject The object to serialize to
  46920. */
  46921. serialize(serializationObject: any): void;
  46922. /**
  46923. * Disposes the component and the associated ressources.
  46924. */
  46925. dispose(): void;
  46926. private _draw;
  46927. }
  46928. }
  46929. declare module "babylonjs/LensFlares/index" {
  46930. export * from "babylonjs/LensFlares/lensFlare";
  46931. export * from "babylonjs/LensFlares/lensFlareSystem";
  46932. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  46933. }
  46934. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  46935. import { Scene } from "babylonjs/scene";
  46936. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46937. import { AbstractScene } from "babylonjs/abstractScene";
  46938. /**
  46939. * Defines the shadow generator component responsible to manage any shadow generators
  46940. * in a given scene.
  46941. */
  46942. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46943. /**
  46944. * The component name helpfull to identify the component in the list of scene components.
  46945. */
  46946. readonly name: string;
  46947. /**
  46948. * The scene the component belongs to.
  46949. */
  46950. scene: Scene;
  46951. /**
  46952. * Creates a new instance of the component for the given scene
  46953. * @param scene Defines the scene to register the component in
  46954. */
  46955. constructor(scene: Scene);
  46956. /**
  46957. * Registers the component in a given scene
  46958. */
  46959. register(): void;
  46960. /**
  46961. * Rebuilds the elements related to this component in case of
  46962. * context lost for instance.
  46963. */
  46964. rebuild(): void;
  46965. /**
  46966. * Serializes the component data to the specified json object
  46967. * @param serializationObject The object to serialize to
  46968. */
  46969. serialize(serializationObject: any): void;
  46970. /**
  46971. * Adds all the element from the container to the scene
  46972. * @param container the container holding the elements
  46973. */
  46974. addFromContainer(container: AbstractScene): void;
  46975. /**
  46976. * Removes all the elements in the container from the scene
  46977. * @param container contains the elements to remove
  46978. */
  46979. removeFromContainer(container: AbstractScene): void;
  46980. /**
  46981. * Rebuilds the elements related to this component in case of
  46982. * context lost for instance.
  46983. */
  46984. dispose(): void;
  46985. private _gatherRenderTargets;
  46986. }
  46987. }
  46988. declare module "babylonjs/Lights/Shadows/index" {
  46989. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  46990. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  46991. }
  46992. declare module "babylonjs/Lights/directionalLight" {
  46993. import { Camera } from "babylonjs/Cameras/camera";
  46994. import { Scene } from "babylonjs/scene";
  46995. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46997. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46998. import { Effect } from "babylonjs/Materials/effect";
  46999. /**
  47000. * A directional light is defined by a direction (what a surprise!).
  47001. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47002. * 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.
  47003. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47004. */
  47005. export class DirectionalLight extends ShadowLight {
  47006. private _shadowFrustumSize;
  47007. /**
  47008. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47009. */
  47010. /**
  47011. * Specifies a fix frustum size for the shadow generation.
  47012. */
  47013. shadowFrustumSize: number;
  47014. private _shadowOrthoScale;
  47015. /**
  47016. * Gets the shadow projection scale against the optimal computed one.
  47017. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47018. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47019. */
  47020. /**
  47021. * Sets the shadow projection scale against the optimal computed one.
  47022. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47023. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47024. */
  47025. shadowOrthoScale: number;
  47026. /**
  47027. * Automatically compute the projection matrix to best fit (including all the casters)
  47028. * on each frame.
  47029. */
  47030. autoUpdateExtends: boolean;
  47031. private _orthoLeft;
  47032. private _orthoRight;
  47033. private _orthoTop;
  47034. private _orthoBottom;
  47035. /**
  47036. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47037. * The directional light is emitted from everywhere in the given direction.
  47038. * It can cast shadows.
  47039. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47040. * @param name The friendly name of the light
  47041. * @param direction The direction of the light
  47042. * @param scene The scene the light belongs to
  47043. */
  47044. constructor(name: string, direction: Vector3, scene: Scene);
  47045. /**
  47046. * Returns the string "DirectionalLight".
  47047. * @return The class name
  47048. */
  47049. getClassName(): string;
  47050. /**
  47051. * Returns the integer 1.
  47052. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47053. */
  47054. getTypeID(): number;
  47055. /**
  47056. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47057. * Returns the DirectionalLight Shadow projection matrix.
  47058. */
  47059. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47060. /**
  47061. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47062. * Returns the DirectionalLight Shadow projection matrix.
  47063. */
  47064. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47065. /**
  47066. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47067. * Returns the DirectionalLight Shadow projection matrix.
  47068. */
  47069. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47070. protected _buildUniformLayout(): void;
  47071. /**
  47072. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47073. * @param effect The effect to update
  47074. * @param lightIndex The index of the light in the effect to update
  47075. * @returns The directional light
  47076. */
  47077. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47078. /**
  47079. * Gets the minZ used for shadow according to both the scene and the light.
  47080. *
  47081. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47082. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47083. * @param activeCamera The camera we are returning the min for
  47084. * @returns the depth min z
  47085. */
  47086. getDepthMinZ(activeCamera: Camera): number;
  47087. /**
  47088. * Gets the maxZ used for shadow according to both the scene and the light.
  47089. *
  47090. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47091. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47092. * @param activeCamera The camera we are returning the max for
  47093. * @returns the depth max z
  47094. */
  47095. getDepthMaxZ(activeCamera: Camera): number;
  47096. /**
  47097. * Prepares the list of defines specific to the light type.
  47098. * @param defines the list of defines
  47099. * @param lightIndex defines the index of the light for the effect
  47100. */
  47101. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47102. }
  47103. }
  47104. declare module "babylonjs/Lights/pointLight" {
  47105. import { Scene } from "babylonjs/scene";
  47106. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47108. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47109. import { Effect } from "babylonjs/Materials/effect";
  47110. /**
  47111. * A point light is a light defined by an unique point in world space.
  47112. * The light is emitted in every direction from this point.
  47113. * A good example of a point light is a standard light bulb.
  47114. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47115. */
  47116. export class PointLight extends ShadowLight {
  47117. private _shadowAngle;
  47118. /**
  47119. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47120. * This specifies what angle the shadow will use to be created.
  47121. *
  47122. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47123. */
  47124. /**
  47125. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47126. * This specifies what angle the shadow will use to be created.
  47127. *
  47128. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47129. */
  47130. shadowAngle: number;
  47131. /**
  47132. * Gets the direction if it has been set.
  47133. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47134. */
  47135. /**
  47136. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47137. */
  47138. direction: Vector3;
  47139. /**
  47140. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47141. * A PointLight emits the light in every direction.
  47142. * It can cast shadows.
  47143. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47144. * ```javascript
  47145. * var pointLight = new PointLight("pl", camera.position, scene);
  47146. * ```
  47147. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47148. * @param name The light friendly name
  47149. * @param position The position of the point light in the scene
  47150. * @param scene The scene the lights belongs to
  47151. */
  47152. constructor(name: string, position: Vector3, scene: Scene);
  47153. /**
  47154. * Returns the string "PointLight"
  47155. * @returns the class name
  47156. */
  47157. getClassName(): string;
  47158. /**
  47159. * Returns the integer 0.
  47160. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47161. */
  47162. getTypeID(): number;
  47163. /**
  47164. * Specifies wether or not the shadowmap should be a cube texture.
  47165. * @returns true if the shadowmap needs to be a cube texture.
  47166. */
  47167. needCube(): boolean;
  47168. /**
  47169. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47170. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47171. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47172. */
  47173. getShadowDirection(faceIndex?: number): Vector3;
  47174. /**
  47175. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47176. * - fov = PI / 2
  47177. * - aspect ratio : 1.0
  47178. * - z-near and far equal to the active camera minZ and maxZ.
  47179. * Returns the PointLight.
  47180. */
  47181. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47182. protected _buildUniformLayout(): void;
  47183. /**
  47184. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47185. * @param effect The effect to update
  47186. * @param lightIndex The index of the light in the effect to update
  47187. * @returns The point light
  47188. */
  47189. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47190. /**
  47191. * Prepares the list of defines specific to the light type.
  47192. * @param defines the list of defines
  47193. * @param lightIndex defines the index of the light for the effect
  47194. */
  47195. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47196. }
  47197. }
  47198. declare module "babylonjs/Lights/spotLight" {
  47199. import { Nullable } from "babylonjs/types";
  47200. import { Scene } from "babylonjs/scene";
  47201. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47203. import { Effect } from "babylonjs/Materials/effect";
  47204. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47205. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47206. /**
  47207. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47208. * These values define a cone of light starting from the position, emitting toward the direction.
  47209. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47210. * and the exponent defines the speed of the decay of the light with distance (reach).
  47211. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47212. */
  47213. export class SpotLight extends ShadowLight {
  47214. private _angle;
  47215. private _innerAngle;
  47216. private _cosHalfAngle;
  47217. private _lightAngleScale;
  47218. private _lightAngleOffset;
  47219. /**
  47220. * Gets the cone angle of the spot light in Radians.
  47221. */
  47222. /**
  47223. * Sets the cone angle of the spot light in Radians.
  47224. */
  47225. angle: number;
  47226. /**
  47227. * Only used in gltf falloff mode, this defines the angle where
  47228. * the directional falloff will start before cutting at angle which could be seen
  47229. * as outer angle.
  47230. */
  47231. /**
  47232. * Only used in gltf falloff mode, this defines the angle where
  47233. * the directional falloff will start before cutting at angle which could be seen
  47234. * as outer angle.
  47235. */
  47236. innerAngle: number;
  47237. private _shadowAngleScale;
  47238. /**
  47239. * Allows scaling the angle of the light for shadow generation only.
  47240. */
  47241. /**
  47242. * Allows scaling the angle of the light for shadow generation only.
  47243. */
  47244. shadowAngleScale: number;
  47245. /**
  47246. * The light decay speed with the distance from the emission spot.
  47247. */
  47248. exponent: number;
  47249. private _projectionTextureMatrix;
  47250. /**
  47251. * Allows reading the projecton texture
  47252. */
  47253. readonly projectionTextureMatrix: Matrix;
  47254. protected _projectionTextureLightNear: number;
  47255. /**
  47256. * Gets the near clip of the Spotlight for texture projection.
  47257. */
  47258. /**
  47259. * Sets the near clip of the Spotlight for texture projection.
  47260. */
  47261. projectionTextureLightNear: number;
  47262. protected _projectionTextureLightFar: number;
  47263. /**
  47264. * Gets the far clip of the Spotlight for texture projection.
  47265. */
  47266. /**
  47267. * Sets the far clip of the Spotlight for texture projection.
  47268. */
  47269. projectionTextureLightFar: number;
  47270. protected _projectionTextureUpDirection: Vector3;
  47271. /**
  47272. * Gets the Up vector of the Spotlight for texture projection.
  47273. */
  47274. /**
  47275. * Sets the Up vector of the Spotlight for texture projection.
  47276. */
  47277. projectionTextureUpDirection: Vector3;
  47278. private _projectionTexture;
  47279. /**
  47280. * Gets the projection texture of the light.
  47281. */
  47282. /**
  47283. * Sets the projection texture of the light.
  47284. */
  47285. projectionTexture: Nullable<BaseTexture>;
  47286. private _projectionTextureViewLightDirty;
  47287. private _projectionTextureProjectionLightDirty;
  47288. private _projectionTextureDirty;
  47289. private _projectionTextureViewTargetVector;
  47290. private _projectionTextureViewLightMatrix;
  47291. private _projectionTextureProjectionLightMatrix;
  47292. private _projectionTextureScalingMatrix;
  47293. /**
  47294. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47295. * It can cast shadows.
  47296. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47297. * @param name The light friendly name
  47298. * @param position The position of the spot light in the scene
  47299. * @param direction The direction of the light in the scene
  47300. * @param angle The cone angle of the light in Radians
  47301. * @param exponent The light decay speed with the distance from the emission spot
  47302. * @param scene The scene the lights belongs to
  47303. */
  47304. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47305. /**
  47306. * Returns the string "SpotLight".
  47307. * @returns the class name
  47308. */
  47309. getClassName(): string;
  47310. /**
  47311. * Returns the integer 2.
  47312. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47313. */
  47314. getTypeID(): number;
  47315. /**
  47316. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47317. */
  47318. protected _setDirection(value: Vector3): void;
  47319. /**
  47320. * Overrides the position setter to recompute the projection texture view light Matrix.
  47321. */
  47322. protected _setPosition(value: Vector3): void;
  47323. /**
  47324. * 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.
  47325. * Returns the SpotLight.
  47326. */
  47327. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47328. protected _computeProjectionTextureViewLightMatrix(): void;
  47329. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47330. /**
  47331. * Main function for light texture projection matrix computing.
  47332. */
  47333. protected _computeProjectionTextureMatrix(): void;
  47334. protected _buildUniformLayout(): void;
  47335. private _computeAngleValues;
  47336. /**
  47337. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47338. * @param effect The effect to update
  47339. * @param lightIndex The index of the light in the effect to update
  47340. * @returns The spot light
  47341. */
  47342. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47343. /**
  47344. * Disposes the light and the associated resources.
  47345. */
  47346. dispose(): void;
  47347. /**
  47348. * Prepares the list of defines specific to the light type.
  47349. * @param defines the list of defines
  47350. * @param lightIndex defines the index of the light for the effect
  47351. */
  47352. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47353. }
  47354. }
  47355. declare module "babylonjs/Lights/index" {
  47356. export * from "babylonjs/Lights/light";
  47357. export * from "babylonjs/Lights/shadowLight";
  47358. export * from "babylonjs/Lights/Shadows/index";
  47359. export * from "babylonjs/Lights/directionalLight";
  47360. export * from "babylonjs/Lights/hemisphericLight";
  47361. export * from "babylonjs/Lights/pointLight";
  47362. export * from "babylonjs/Lights/spotLight";
  47363. }
  47364. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  47365. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47366. /**
  47367. * Header information of HDR texture files.
  47368. */
  47369. export interface HDRInfo {
  47370. /**
  47371. * The height of the texture in pixels.
  47372. */
  47373. height: number;
  47374. /**
  47375. * The width of the texture in pixels.
  47376. */
  47377. width: number;
  47378. /**
  47379. * The index of the beginning of the data in the binary file.
  47380. */
  47381. dataPosition: number;
  47382. }
  47383. /**
  47384. * This groups tools to convert HDR texture to native colors array.
  47385. */
  47386. export class HDRTools {
  47387. private static Ldexp;
  47388. private static Rgbe2float;
  47389. private static readStringLine;
  47390. /**
  47391. * Reads header information from an RGBE texture stored in a native array.
  47392. * More information on this format are available here:
  47393. * https://en.wikipedia.org/wiki/RGBE_image_format
  47394. *
  47395. * @param uint8array The binary file stored in native array.
  47396. * @return The header information.
  47397. */
  47398. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47399. /**
  47400. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47401. * This RGBE texture needs to store the information as a panorama.
  47402. *
  47403. * More information on this format are available here:
  47404. * https://en.wikipedia.org/wiki/RGBE_image_format
  47405. *
  47406. * @param buffer The binary file stored in an array buffer.
  47407. * @param size The expected size of the extracted cubemap.
  47408. * @return The Cube Map information.
  47409. */
  47410. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47411. /**
  47412. * Returns the pixels data extracted from an RGBE texture.
  47413. * This pixels will be stored left to right up to down in the R G B order in one array.
  47414. *
  47415. * More information on this format are available here:
  47416. * https://en.wikipedia.org/wiki/RGBE_image_format
  47417. *
  47418. * @param uint8array The binary file stored in an array buffer.
  47419. * @param hdrInfo The header information of the file.
  47420. * @return The pixels data in RGB right to left up to down order.
  47421. */
  47422. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47423. private static RGBE_ReadPixels_RLE;
  47424. }
  47425. }
  47426. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  47427. import { Nullable } from "babylonjs/types";
  47428. import { Scene } from "babylonjs/scene";
  47429. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47431. /**
  47432. * This represents a texture coming from an HDR input.
  47433. *
  47434. * The only supported format is currently panorama picture stored in RGBE format.
  47435. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47436. */
  47437. export class HDRCubeTexture extends BaseTexture {
  47438. private static _facesMapping;
  47439. private _generateHarmonics;
  47440. private _noMipmap;
  47441. private _textureMatrix;
  47442. private _size;
  47443. private _onLoad;
  47444. private _onError;
  47445. /**
  47446. * The texture URL.
  47447. */
  47448. url: string;
  47449. /**
  47450. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47451. */
  47452. coordinatesMode: number;
  47453. protected _isBlocking: boolean;
  47454. /**
  47455. * Sets wether or not the texture is blocking during loading.
  47456. */
  47457. /**
  47458. * Gets wether or not the texture is blocking during loading.
  47459. */
  47460. isBlocking: boolean;
  47461. protected _rotationY: number;
  47462. /**
  47463. * Sets texture matrix rotation angle around Y axis in radians.
  47464. */
  47465. /**
  47466. * Gets texture matrix rotation angle around Y axis radians.
  47467. */
  47468. rotationY: number;
  47469. /**
  47470. * Gets or sets the center of the bounding box associated with the cube texture
  47471. * It must define where the camera used to render the texture was set
  47472. */
  47473. boundingBoxPosition: Vector3;
  47474. private _boundingBoxSize;
  47475. /**
  47476. * Gets or sets the size of the bounding box associated with the cube texture
  47477. * When defined, the cubemap will switch to local mode
  47478. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47479. * @example https://www.babylonjs-playground.com/#RNASML
  47480. */
  47481. boundingBoxSize: Vector3;
  47482. /**
  47483. * Instantiates an HDRTexture from the following parameters.
  47484. *
  47485. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47486. * @param scene The scene the texture will be used in
  47487. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47488. * @param noMipmap Forces to not generate the mipmap if true
  47489. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47490. * @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)
  47491. * @param reserved Reserved flag for internal use.
  47492. */
  47493. 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>);
  47494. /**
  47495. * Get the current class name of the texture useful for serialization or dynamic coding.
  47496. * @returns "HDRCubeTexture"
  47497. */
  47498. getClassName(): string;
  47499. /**
  47500. * Occurs when the file is raw .hdr file.
  47501. */
  47502. private loadTexture;
  47503. clone(): HDRCubeTexture;
  47504. delayLoad(): void;
  47505. /**
  47506. * Get the texture reflection matrix used to rotate/transform the reflection.
  47507. * @returns the reflection matrix
  47508. */
  47509. getReflectionTextureMatrix(): Matrix;
  47510. /**
  47511. * Set the texture reflection matrix used to rotate/transform the reflection.
  47512. * @param value Define the reflection matrix to set
  47513. */
  47514. setReflectionTextureMatrix(value: Matrix): void;
  47515. /**
  47516. * Parses a JSON representation of an HDR Texture in order to create the texture
  47517. * @param parsedTexture Define the JSON representation
  47518. * @param scene Define the scene the texture should be created in
  47519. * @param rootUrl Define the root url in case we need to load relative dependencies
  47520. * @returns the newly created texture after parsing
  47521. */
  47522. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47523. serialize(): any;
  47524. }
  47525. }
  47526. declare module "babylonjs/Physics/physicsEngine" {
  47527. import { Nullable } from "babylonjs/types";
  47528. import { Vector3 } from "babylonjs/Maths/math";
  47529. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47530. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47531. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47532. /**
  47533. * Class used to control physics engine
  47534. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47535. */
  47536. export class PhysicsEngine implements IPhysicsEngine {
  47537. private _physicsPlugin;
  47538. /**
  47539. * Global value used to control the smallest number supported by the simulation
  47540. */
  47541. static Epsilon: number;
  47542. private _impostors;
  47543. private _joints;
  47544. /**
  47545. * Gets the gravity vector used by the simulation
  47546. */
  47547. gravity: Vector3;
  47548. /**
  47549. * Factory used to create the default physics plugin.
  47550. * @returns The default physics plugin
  47551. */
  47552. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47553. /**
  47554. * Creates a new Physics Engine
  47555. * @param gravity defines the gravity vector used by the simulation
  47556. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47557. */
  47558. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47559. /**
  47560. * Sets the gravity vector used by the simulation
  47561. * @param gravity defines the gravity vector to use
  47562. */
  47563. setGravity(gravity: Vector3): void;
  47564. /**
  47565. * Set the time step of the physics engine.
  47566. * Default is 1/60.
  47567. * To slow it down, enter 1/600 for example.
  47568. * To speed it up, 1/30
  47569. * @param newTimeStep defines the new timestep to apply to this world.
  47570. */
  47571. setTimeStep(newTimeStep?: number): void;
  47572. /**
  47573. * Get the time step of the physics engine.
  47574. * @returns the current time step
  47575. */
  47576. getTimeStep(): number;
  47577. /**
  47578. * Release all resources
  47579. */
  47580. dispose(): void;
  47581. /**
  47582. * Gets the name of the current physics plugin
  47583. * @returns the name of the plugin
  47584. */
  47585. getPhysicsPluginName(): string;
  47586. /**
  47587. * Adding a new impostor for the impostor tracking.
  47588. * This will be done by the impostor itself.
  47589. * @param impostor the impostor to add
  47590. */
  47591. addImpostor(impostor: PhysicsImpostor): void;
  47592. /**
  47593. * Remove an impostor from the engine.
  47594. * This impostor and its mesh will not longer be updated by the physics engine.
  47595. * @param impostor the impostor to remove
  47596. */
  47597. removeImpostor(impostor: PhysicsImpostor): void;
  47598. /**
  47599. * Add a joint to the physics engine
  47600. * @param mainImpostor defines the main impostor to which the joint is added.
  47601. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47602. * @param joint defines the joint that will connect both impostors.
  47603. */
  47604. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47605. /**
  47606. * Removes a joint from the simulation
  47607. * @param mainImpostor defines the impostor used with the joint
  47608. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47609. * @param joint defines the joint to remove
  47610. */
  47611. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47612. /**
  47613. * Called by the scene. No need to call it.
  47614. * @param delta defines the timespam between frames
  47615. */
  47616. _step(delta: number): void;
  47617. /**
  47618. * Gets the current plugin used to run the simulation
  47619. * @returns current plugin
  47620. */
  47621. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47622. /**
  47623. * Gets the list of physic impostors
  47624. * @returns an array of PhysicsImpostor
  47625. */
  47626. getImpostors(): Array<PhysicsImpostor>;
  47627. /**
  47628. * Gets the impostor for a physics enabled object
  47629. * @param object defines the object impersonated by the impostor
  47630. * @returns the PhysicsImpostor or null if not found
  47631. */
  47632. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47633. /**
  47634. * Gets the impostor for a physics body object
  47635. * @param body defines physics body used by the impostor
  47636. * @returns the PhysicsImpostor or null if not found
  47637. */
  47638. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47639. }
  47640. }
  47641. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47642. import { Nullable } from "babylonjs/types";
  47643. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47645. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47646. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47647. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47648. /** @hidden */
  47649. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47650. private _useDeltaForWorldStep;
  47651. world: any;
  47652. name: string;
  47653. private _physicsMaterials;
  47654. private _fixedTimeStep;
  47655. BJSCANNON: any;
  47656. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47657. setGravity(gravity: Vector3): void;
  47658. setTimeStep(timeStep: number): void;
  47659. getTimeStep(): number;
  47660. executeStep(delta: number): void;
  47661. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47662. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47663. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47664. private _processChildMeshes;
  47665. removePhysicsBody(impostor: PhysicsImpostor): void;
  47666. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47667. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47668. private _addMaterial;
  47669. private _checkWithEpsilon;
  47670. private _createShape;
  47671. private _createHeightmap;
  47672. private _minus90X;
  47673. private _plus90X;
  47674. private _tmpPosition;
  47675. private _tmpDeltaPosition;
  47676. private _tmpUnityRotation;
  47677. private _updatePhysicsBodyTransformation;
  47678. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47679. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47680. isSupported(): boolean;
  47681. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47682. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47683. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47684. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47685. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47686. getBodyMass(impostor: PhysicsImpostor): number;
  47687. getBodyFriction(impostor: PhysicsImpostor): number;
  47688. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47689. getBodyRestitution(impostor: PhysicsImpostor): number;
  47690. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47691. sleepBody(impostor: PhysicsImpostor): void;
  47692. wakeUpBody(impostor: PhysicsImpostor): void;
  47693. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47694. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47695. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47696. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47697. getRadius(impostor: PhysicsImpostor): number;
  47698. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47699. dispose(): void;
  47700. private _extendNamespace;
  47701. }
  47702. }
  47703. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47704. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47705. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47706. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47708. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47709. import { Nullable } from "babylonjs/types";
  47710. /** @hidden */
  47711. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47712. world: any;
  47713. name: string;
  47714. BJSOIMO: any;
  47715. constructor(iterations?: number, oimoInjection?: any);
  47716. setGravity(gravity: Vector3): void;
  47717. setTimeStep(timeStep: number): void;
  47718. getTimeStep(): number;
  47719. private _tmpImpostorsArray;
  47720. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47721. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47722. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47723. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47724. private _tmpPositionVector;
  47725. removePhysicsBody(impostor: PhysicsImpostor): void;
  47726. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47727. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47728. isSupported(): boolean;
  47729. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47730. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47731. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47732. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47733. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47734. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47735. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47736. getBodyMass(impostor: PhysicsImpostor): number;
  47737. getBodyFriction(impostor: PhysicsImpostor): number;
  47738. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47739. getBodyRestitution(impostor: PhysicsImpostor): number;
  47740. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47741. sleepBody(impostor: PhysicsImpostor): void;
  47742. wakeUpBody(impostor: PhysicsImpostor): void;
  47743. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47744. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47745. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47746. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47747. getRadius(impostor: PhysicsImpostor): number;
  47748. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47749. dispose(): void;
  47750. }
  47751. }
  47752. declare module "babylonjs/Probes/reflectionProbe" {
  47753. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47754. import { Vector3 } from "babylonjs/Maths/math";
  47755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47756. import { Nullable } from "babylonjs/types";
  47757. import { Scene } from "babylonjs/scene";
  47758. module "babylonjs/abstractScene" {
  47759. interface AbstractScene {
  47760. /**
  47761. * The list of reflection probes added to the scene
  47762. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47763. */
  47764. reflectionProbes: Array<ReflectionProbe>;
  47765. /**
  47766. * Removes the given reflection probe from this scene.
  47767. * @param toRemove The reflection probe to remove
  47768. * @returns The index of the removed reflection probe
  47769. */
  47770. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47771. /**
  47772. * Adds the given reflection probe to this scene.
  47773. * @param newReflectionProbe The reflection probe to add
  47774. */
  47775. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47776. }
  47777. }
  47778. /**
  47779. * Class used to generate realtime reflection / refraction cube textures
  47780. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47781. */
  47782. export class ReflectionProbe {
  47783. /** defines the name of the probe */
  47784. name: string;
  47785. private _scene;
  47786. private _renderTargetTexture;
  47787. private _projectionMatrix;
  47788. private _viewMatrix;
  47789. private _target;
  47790. private _add;
  47791. private _attachedMesh;
  47792. private _invertYAxis;
  47793. /** Gets or sets probe position (center of the cube map) */
  47794. position: Vector3;
  47795. /**
  47796. * Creates a new reflection probe
  47797. * @param name defines the name of the probe
  47798. * @param size defines the texture resolution (for each face)
  47799. * @param scene defines the hosting scene
  47800. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47801. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47802. */
  47803. constructor(
  47804. /** defines the name of the probe */
  47805. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47806. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47807. samples: number;
  47808. /** Gets or sets the refresh rate to use (on every frame by default) */
  47809. refreshRate: number;
  47810. /**
  47811. * Gets the hosting scene
  47812. * @returns a Scene
  47813. */
  47814. getScene(): Scene;
  47815. /** Gets the internal CubeTexture used to render to */
  47816. readonly cubeTexture: RenderTargetTexture;
  47817. /** Gets the list of meshes to render */
  47818. readonly renderList: Nullable<AbstractMesh[]>;
  47819. /**
  47820. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47821. * @param mesh defines the mesh to attach to
  47822. */
  47823. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47824. /**
  47825. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47826. * @param renderingGroupId The rendering group id corresponding to its index
  47827. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47828. */
  47829. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47830. /**
  47831. * Clean all associated resources
  47832. */
  47833. dispose(): void;
  47834. /**
  47835. * Converts the reflection probe information to a readable string for debug purpose.
  47836. * @param fullDetails Supports for multiple levels of logging within scene loading
  47837. * @returns the human readable reflection probe info
  47838. */
  47839. toString(fullDetails?: boolean): string;
  47840. /**
  47841. * Get the class name of the relfection probe.
  47842. * @returns "ReflectionProbe"
  47843. */
  47844. getClassName(): string;
  47845. /**
  47846. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47847. * @returns The JSON representation of the texture
  47848. */
  47849. serialize(): any;
  47850. /**
  47851. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47852. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47853. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47854. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47855. * @returns The parsed reflection probe if successful
  47856. */
  47857. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47858. }
  47859. }
  47860. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  47861. /** @hidden */
  47862. export var _BabylonLoaderRegistered: boolean;
  47863. }
  47864. declare module "babylonjs/Loading/Plugins/index" {
  47865. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  47866. }
  47867. declare module "babylonjs/Loading/index" {
  47868. export * from "babylonjs/Loading/loadingScreen";
  47869. export * from "babylonjs/Loading/Plugins/index";
  47870. export * from "babylonjs/Loading/sceneLoader";
  47871. export * from "babylonjs/Loading/sceneLoaderFlags";
  47872. }
  47873. declare module "babylonjs/Materials/Background/index" {
  47874. export * from "babylonjs/Materials/Background/backgroundMaterial";
  47875. }
  47876. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  47877. import { Scene } from "babylonjs/scene";
  47878. import { Color3 } from "babylonjs/Maths/math";
  47879. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47881. /**
  47882. * The Physically based simple base material of BJS.
  47883. *
  47884. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47885. * It is used as the base class for both the specGloss and metalRough conventions.
  47886. */
  47887. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47888. /**
  47889. * Number of Simultaneous lights allowed on the material.
  47890. */
  47891. maxSimultaneousLights: number;
  47892. /**
  47893. * If sets to true, disables all the lights affecting the material.
  47894. */
  47895. disableLighting: boolean;
  47896. /**
  47897. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47898. */
  47899. environmentTexture: BaseTexture;
  47900. /**
  47901. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47902. */
  47903. invertNormalMapX: boolean;
  47904. /**
  47905. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47906. */
  47907. invertNormalMapY: boolean;
  47908. /**
  47909. * Normal map used in the model.
  47910. */
  47911. normalTexture: BaseTexture;
  47912. /**
  47913. * Emissivie color used to self-illuminate the model.
  47914. */
  47915. emissiveColor: Color3;
  47916. /**
  47917. * Emissivie texture used to self-illuminate the model.
  47918. */
  47919. emissiveTexture: BaseTexture;
  47920. /**
  47921. * Occlusion Channel Strenght.
  47922. */
  47923. occlusionStrength: number;
  47924. /**
  47925. * Occlusion Texture of the material (adding extra occlusion effects).
  47926. */
  47927. occlusionTexture: BaseTexture;
  47928. /**
  47929. * Defines the alpha limits in alpha test mode.
  47930. */
  47931. alphaCutOff: number;
  47932. /**
  47933. * Gets the current double sided mode.
  47934. */
  47935. /**
  47936. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47937. */
  47938. doubleSided: boolean;
  47939. /**
  47940. * Stores the pre-calculated light information of a mesh in a texture.
  47941. */
  47942. lightmapTexture: BaseTexture;
  47943. /**
  47944. * If true, the light map contains occlusion information instead of lighting info.
  47945. */
  47946. useLightmapAsShadowmap: boolean;
  47947. /**
  47948. * Return the active textures of the material.
  47949. */
  47950. getActiveTextures(): BaseTexture[];
  47951. hasTexture(texture: BaseTexture): boolean;
  47952. /**
  47953. * Instantiates a new PBRMaterial instance.
  47954. *
  47955. * @param name The material name
  47956. * @param scene The scene the material will be use in.
  47957. */
  47958. constructor(name: string, scene: Scene);
  47959. getClassName(): string;
  47960. }
  47961. }
  47962. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  47963. import { Scene } from "babylonjs/scene";
  47964. import { Color3 } from "babylonjs/Maths/math";
  47965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47966. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47967. /**
  47968. * The PBR material of BJS following the metal roughness convention.
  47969. *
  47970. * This fits to the PBR convention in the GLTF definition:
  47971. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47972. */
  47973. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47974. /**
  47975. * The base color has two different interpretations depending on the value of metalness.
  47976. * When the material is a metal, the base color is the specific measured reflectance value
  47977. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47978. * of the material.
  47979. */
  47980. baseColor: Color3;
  47981. /**
  47982. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47983. * well as opacity information in the alpha channel.
  47984. */
  47985. baseTexture: BaseTexture;
  47986. /**
  47987. * Specifies the metallic scalar value of the material.
  47988. * Can also be used to scale the metalness values of the metallic texture.
  47989. */
  47990. metallic: number;
  47991. /**
  47992. * Specifies the roughness scalar value of the material.
  47993. * Can also be used to scale the roughness values of the metallic texture.
  47994. */
  47995. roughness: number;
  47996. /**
  47997. * Texture containing both the metallic value in the B channel and the
  47998. * roughness value in the G channel to keep better precision.
  47999. */
  48000. metallicRoughnessTexture: BaseTexture;
  48001. /**
  48002. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48003. *
  48004. * @param name The material name
  48005. * @param scene The scene the material will be use in.
  48006. */
  48007. constructor(name: string, scene: Scene);
  48008. /**
  48009. * Return the currrent class name of the material.
  48010. */
  48011. getClassName(): string;
  48012. /**
  48013. * Return the active textures of the material.
  48014. */
  48015. getActiveTextures(): BaseTexture[];
  48016. /**
  48017. * Checks to see if a texture is used in the material.
  48018. * @param texture - Base texture to use.
  48019. * @returns - Boolean specifying if a texture is used in the material.
  48020. */
  48021. hasTexture(texture: BaseTexture): boolean;
  48022. /**
  48023. * Makes a duplicate of the current material.
  48024. * @param name - name to use for the new material.
  48025. */
  48026. clone(name: string): PBRMetallicRoughnessMaterial;
  48027. /**
  48028. * Serialize the material to a parsable JSON object.
  48029. */
  48030. serialize(): any;
  48031. /**
  48032. * Parses a JSON object correponding to the serialize function.
  48033. */
  48034. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48035. }
  48036. }
  48037. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  48038. import { Scene } from "babylonjs/scene";
  48039. import { Color3 } from "babylonjs/Maths/math";
  48040. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48041. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48042. /**
  48043. * The PBR material of BJS following the specular glossiness convention.
  48044. *
  48045. * This fits to the PBR convention in the GLTF definition:
  48046. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48047. */
  48048. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48049. /**
  48050. * Specifies the diffuse color of the material.
  48051. */
  48052. diffuseColor: Color3;
  48053. /**
  48054. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48055. * channel.
  48056. */
  48057. diffuseTexture: BaseTexture;
  48058. /**
  48059. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48060. */
  48061. specularColor: Color3;
  48062. /**
  48063. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48064. */
  48065. glossiness: number;
  48066. /**
  48067. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48068. */
  48069. specularGlossinessTexture: BaseTexture;
  48070. /**
  48071. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48072. *
  48073. * @param name The material name
  48074. * @param scene The scene the material will be use in.
  48075. */
  48076. constructor(name: string, scene: Scene);
  48077. /**
  48078. * Return the currrent class name of the material.
  48079. */
  48080. getClassName(): string;
  48081. /**
  48082. * Return the active textures of the material.
  48083. */
  48084. getActiveTextures(): BaseTexture[];
  48085. /**
  48086. * Checks to see if a texture is used in the material.
  48087. * @param texture - Base texture to use.
  48088. * @returns - Boolean specifying if a texture is used in the material.
  48089. */
  48090. hasTexture(texture: BaseTexture): boolean;
  48091. /**
  48092. * Makes a duplicate of the current material.
  48093. * @param name - name to use for the new material.
  48094. */
  48095. clone(name: string): PBRSpecularGlossinessMaterial;
  48096. /**
  48097. * Serialize the material to a parsable JSON object.
  48098. */
  48099. serialize(): any;
  48100. /**
  48101. * Parses a JSON object correponding to the serialize function.
  48102. */
  48103. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48104. }
  48105. }
  48106. declare module "babylonjs/Materials/PBR/index" {
  48107. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48108. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48109. export * from "babylonjs/Materials/PBR/pbrMaterial";
  48110. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  48111. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  48112. }
  48113. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  48114. import { Nullable } from "babylonjs/types";
  48115. import { Scene } from "babylonjs/scene";
  48116. import { Matrix } from "babylonjs/Maths/math";
  48117. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48118. /**
  48119. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48120. * It can help converting any input color in a desired output one. This can then be used to create effects
  48121. * from sepia, black and white to sixties or futuristic rendering...
  48122. *
  48123. * The only supported format is currently 3dl.
  48124. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48125. */
  48126. export class ColorGradingTexture extends BaseTexture {
  48127. /**
  48128. * The current texture matrix. (will always be identity in color grading texture)
  48129. */
  48130. private _textureMatrix;
  48131. /**
  48132. * The texture URL.
  48133. */
  48134. url: string;
  48135. /**
  48136. * Empty line regex stored for GC.
  48137. */
  48138. private static _noneEmptyLineRegex;
  48139. private _engine;
  48140. /**
  48141. * Instantiates a ColorGradingTexture from the following parameters.
  48142. *
  48143. * @param url The location of the color gradind data (currently only supporting 3dl)
  48144. * @param scene The scene the texture will be used in
  48145. */
  48146. constructor(url: string, scene: Scene);
  48147. /**
  48148. * Returns the texture matrix used in most of the material.
  48149. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48150. */
  48151. getTextureMatrix(): Matrix;
  48152. /**
  48153. * Occurs when the file being loaded is a .3dl LUT file.
  48154. */
  48155. private load3dlTexture;
  48156. /**
  48157. * Starts the loading process of the texture.
  48158. */
  48159. private loadTexture;
  48160. /**
  48161. * Clones the color gradind texture.
  48162. */
  48163. clone(): ColorGradingTexture;
  48164. /**
  48165. * Called during delayed load for textures.
  48166. */
  48167. delayLoad(): void;
  48168. /**
  48169. * Parses a color grading texture serialized by Babylon.
  48170. * @param parsedTexture The texture information being parsedTexture
  48171. * @param scene The scene to load the texture in
  48172. * @param rootUrl The root url of the data assets to load
  48173. * @return A color gradind texture
  48174. */
  48175. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48176. /**
  48177. * Serializes the LUT texture to json format.
  48178. */
  48179. serialize(): any;
  48180. }
  48181. }
  48182. declare module "babylonjs/Misc/dds" {
  48183. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48184. import { Engine } from "babylonjs/Engines/engine";
  48185. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48186. import { Nullable } from "babylonjs/types";
  48187. import { Scene } from "babylonjs/scene";
  48188. /**
  48189. * Direct draw surface info
  48190. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48191. */
  48192. export interface DDSInfo {
  48193. /**
  48194. * Width of the texture
  48195. */
  48196. width: number;
  48197. /**
  48198. * Width of the texture
  48199. */
  48200. height: number;
  48201. /**
  48202. * Number of Mipmaps for the texture
  48203. * @see https://en.wikipedia.org/wiki/Mipmap
  48204. */
  48205. mipmapCount: number;
  48206. /**
  48207. * If the textures format is a known fourCC format
  48208. * @see https://www.fourcc.org/
  48209. */
  48210. isFourCC: boolean;
  48211. /**
  48212. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48213. */
  48214. isRGB: boolean;
  48215. /**
  48216. * If the texture is a lumincance format
  48217. */
  48218. isLuminance: boolean;
  48219. /**
  48220. * If this is a cube texture
  48221. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48222. */
  48223. isCube: boolean;
  48224. /**
  48225. * If the texture is a compressed format eg. FOURCC_DXT1
  48226. */
  48227. isCompressed: boolean;
  48228. /**
  48229. * The dxgiFormat of the texture
  48230. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48231. */
  48232. dxgiFormat: number;
  48233. /**
  48234. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48235. */
  48236. textureType: number;
  48237. /**
  48238. * Sphericle polynomial created for the dds texture
  48239. */
  48240. sphericalPolynomial?: SphericalPolynomial;
  48241. }
  48242. /**
  48243. * Class used to provide DDS decompression tools
  48244. */
  48245. export class DDSTools {
  48246. /**
  48247. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48248. */
  48249. static StoreLODInAlphaChannel: boolean;
  48250. /**
  48251. * Gets DDS information from an array buffer
  48252. * @param arrayBuffer defines the array buffer to read data from
  48253. * @returns the DDS information
  48254. */
  48255. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48256. private static _FloatView;
  48257. private static _Int32View;
  48258. private static _ToHalfFloat;
  48259. private static _FromHalfFloat;
  48260. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48261. private static _GetHalfFloatRGBAArrayBuffer;
  48262. private static _GetFloatRGBAArrayBuffer;
  48263. private static _GetFloatAsUIntRGBAArrayBuffer;
  48264. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48265. private static _GetRGBAArrayBuffer;
  48266. private static _ExtractLongWordOrder;
  48267. private static _GetRGBArrayBuffer;
  48268. private static _GetLuminanceArrayBuffer;
  48269. /**
  48270. * Uploads DDS Levels to a Babylon Texture
  48271. * @hidden
  48272. */
  48273. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48274. }
  48275. module "babylonjs/Engines/engine" {
  48276. interface Engine {
  48277. /**
  48278. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48279. * @param rootUrl defines the url where the file to load is located
  48280. * @param scene defines the current scene
  48281. * @param lodScale defines scale to apply to the mip map selection
  48282. * @param lodOffset defines offset to apply to the mip map selection
  48283. * @param onLoad defines an optional callback raised when the texture is loaded
  48284. * @param onError defines an optional callback raised if there is an issue to load the texture
  48285. * @param format defines the format of the data
  48286. * @param forcedExtension defines the extension to use to pick the right loader
  48287. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48288. * @returns the cube texture as an InternalTexture
  48289. */
  48290. 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;
  48291. }
  48292. }
  48293. }
  48294. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48295. import { Nullable } from "babylonjs/types";
  48296. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48297. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48298. /**
  48299. * Implementation of the DDS Texture Loader.
  48300. * @hidden
  48301. */
  48302. export class _DDSTextureLoader implements IInternalTextureLoader {
  48303. /**
  48304. * Defines wether the loader supports cascade loading the different faces.
  48305. */
  48306. readonly supportCascades: boolean;
  48307. /**
  48308. * This returns if the loader support the current file information.
  48309. * @param extension defines the file extension of the file being loaded
  48310. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48311. * @param fallback defines the fallback internal texture if any
  48312. * @param isBase64 defines whether the texture is encoded as a base64
  48313. * @param isBuffer defines whether the texture data are stored as a buffer
  48314. * @returns true if the loader can load the specified file
  48315. */
  48316. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48317. /**
  48318. * Transform the url before loading if required.
  48319. * @param rootUrl the url of the texture
  48320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48321. * @returns the transformed texture
  48322. */
  48323. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48324. /**
  48325. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48326. * @param rootUrl the url of the texture
  48327. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48328. * @returns the fallback texture
  48329. */
  48330. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48331. /**
  48332. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48333. * @param data contains the texture data
  48334. * @param texture defines the BabylonJS internal texture
  48335. * @param createPolynomials will be true if polynomials have been requested
  48336. * @param onLoad defines the callback to trigger once the texture is ready
  48337. * @param onError defines the callback to trigger in case of error
  48338. */
  48339. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48340. /**
  48341. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48342. * @param data contains the texture data
  48343. * @param texture defines the BabylonJS internal texture
  48344. * @param callback defines the method to call once ready to upload
  48345. */
  48346. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48347. }
  48348. }
  48349. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48350. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48351. /** @hidden */
  48352. export var rgbdEncodePixelShader: {
  48353. name: string;
  48354. shader: string;
  48355. };
  48356. }
  48357. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48358. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48359. /** @hidden */
  48360. export var rgbdDecodePixelShader: {
  48361. name: string;
  48362. shader: string;
  48363. };
  48364. }
  48365. declare module "babylonjs/Misc/environmentTextureTools" {
  48366. import { Nullable } from "babylonjs/types";
  48367. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48368. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48369. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48370. import "babylonjs/Shaders/rgbdEncode.fragment";
  48371. import "babylonjs/Shaders/rgbdDecode.fragment";
  48372. /**
  48373. * Raw texture data and descriptor sufficient for WebGL texture upload
  48374. */
  48375. export interface EnvironmentTextureInfo {
  48376. /**
  48377. * Version of the environment map
  48378. */
  48379. version: number;
  48380. /**
  48381. * Width of image
  48382. */
  48383. width: number;
  48384. /**
  48385. * Irradiance information stored in the file.
  48386. */
  48387. irradiance: any;
  48388. /**
  48389. * Specular information stored in the file.
  48390. */
  48391. specular: any;
  48392. }
  48393. /**
  48394. * Sets of helpers addressing the serialization and deserialization of environment texture
  48395. * stored in a BabylonJS env file.
  48396. * Those files are usually stored as .env files.
  48397. */
  48398. export class EnvironmentTextureTools {
  48399. /**
  48400. * Magic number identifying the env file.
  48401. */
  48402. private static _MagicBytes;
  48403. /**
  48404. * Gets the environment info from an env file.
  48405. * @param data The array buffer containing the .env bytes.
  48406. * @returns the environment file info (the json header) if successfully parsed.
  48407. */
  48408. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48409. /**
  48410. * Creates an environment texture from a loaded cube texture.
  48411. * @param texture defines the cube texture to convert in env file
  48412. * @return a promise containing the environment data if succesfull.
  48413. */
  48414. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48415. /**
  48416. * Creates a JSON representation of the spherical data.
  48417. * @param texture defines the texture containing the polynomials
  48418. * @return the JSON representation of the spherical info
  48419. */
  48420. private static _CreateEnvTextureIrradiance;
  48421. /**
  48422. * Uploads the texture info contained in the env file to the GPU.
  48423. * @param texture defines the internal texture to upload to
  48424. * @param arrayBuffer defines the buffer cotaining the data to load
  48425. * @param info defines the texture info retrieved through the GetEnvInfo method
  48426. * @returns a promise
  48427. */
  48428. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48429. /**
  48430. * Uploads the levels of image data to the GPU.
  48431. * @param texture defines the internal texture to upload to
  48432. * @param imageData defines the array buffer views of image data [mipmap][face]
  48433. * @returns a promise
  48434. */
  48435. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48436. /**
  48437. * Uploads spherical polynomials information to the texture.
  48438. * @param texture defines the texture we are trying to upload the information to
  48439. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48440. */
  48441. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48442. /** @hidden */
  48443. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48444. }
  48445. }
  48446. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48447. import { Nullable } from "babylonjs/types";
  48448. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48449. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48450. /**
  48451. * Implementation of the ENV Texture Loader.
  48452. * @hidden
  48453. */
  48454. export class _ENVTextureLoader implements IInternalTextureLoader {
  48455. /**
  48456. * Defines wether the loader supports cascade loading the different faces.
  48457. */
  48458. readonly supportCascades: boolean;
  48459. /**
  48460. * This returns if the loader support the current file information.
  48461. * @param extension defines the file extension of the file being loaded
  48462. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48463. * @param fallback defines the fallback internal texture if any
  48464. * @param isBase64 defines whether the texture is encoded as a base64
  48465. * @param isBuffer defines whether the texture data are stored as a buffer
  48466. * @returns true if the loader can load the specified file
  48467. */
  48468. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48469. /**
  48470. * Transform the url before loading if required.
  48471. * @param rootUrl the url of the texture
  48472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48473. * @returns the transformed texture
  48474. */
  48475. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48476. /**
  48477. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48478. * @param rootUrl the url of the texture
  48479. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48480. * @returns the fallback texture
  48481. */
  48482. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48483. /**
  48484. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48485. * @param data contains the texture data
  48486. * @param texture defines the BabylonJS internal texture
  48487. * @param createPolynomials will be true if polynomials have been requested
  48488. * @param onLoad defines the callback to trigger once the texture is ready
  48489. * @param onError defines the callback to trigger in case of error
  48490. */
  48491. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48492. /**
  48493. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48494. * @param data contains the texture data
  48495. * @param texture defines the BabylonJS internal texture
  48496. * @param callback defines the method to call once ready to upload
  48497. */
  48498. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48499. }
  48500. }
  48501. declare module "babylonjs/Misc/khronosTextureContainer" {
  48502. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48503. /**
  48504. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48505. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48506. */
  48507. export class KhronosTextureContainer {
  48508. /** contents of the KTX container file */
  48509. arrayBuffer: any;
  48510. private static HEADER_LEN;
  48511. private static COMPRESSED_2D;
  48512. private static COMPRESSED_3D;
  48513. private static TEX_2D;
  48514. private static TEX_3D;
  48515. /**
  48516. * Gets the openGL type
  48517. */
  48518. glType: number;
  48519. /**
  48520. * Gets the openGL type size
  48521. */
  48522. glTypeSize: number;
  48523. /**
  48524. * Gets the openGL format
  48525. */
  48526. glFormat: number;
  48527. /**
  48528. * Gets the openGL internal format
  48529. */
  48530. glInternalFormat: number;
  48531. /**
  48532. * Gets the base internal format
  48533. */
  48534. glBaseInternalFormat: number;
  48535. /**
  48536. * Gets image width in pixel
  48537. */
  48538. pixelWidth: number;
  48539. /**
  48540. * Gets image height in pixel
  48541. */
  48542. pixelHeight: number;
  48543. /**
  48544. * Gets image depth in pixels
  48545. */
  48546. pixelDepth: number;
  48547. /**
  48548. * Gets the number of array elements
  48549. */
  48550. numberOfArrayElements: number;
  48551. /**
  48552. * Gets the number of faces
  48553. */
  48554. numberOfFaces: number;
  48555. /**
  48556. * Gets the number of mipmap levels
  48557. */
  48558. numberOfMipmapLevels: number;
  48559. /**
  48560. * Gets the bytes of key value data
  48561. */
  48562. bytesOfKeyValueData: number;
  48563. /**
  48564. * Gets the load type
  48565. */
  48566. loadType: number;
  48567. /**
  48568. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48569. */
  48570. isInvalid: boolean;
  48571. /**
  48572. * Creates a new KhronosTextureContainer
  48573. * @param arrayBuffer contents of the KTX container file
  48574. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48575. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48576. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48577. */
  48578. constructor(
  48579. /** contents of the KTX container file */
  48580. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48581. /**
  48582. * Uploads KTX content to a Babylon Texture.
  48583. * It is assumed that the texture has already been created & is currently bound
  48584. * @hidden
  48585. */
  48586. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48587. private _upload2DCompressedLevels;
  48588. }
  48589. }
  48590. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48591. import { Nullable } from "babylonjs/types";
  48592. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48593. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48594. /**
  48595. * Implementation of the KTX Texture Loader.
  48596. * @hidden
  48597. */
  48598. export class _KTXTextureLoader implements IInternalTextureLoader {
  48599. /**
  48600. * Defines wether the loader supports cascade loading the different faces.
  48601. */
  48602. readonly supportCascades: boolean;
  48603. /**
  48604. * This returns if the loader support the current file information.
  48605. * @param extension defines the file extension of the file being loaded
  48606. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48607. * @param fallback defines the fallback internal texture if any
  48608. * @param isBase64 defines whether the texture is encoded as a base64
  48609. * @param isBuffer defines whether the texture data are stored as a buffer
  48610. * @returns true if the loader can load the specified file
  48611. */
  48612. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48613. /**
  48614. * Transform the url before loading if required.
  48615. * @param rootUrl the url of the texture
  48616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48617. * @returns the transformed texture
  48618. */
  48619. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48620. /**
  48621. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48622. * @param rootUrl the url of the texture
  48623. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48624. * @returns the fallback texture
  48625. */
  48626. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48627. /**
  48628. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48629. * @param data contains the texture data
  48630. * @param texture defines the BabylonJS internal texture
  48631. * @param createPolynomials will be true if polynomials have been requested
  48632. * @param onLoad defines the callback to trigger once the texture is ready
  48633. * @param onError defines the callback to trigger in case of error
  48634. */
  48635. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48636. /**
  48637. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48638. * @param data contains the texture data
  48639. * @param texture defines the BabylonJS internal texture
  48640. * @param callback defines the method to call once ready to upload
  48641. */
  48642. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48643. }
  48644. }
  48645. declare module "babylonjs/Misc/tga" {
  48646. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48647. /**
  48648. * Based on jsTGALoader - Javascript loader for TGA file
  48649. * By Vincent Thibault
  48650. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48651. */
  48652. export class TGATools {
  48653. private static _TYPE_INDEXED;
  48654. private static _TYPE_RGB;
  48655. private static _TYPE_GREY;
  48656. private static _TYPE_RLE_INDEXED;
  48657. private static _TYPE_RLE_RGB;
  48658. private static _TYPE_RLE_GREY;
  48659. private static _ORIGIN_MASK;
  48660. private static _ORIGIN_SHIFT;
  48661. private static _ORIGIN_BL;
  48662. private static _ORIGIN_BR;
  48663. private static _ORIGIN_UL;
  48664. private static _ORIGIN_UR;
  48665. /**
  48666. * Gets the header of a TGA file
  48667. * @param data defines the TGA data
  48668. * @returns the header
  48669. */
  48670. static GetTGAHeader(data: Uint8Array): any;
  48671. /**
  48672. * Uploads TGA content to a Babylon Texture
  48673. * @hidden
  48674. */
  48675. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48676. /** @hidden */
  48677. 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;
  48678. /** @hidden */
  48679. 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;
  48680. /** @hidden */
  48681. 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;
  48682. /** @hidden */
  48683. 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;
  48684. /** @hidden */
  48685. 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;
  48686. /** @hidden */
  48687. 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;
  48688. }
  48689. }
  48690. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48691. import { Nullable } from "babylonjs/types";
  48692. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48693. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48694. /**
  48695. * Implementation of the TGA Texture Loader.
  48696. * @hidden
  48697. */
  48698. export class _TGATextureLoader implements IInternalTextureLoader {
  48699. /**
  48700. * Defines wether the loader supports cascade loading the different faces.
  48701. */
  48702. readonly supportCascades: boolean;
  48703. /**
  48704. * This returns if the loader support the current file information.
  48705. * @param extension defines the file extension of the file being loaded
  48706. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48707. * @param fallback defines the fallback internal texture if any
  48708. * @param isBase64 defines whether the texture is encoded as a base64
  48709. * @param isBuffer defines whether the texture data are stored as a buffer
  48710. * @returns true if the loader can load the specified file
  48711. */
  48712. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48713. /**
  48714. * Transform the url before loading if required.
  48715. * @param rootUrl the url of the texture
  48716. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48717. * @returns the transformed texture
  48718. */
  48719. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48720. /**
  48721. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48722. * @param rootUrl the url of the texture
  48723. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48724. * @returns the fallback texture
  48725. */
  48726. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48727. /**
  48728. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48729. * @param data contains the texture data
  48730. * @param texture defines the BabylonJS internal texture
  48731. * @param createPolynomials will be true if polynomials have been requested
  48732. * @param onLoad defines the callback to trigger once the texture is ready
  48733. * @param onError defines the callback to trigger in case of error
  48734. */
  48735. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48736. /**
  48737. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48738. * @param data contains the texture data
  48739. * @param texture defines the BabylonJS internal texture
  48740. * @param callback defines the method to call once ready to upload
  48741. */
  48742. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48743. }
  48744. }
  48745. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48746. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48747. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48748. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48749. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48750. }
  48751. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48752. import { Scene } from "babylonjs/scene";
  48753. import { Texture } from "babylonjs/Materials/Textures/texture";
  48754. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48755. /**
  48756. * 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.
  48757. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48758. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48759. */
  48760. export class CustomProceduralTexture extends ProceduralTexture {
  48761. private _animate;
  48762. private _time;
  48763. private _config;
  48764. private _texturePath;
  48765. /**
  48766. * Instantiates a new Custom Procedural Texture.
  48767. * 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.
  48768. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48769. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48770. * @param name Define the name of the texture
  48771. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48772. * @param size Define the size of the texture to create
  48773. * @param scene Define the scene the texture belongs to
  48774. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48775. * @param generateMipMaps Define if the texture should creates mip maps or not
  48776. */
  48777. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48778. private _loadJson;
  48779. /**
  48780. * Is the texture ready to be used ? (rendered at least once)
  48781. * @returns true if ready, otherwise, false.
  48782. */
  48783. isReady(): boolean;
  48784. /**
  48785. * Render the texture to its associated render target.
  48786. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48787. */
  48788. render(useCameraPostProcess?: boolean): void;
  48789. /**
  48790. * Update the list of dependant textures samplers in the shader.
  48791. */
  48792. updateTextures(): void;
  48793. /**
  48794. * Update the uniform values of the procedural texture in the shader.
  48795. */
  48796. updateShaderUniforms(): void;
  48797. /**
  48798. * Define if the texture animates or not.
  48799. */
  48800. animate: boolean;
  48801. }
  48802. }
  48803. declare module "babylonjs/Shaders/noise.fragment" {
  48804. /** @hidden */
  48805. export var noisePixelShader: {
  48806. name: string;
  48807. shader: string;
  48808. };
  48809. }
  48810. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48811. import { Nullable } from "babylonjs/types";
  48812. import { Scene } from "babylonjs/scene";
  48813. import { Texture } from "babylonjs/Materials/Textures/texture";
  48814. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48815. import "babylonjs/Shaders/noise.fragment";
  48816. /**
  48817. * Class used to generate noise procedural textures
  48818. */
  48819. export class NoiseProceduralTexture extends ProceduralTexture {
  48820. private _time;
  48821. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48822. brightness: number;
  48823. /** Defines the number of octaves to process */
  48824. octaves: number;
  48825. /** Defines the level of persistence (0.8 by default) */
  48826. persistence: number;
  48827. /** Gets or sets animation speed factor (default is 1) */
  48828. animationSpeedFactor: number;
  48829. /**
  48830. * Creates a new NoiseProceduralTexture
  48831. * @param name defines the name fo the texture
  48832. * @param size defines the size of the texture (default is 256)
  48833. * @param scene defines the hosting scene
  48834. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48835. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48836. */
  48837. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48838. private _updateShaderUniforms;
  48839. protected _getDefines(): string;
  48840. /** Generate the current state of the procedural texture */
  48841. render(useCameraPostProcess?: boolean): void;
  48842. /**
  48843. * Serializes this noise procedural texture
  48844. * @returns a serialized noise procedural texture object
  48845. */
  48846. serialize(): any;
  48847. /**
  48848. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48849. * @param parsedTexture defines parsed texture data
  48850. * @param scene defines the current scene
  48851. * @param rootUrl defines the root URL containing noise procedural texture information
  48852. * @returns a parsed NoiseProceduralTexture
  48853. */
  48854. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48855. }
  48856. }
  48857. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  48858. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  48859. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  48860. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48861. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  48862. }
  48863. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  48864. import { Nullable } from "babylonjs/types";
  48865. import { Scene } from "babylonjs/scene";
  48866. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48867. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48868. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48869. /**
  48870. * Raw cube texture where the raw buffers are passed in
  48871. */
  48872. export class RawCubeTexture extends CubeTexture {
  48873. /**
  48874. * Creates a cube texture where the raw buffers are passed in.
  48875. * @param scene defines the scene the texture is attached to
  48876. * @param data defines the array of data to use to create each face
  48877. * @param size defines the size of the textures
  48878. * @param format defines the format of the data
  48879. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48880. * @param generateMipMaps defines if the engine should generate the mip levels
  48881. * @param invertY defines if data must be stored with Y axis inverted
  48882. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48883. * @param compression defines the compression used (null by default)
  48884. */
  48885. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48886. /**
  48887. * Updates the raw cube texture.
  48888. * @param data defines the data to store
  48889. * @param format defines the data format
  48890. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48891. * @param invertY defines if data must be stored with Y axis inverted
  48892. * @param compression defines the compression used (null by default)
  48893. * @param level defines which level of the texture to update
  48894. */
  48895. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48896. /**
  48897. * Updates a raw cube texture with RGBD encoded data.
  48898. * @param data defines the array of data [mipmap][face] to use to create each face
  48899. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48900. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48901. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48902. * @returns a promsie that resolves when the operation is complete
  48903. */
  48904. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48905. /**
  48906. * Clones the raw cube texture.
  48907. * @return a new cube texture
  48908. */
  48909. clone(): CubeTexture;
  48910. /** @hidden */
  48911. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48912. }
  48913. }
  48914. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  48915. import { Scene } from "babylonjs/scene";
  48916. import { Texture } from "babylonjs/Materials/Textures/texture";
  48917. /**
  48918. * Class used to store 3D textures containing user data
  48919. */
  48920. export class RawTexture3D extends Texture {
  48921. /** Gets or sets the texture format to use */
  48922. format: number;
  48923. private _engine;
  48924. /**
  48925. * Create a new RawTexture3D
  48926. * @param data defines the data of the texture
  48927. * @param width defines the width of the texture
  48928. * @param height defines the height of the texture
  48929. * @param depth defines the depth of the texture
  48930. * @param format defines the texture format to use
  48931. * @param scene defines the hosting scene
  48932. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48933. * @param invertY defines if texture must be stored with Y axis inverted
  48934. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48935. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48936. */
  48937. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48938. /** Gets or sets the texture format to use */
  48939. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48940. /**
  48941. * Update the texture with new data
  48942. * @param data defines the data to store in the texture
  48943. */
  48944. update(data: ArrayBufferView): void;
  48945. }
  48946. }
  48947. declare module "babylonjs/Materials/Textures/refractionTexture" {
  48948. import { Scene } from "babylonjs/scene";
  48949. import { Plane } from "babylonjs/Maths/math";
  48950. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48951. /**
  48952. * Creates a refraction texture used by refraction channel of the standard material.
  48953. * It is like a mirror but to see through a material.
  48954. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48955. */
  48956. export class RefractionTexture extends RenderTargetTexture {
  48957. /**
  48958. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48959. * 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.
  48960. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48961. */
  48962. refractionPlane: Plane;
  48963. /**
  48964. * Define how deep under the surface we should see.
  48965. */
  48966. depth: number;
  48967. /**
  48968. * Creates a refraction texture used by refraction channel of the standard material.
  48969. * It is like a mirror but to see through a material.
  48970. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48971. * @param name Define the texture name
  48972. * @param size Define the size of the underlying texture
  48973. * @param scene Define the scene the refraction belongs to
  48974. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48975. */
  48976. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48977. /**
  48978. * Clone the refraction texture.
  48979. * @returns the cloned texture
  48980. */
  48981. clone(): RefractionTexture;
  48982. /**
  48983. * Serialize the texture to a JSON representation you could use in Parse later on
  48984. * @returns the serialized JSON representation
  48985. */
  48986. serialize(): any;
  48987. }
  48988. }
  48989. declare module "babylonjs/Materials/Textures/index" {
  48990. export * from "babylonjs/Materials/Textures/baseTexture";
  48991. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  48992. export * from "babylonjs/Materials/Textures/cubeTexture";
  48993. export * from "babylonjs/Materials/Textures/dynamicTexture";
  48994. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  48995. export * from "babylonjs/Materials/Textures/internalTexture";
  48996. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  48997. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  48998. export * from "babylonjs/Materials/Textures/Loaders/index";
  48999. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49000. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49001. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49002. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49003. export * from "babylonjs/Materials/Textures/rawTexture";
  49004. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49005. export * from "babylonjs/Materials/Textures/refractionTexture";
  49006. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49007. export * from "babylonjs/Materials/Textures/texture";
  49008. export * from "babylonjs/Materials/Textures/videoTexture";
  49009. }
  49010. declare module "babylonjs/Materials/index" {
  49011. export * from "babylonjs/Materials/Background/index";
  49012. export * from "babylonjs/Materials/colorCurves";
  49013. export * from "babylonjs/Materials/effect";
  49014. export * from "babylonjs/Materials/fresnelParameters";
  49015. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49016. export * from "babylonjs/Materials/material";
  49017. export * from "babylonjs/Materials/materialDefines";
  49018. export * from "babylonjs/Materials/materialHelper";
  49019. export * from "babylonjs/Materials/multiMaterial";
  49020. export * from "babylonjs/Materials/PBR/index";
  49021. export * from "babylonjs/Materials/pushMaterial";
  49022. export * from "babylonjs/Materials/shaderMaterial";
  49023. export * from "babylonjs/Materials/standardMaterial";
  49024. export * from "babylonjs/Materials/Textures/index";
  49025. export * from "babylonjs/Materials/uniformBuffer";
  49026. export * from "babylonjs/Materials/materialFlags";
  49027. }
  49028. declare module "babylonjs/Maths/index" {
  49029. export * from "babylonjs/Maths/math.scalar";
  49030. export * from "babylonjs/Maths/math";
  49031. export * from "babylonjs/Maths/sphericalPolynomial";
  49032. }
  49033. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49034. import { IDisposable } from "babylonjs/scene";
  49035. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49036. /**
  49037. * Configuration for Draco compression
  49038. */
  49039. export interface IDracoCompressionConfiguration {
  49040. /**
  49041. * Configuration for the decoder.
  49042. */
  49043. decoder?: {
  49044. /**
  49045. * The url to the WebAssembly module.
  49046. */
  49047. wasmUrl?: string;
  49048. /**
  49049. * The url to the WebAssembly binary.
  49050. */
  49051. wasmBinaryUrl?: string;
  49052. /**
  49053. * The url to the fallback JavaScript module.
  49054. */
  49055. fallbackUrl?: string;
  49056. };
  49057. }
  49058. /**
  49059. * Draco compression (https://google.github.io/draco/)
  49060. *
  49061. * This class wraps the Draco module.
  49062. *
  49063. * **Encoder**
  49064. *
  49065. * The encoder is not currently implemented.
  49066. *
  49067. * **Decoder**
  49068. *
  49069. * 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.
  49070. *
  49071. * To update the configuration, use the following code:
  49072. * ```javascript
  49073. * DracoCompression.Configuration = {
  49074. * decoder: {
  49075. * wasmUrl: "<url to the WebAssembly library>",
  49076. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49077. * fallbackUrl: "<url to the fallback JavaScript library>",
  49078. * }
  49079. * };
  49080. * ```
  49081. *
  49082. * 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.
  49083. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49084. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49085. *
  49086. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49087. * ```javascript
  49088. * var dracoCompression = new DracoCompression();
  49089. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49090. * [VertexBuffer.PositionKind]: 0
  49091. * });
  49092. * ```
  49093. *
  49094. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49095. */
  49096. export class DracoCompression implements IDisposable {
  49097. private static _DecoderModulePromise;
  49098. /**
  49099. * The configuration. Defaults to the following urls:
  49100. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49101. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49102. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49103. */
  49104. static Configuration: IDracoCompressionConfiguration;
  49105. /**
  49106. * Returns true if the decoder is available.
  49107. */
  49108. static readonly DecoderAvailable: boolean;
  49109. /**
  49110. * Constructor
  49111. */
  49112. constructor();
  49113. /**
  49114. * Stop all async operations and release resources.
  49115. */
  49116. dispose(): void;
  49117. /**
  49118. * Decode Draco compressed mesh data to vertex data.
  49119. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49120. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49121. * @returns A promise that resolves with the decoded vertex data
  49122. */
  49123. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49124. [kind: string]: number;
  49125. }): Promise<VertexData>;
  49126. private static _GetDecoderModule;
  49127. private static _LoadScriptAsync;
  49128. private static _LoadFileAsync;
  49129. }
  49130. }
  49131. declare module "babylonjs/Meshes/Compression/index" {
  49132. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49133. }
  49134. declare module "babylonjs/Meshes/csg" {
  49135. import { Nullable } from "babylonjs/types";
  49136. import { Scene } from "babylonjs/scene";
  49137. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49138. import { Mesh } from "babylonjs/Meshes/mesh";
  49139. import { Material } from "babylonjs/Materials/material";
  49140. /**
  49141. * Class for building Constructive Solid Geometry
  49142. */
  49143. export class CSG {
  49144. private polygons;
  49145. /**
  49146. * The world matrix
  49147. */
  49148. matrix: Matrix;
  49149. /**
  49150. * Stores the position
  49151. */
  49152. position: Vector3;
  49153. /**
  49154. * Stores the rotation
  49155. */
  49156. rotation: Vector3;
  49157. /**
  49158. * Stores the rotation quaternion
  49159. */
  49160. rotationQuaternion: Nullable<Quaternion>;
  49161. /**
  49162. * Stores the scaling vector
  49163. */
  49164. scaling: Vector3;
  49165. /**
  49166. * Convert the Mesh to CSG
  49167. * @param mesh The Mesh to convert to CSG
  49168. * @returns A new CSG from the Mesh
  49169. */
  49170. static FromMesh(mesh: Mesh): CSG;
  49171. /**
  49172. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49173. * @param polygons Polygons used to construct a CSG solid
  49174. */
  49175. private static FromPolygons;
  49176. /**
  49177. * Clones, or makes a deep copy, of the CSG
  49178. * @returns A new CSG
  49179. */
  49180. clone(): CSG;
  49181. /**
  49182. * Unions this CSG with another CSG
  49183. * @param csg The CSG to union against this CSG
  49184. * @returns The unioned CSG
  49185. */
  49186. union(csg: CSG): CSG;
  49187. /**
  49188. * Unions this CSG with another CSG in place
  49189. * @param csg The CSG to union against this CSG
  49190. */
  49191. unionInPlace(csg: CSG): void;
  49192. /**
  49193. * Subtracts this CSG with another CSG
  49194. * @param csg The CSG to subtract against this CSG
  49195. * @returns A new CSG
  49196. */
  49197. subtract(csg: CSG): CSG;
  49198. /**
  49199. * Subtracts this CSG with another CSG in place
  49200. * @param csg The CSG to subtact against this CSG
  49201. */
  49202. subtractInPlace(csg: CSG): void;
  49203. /**
  49204. * Intersect this CSG with another CSG
  49205. * @param csg The CSG to intersect against this CSG
  49206. * @returns A new CSG
  49207. */
  49208. intersect(csg: CSG): CSG;
  49209. /**
  49210. * Intersects this CSG with another CSG in place
  49211. * @param csg The CSG to intersect against this CSG
  49212. */
  49213. intersectInPlace(csg: CSG): void;
  49214. /**
  49215. * Return a new CSG solid with solid and empty space switched. This solid is
  49216. * not modified.
  49217. * @returns A new CSG solid with solid and empty space switched
  49218. */
  49219. inverse(): CSG;
  49220. /**
  49221. * Inverses the CSG in place
  49222. */
  49223. inverseInPlace(): void;
  49224. /**
  49225. * This is used to keep meshes transformations so they can be restored
  49226. * when we build back a Babylon Mesh
  49227. * NB : All CSG operations are performed in world coordinates
  49228. * @param csg The CSG to copy the transform attributes from
  49229. * @returns This CSG
  49230. */
  49231. copyTransformAttributes(csg: CSG): CSG;
  49232. /**
  49233. * Build Raw mesh from CSG
  49234. * Coordinates here are in world space
  49235. * @param name The name of the mesh geometry
  49236. * @param scene The Scene
  49237. * @param keepSubMeshes Specifies if the submeshes should be kept
  49238. * @returns A new Mesh
  49239. */
  49240. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49241. /**
  49242. * Build Mesh from CSG taking material and transforms into account
  49243. * @param name The name of the Mesh
  49244. * @param material The material of the Mesh
  49245. * @param scene The Scene
  49246. * @param keepSubMeshes Specifies if submeshes should be kept
  49247. * @returns The new Mesh
  49248. */
  49249. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49250. }
  49251. }
  49252. declare module "babylonjs/Meshes/meshSimplification" {
  49253. import { Mesh } from "babylonjs/Meshes/mesh";
  49254. /**
  49255. * A simplifier interface for future simplification implementations
  49256. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49257. */
  49258. export interface ISimplifier {
  49259. /**
  49260. * Simplification of a given mesh according to the given settings.
  49261. * Since this requires computation, it is assumed that the function runs async.
  49262. * @param settings The settings of the simplification, including quality and distance
  49263. * @param successCallback A callback that will be called after the mesh was simplified.
  49264. * @param errorCallback in case of an error, this callback will be called. optional.
  49265. */
  49266. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49267. }
  49268. /**
  49269. * Expected simplification settings.
  49270. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49271. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49272. */
  49273. export interface ISimplificationSettings {
  49274. /**
  49275. * Gets or sets the expected quality
  49276. */
  49277. quality: number;
  49278. /**
  49279. * Gets or sets the distance when this optimized version should be used
  49280. */
  49281. distance: number;
  49282. /**
  49283. * Gets an already optimized mesh
  49284. */
  49285. optimizeMesh?: boolean;
  49286. }
  49287. /**
  49288. * Class used to specify simplification options
  49289. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49290. */
  49291. export class SimplificationSettings implements ISimplificationSettings {
  49292. /** expected quality */
  49293. quality: number;
  49294. /** distance when this optimized version should be used */
  49295. distance: number;
  49296. /** already optimized mesh */
  49297. optimizeMesh?: boolean | undefined;
  49298. /**
  49299. * Creates a SimplificationSettings
  49300. * @param quality expected quality
  49301. * @param distance distance when this optimized version should be used
  49302. * @param optimizeMesh already optimized mesh
  49303. */
  49304. constructor(
  49305. /** expected quality */
  49306. quality: number,
  49307. /** distance when this optimized version should be used */
  49308. distance: number,
  49309. /** already optimized mesh */
  49310. optimizeMesh?: boolean | undefined);
  49311. }
  49312. /**
  49313. * Interface used to define a simplification task
  49314. */
  49315. export interface ISimplificationTask {
  49316. /**
  49317. * Array of settings
  49318. */
  49319. settings: Array<ISimplificationSettings>;
  49320. /**
  49321. * Simplification type
  49322. */
  49323. simplificationType: SimplificationType;
  49324. /**
  49325. * Mesh to simplify
  49326. */
  49327. mesh: Mesh;
  49328. /**
  49329. * Callback called on success
  49330. */
  49331. successCallback?: () => void;
  49332. /**
  49333. * Defines if parallel processing can be used
  49334. */
  49335. parallelProcessing: boolean;
  49336. }
  49337. /**
  49338. * Queue used to order the simplification tasks
  49339. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49340. */
  49341. export class SimplificationQueue {
  49342. private _simplificationArray;
  49343. /**
  49344. * Gets a boolean indicating that the process is still running
  49345. */
  49346. running: boolean;
  49347. /**
  49348. * Creates a new queue
  49349. */
  49350. constructor();
  49351. /**
  49352. * Adds a new simplification task
  49353. * @param task defines a task to add
  49354. */
  49355. addTask(task: ISimplificationTask): void;
  49356. /**
  49357. * Execute next task
  49358. */
  49359. executeNext(): void;
  49360. /**
  49361. * Execute a simplification task
  49362. * @param task defines the task to run
  49363. */
  49364. runSimplification(task: ISimplificationTask): void;
  49365. private getSimplifier;
  49366. }
  49367. /**
  49368. * The implemented types of simplification
  49369. * At the moment only Quadratic Error Decimation is implemented
  49370. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49371. */
  49372. export enum SimplificationType {
  49373. /** Quadratic error decimation */
  49374. QUADRATIC = 0
  49375. }
  49376. }
  49377. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  49378. import { Scene } from "babylonjs/scene";
  49379. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  49380. import { ISceneComponent } from "babylonjs/sceneComponent";
  49381. module "babylonjs/scene" {
  49382. interface Scene {
  49383. /** @hidden (Backing field) */
  49384. _simplificationQueue: SimplificationQueue;
  49385. /**
  49386. * Gets or sets the simplification queue attached to the scene
  49387. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49388. */
  49389. simplificationQueue: SimplificationQueue;
  49390. }
  49391. }
  49392. module "babylonjs/Meshes/mesh" {
  49393. interface Mesh {
  49394. /**
  49395. * Simplify the mesh according to the given array of settings.
  49396. * Function will return immediately and will simplify async
  49397. * @param settings a collection of simplification settings
  49398. * @param parallelProcessing should all levels calculate parallel or one after the other
  49399. * @param simplificationType the type of simplification to run
  49400. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  49401. * @returns the current mesh
  49402. */
  49403. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  49404. }
  49405. }
  49406. /**
  49407. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  49408. * created in a scene
  49409. */
  49410. export class SimplicationQueueSceneComponent implements ISceneComponent {
  49411. /**
  49412. * The component name helpfull to identify the component in the list of scene components.
  49413. */
  49414. readonly name: string;
  49415. /**
  49416. * The scene the component belongs to.
  49417. */
  49418. scene: Scene;
  49419. /**
  49420. * Creates a new instance of the component for the given scene
  49421. * @param scene Defines the scene to register the component in
  49422. */
  49423. constructor(scene: Scene);
  49424. /**
  49425. * Registers the component in a given scene
  49426. */
  49427. register(): void;
  49428. /**
  49429. * Rebuilds the elements related to this component in case of
  49430. * context lost for instance.
  49431. */
  49432. rebuild(): void;
  49433. /**
  49434. * Disposes the component and the associated ressources
  49435. */
  49436. dispose(): void;
  49437. private _beforeCameraUpdate;
  49438. }
  49439. }
  49440. declare module "babylonjs/Meshes/index" {
  49441. export * from "babylonjs/Meshes/abstractMesh";
  49442. export * from "babylonjs/Meshes/buffer";
  49443. export * from "babylonjs/Meshes/Compression/index";
  49444. export * from "babylonjs/Meshes/csg";
  49445. export * from "babylonjs/Meshes/geometry";
  49446. export * from "babylonjs/Meshes/groundMesh";
  49447. export * from "babylonjs/Meshes/instancedMesh";
  49448. export * from "babylonjs/Meshes/linesMesh";
  49449. export * from "babylonjs/Meshes/mesh";
  49450. export * from "babylonjs/Meshes/mesh.vertexData";
  49451. export * from "babylonjs/Meshes/meshBuilder";
  49452. export * from "babylonjs/Meshes/meshSimplification";
  49453. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  49454. export * from "babylonjs/Meshes/polygonMesh";
  49455. export * from "babylonjs/Meshes/subMesh";
  49456. export * from "babylonjs/Meshes/transformNode";
  49457. }
  49458. declare module "babylonjs/Morph/index" {
  49459. export * from "babylonjs/Morph/morphTarget";
  49460. export * from "babylonjs/Morph/morphTargetManager";
  49461. }
  49462. declare module "babylonjs/Offline/database" {
  49463. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  49464. /**
  49465. * Class used to enable access to IndexedDB
  49466. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  49467. */
  49468. export class Database implements IOfflineProvider {
  49469. private _callbackManifestChecked;
  49470. private _currentSceneUrl;
  49471. private _db;
  49472. private _enableSceneOffline;
  49473. private _enableTexturesOffline;
  49474. private _manifestVersionFound;
  49475. private _mustUpdateRessources;
  49476. private _hasReachedQuota;
  49477. private _isSupported;
  49478. private _idbFactory;
  49479. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  49480. private static IsUASupportingBlobStorage;
  49481. /**
  49482. * Gets a boolean indicating if Database storate is enabled (off by default)
  49483. */
  49484. static IDBStorageEnabled: boolean;
  49485. /**
  49486. * Gets a boolean indicating if scene must be saved in the database
  49487. */
  49488. readonly enableSceneOffline: boolean;
  49489. /**
  49490. * Gets a boolean indicating if textures must be saved in the database
  49491. */
  49492. readonly enableTexturesOffline: boolean;
  49493. /**
  49494. * Creates a new Database
  49495. * @param urlToScene defines the url to load the scene
  49496. * @param callbackManifestChecked defines the callback to use when manifest is checked
  49497. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  49498. */
  49499. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  49500. private static _ParseURL;
  49501. private static _ReturnFullUrlLocation;
  49502. private _checkManifestFile;
  49503. /**
  49504. * Open the database and make it available
  49505. * @param successCallback defines the callback to call on success
  49506. * @param errorCallback defines the callback to call on error
  49507. */
  49508. open(successCallback: () => void, errorCallback: () => void): void;
  49509. /**
  49510. * Loads an image from the database
  49511. * @param url defines the url to load from
  49512. * @param image defines the target DOM image
  49513. */
  49514. loadImage(url: string, image: HTMLImageElement): void;
  49515. private _loadImageFromDBAsync;
  49516. private _saveImageIntoDBAsync;
  49517. private _checkVersionFromDB;
  49518. private _loadVersionFromDBAsync;
  49519. private _saveVersionIntoDBAsync;
  49520. /**
  49521. * Loads a file from database
  49522. * @param url defines the URL to load from
  49523. * @param sceneLoaded defines a callback to call on success
  49524. * @param progressCallBack defines a callback to call when progress changed
  49525. * @param errorCallback defines a callback to call on error
  49526. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  49527. */
  49528. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  49529. private _loadFileAsync;
  49530. private _saveFileAsync;
  49531. /**
  49532. * Validates if xhr data is correct
  49533. * @param xhr defines the request to validate
  49534. * @param dataType defines the expected data type
  49535. * @returns true if data is correct
  49536. */
  49537. private static _ValidateXHRData;
  49538. }
  49539. }
  49540. declare module "babylonjs/Offline/index" {
  49541. export * from "babylonjs/Offline/database";
  49542. export * from "babylonjs/Offline/IOfflineProvider";
  49543. }
  49544. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  49545. /** @hidden */
  49546. export var gpuUpdateParticlesPixelShader: {
  49547. name: string;
  49548. shader: string;
  49549. };
  49550. }
  49551. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  49552. /** @hidden */
  49553. export var gpuUpdateParticlesVertexShader: {
  49554. name: string;
  49555. shader: string;
  49556. };
  49557. }
  49558. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  49559. /** @hidden */
  49560. export var clipPlaneFragmentDeclaration2: {
  49561. name: string;
  49562. shader: string;
  49563. };
  49564. }
  49565. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  49566. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  49567. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49568. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49569. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49570. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49571. /** @hidden */
  49572. export var gpuRenderParticlesPixelShader: {
  49573. name: string;
  49574. shader: string;
  49575. };
  49576. }
  49577. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  49578. /** @hidden */
  49579. export var clipPlaneVertexDeclaration2: {
  49580. name: string;
  49581. shader: string;
  49582. };
  49583. }
  49584. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  49585. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  49586. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49587. /** @hidden */
  49588. export var gpuRenderParticlesVertexShader: {
  49589. name: string;
  49590. shader: string;
  49591. };
  49592. }
  49593. declare module "babylonjs/Particles/gpuParticleSystem" {
  49594. import { Nullable } from "babylonjs/types";
  49595. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  49596. import { Observable } from "babylonjs/Misc/observable";
  49597. import { Color4, Color3 } from "babylonjs/Maths/math";
  49598. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49599. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  49600. import { Scene, IDisposable } from "babylonjs/scene";
  49601. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  49602. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  49603. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  49604. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  49605. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  49606. /**
  49607. * This represents a GPU particle system in Babylon
  49608. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  49609. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  49610. */
  49611. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  49612. /**
  49613. * The layer mask we are rendering the particles through.
  49614. */
  49615. layerMask: number;
  49616. private _capacity;
  49617. private _activeCount;
  49618. private _currentActiveCount;
  49619. private _accumulatedCount;
  49620. private _renderEffect;
  49621. private _updateEffect;
  49622. private _buffer0;
  49623. private _buffer1;
  49624. private _spriteBuffer;
  49625. private _updateVAO;
  49626. private _renderVAO;
  49627. private _targetIndex;
  49628. private _sourceBuffer;
  49629. private _targetBuffer;
  49630. private _engine;
  49631. private _currentRenderId;
  49632. private _started;
  49633. private _stopped;
  49634. private _timeDelta;
  49635. private _randomTexture;
  49636. private _randomTexture2;
  49637. private _attributesStrideSize;
  49638. private _updateEffectOptions;
  49639. private _randomTextureSize;
  49640. private _actualFrame;
  49641. private readonly _rawTextureWidth;
  49642. /**
  49643. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  49644. */
  49645. static readonly IsSupported: boolean;
  49646. /**
  49647. * An event triggered when the system is disposed.
  49648. */
  49649. onDisposeObservable: Observable<GPUParticleSystem>;
  49650. /**
  49651. * Gets the maximum number of particles active at the same time.
  49652. * @returns The max number of active particles.
  49653. */
  49654. getCapacity(): number;
  49655. /**
  49656. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  49657. * to override the particles.
  49658. */
  49659. forceDepthWrite: boolean;
  49660. /**
  49661. * Gets or set the number of active particles
  49662. */
  49663. activeParticleCount: number;
  49664. private _preWarmDone;
  49665. /**
  49666. * Is this system ready to be used/rendered
  49667. * @return true if the system is ready
  49668. */
  49669. isReady(): boolean;
  49670. /**
  49671. * Gets if the system has been started. (Note: this will still be true after stop is called)
  49672. * @returns True if it has been started, otherwise false.
  49673. */
  49674. isStarted(): boolean;
  49675. /**
  49676. * Starts the particle system and begins to emit
  49677. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  49678. */
  49679. start(delay?: number): void;
  49680. /**
  49681. * Stops the particle system.
  49682. */
  49683. stop(): void;
  49684. /**
  49685. * Remove all active particles
  49686. */
  49687. reset(): void;
  49688. /**
  49689. * Returns the string "GPUParticleSystem"
  49690. * @returns a string containing the class name
  49691. */
  49692. getClassName(): string;
  49693. private _colorGradientsTexture;
  49694. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  49695. /**
  49696. * Adds a new color gradient
  49697. * @param gradient defines the gradient to use (between 0 and 1)
  49698. * @param color1 defines the color to affect to the specified gradient
  49699. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  49700. * @returns the current particle system
  49701. */
  49702. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  49703. /**
  49704. * Remove a specific color gradient
  49705. * @param gradient defines the gradient to remove
  49706. * @returns the current particle system
  49707. */
  49708. removeColorGradient(gradient: number): GPUParticleSystem;
  49709. private _angularSpeedGradientsTexture;
  49710. private _sizeGradientsTexture;
  49711. private _velocityGradientsTexture;
  49712. private _limitVelocityGradientsTexture;
  49713. private _dragGradientsTexture;
  49714. private _addFactorGradient;
  49715. /**
  49716. * Adds a new size gradient
  49717. * @param gradient defines the gradient to use (between 0 and 1)
  49718. * @param factor defines the size factor to affect to the specified gradient
  49719. * @returns the current particle system
  49720. */
  49721. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  49722. /**
  49723. * Remove a specific size gradient
  49724. * @param gradient defines the gradient to remove
  49725. * @returns the current particle system
  49726. */
  49727. removeSizeGradient(gradient: number): GPUParticleSystem;
  49728. /**
  49729. * Adds a new angular speed gradient
  49730. * @param gradient defines the gradient to use (between 0 and 1)
  49731. * @param factor defines the angular speed to affect to the specified gradient
  49732. * @returns the current particle system
  49733. */
  49734. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  49735. /**
  49736. * Remove a specific angular speed gradient
  49737. * @param gradient defines the gradient to remove
  49738. * @returns the current particle system
  49739. */
  49740. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  49741. /**
  49742. * Adds a new velocity gradient
  49743. * @param gradient defines the gradient to use (between 0 and 1)
  49744. * @param factor defines the velocity to affect to the specified gradient
  49745. * @returns the current particle system
  49746. */
  49747. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  49748. /**
  49749. * Remove a specific velocity gradient
  49750. * @param gradient defines the gradient to remove
  49751. * @returns the current particle system
  49752. */
  49753. removeVelocityGradient(gradient: number): GPUParticleSystem;
  49754. /**
  49755. * Adds a new limit velocity gradient
  49756. * @param gradient defines the gradient to use (between 0 and 1)
  49757. * @param factor defines the limit velocity value to affect to the specified gradient
  49758. * @returns the current particle system
  49759. */
  49760. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  49761. /**
  49762. * Remove a specific limit velocity gradient
  49763. * @param gradient defines the gradient to remove
  49764. * @returns the current particle system
  49765. */
  49766. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  49767. /**
  49768. * Adds a new drag gradient
  49769. * @param gradient defines the gradient to use (between 0 and 1)
  49770. * @param factor defines the drag value to affect to the specified gradient
  49771. * @returns the current particle system
  49772. */
  49773. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  49774. /**
  49775. * Remove a specific drag gradient
  49776. * @param gradient defines the gradient to remove
  49777. * @returns the current particle system
  49778. */
  49779. removeDragGradient(gradient: number): GPUParticleSystem;
  49780. /**
  49781. * Not supported by GPUParticleSystem
  49782. * @param gradient defines the gradient to use (between 0 and 1)
  49783. * @param factor defines the emit rate value to affect to the specified gradient
  49784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49785. * @returns the current particle system
  49786. */
  49787. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49788. /**
  49789. * Not supported by GPUParticleSystem
  49790. * @param gradient defines the gradient to remove
  49791. * @returns the current particle system
  49792. */
  49793. removeEmitRateGradient(gradient: number): IParticleSystem;
  49794. /**
  49795. * Not supported by GPUParticleSystem
  49796. * @param gradient defines the gradient to use (between 0 and 1)
  49797. * @param factor defines the start size value to affect to the specified gradient
  49798. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49799. * @returns the current particle system
  49800. */
  49801. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49802. /**
  49803. * Not supported by GPUParticleSystem
  49804. * @param gradient defines the gradient to remove
  49805. * @returns the current particle system
  49806. */
  49807. removeStartSizeGradient(gradient: number): IParticleSystem;
  49808. /**
  49809. * Not supported by GPUParticleSystem
  49810. * @param gradient defines the gradient to use (between 0 and 1)
  49811. * @param min defines the color remap minimal range
  49812. * @param max defines the color remap maximal range
  49813. * @returns the current particle system
  49814. */
  49815. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  49816. /**
  49817. * Not supported by GPUParticleSystem
  49818. * @param gradient defines the gradient to remove
  49819. * @returns the current particle system
  49820. */
  49821. removeColorRemapGradient(): IParticleSystem;
  49822. /**
  49823. * Not supported by GPUParticleSystem
  49824. * @param gradient defines the gradient to use (between 0 and 1)
  49825. * @param min defines the alpha remap minimal range
  49826. * @param max defines the alpha remap maximal range
  49827. * @returns the current particle system
  49828. */
  49829. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  49830. /**
  49831. * Not supported by GPUParticleSystem
  49832. * @param gradient defines the gradient to remove
  49833. * @returns the current particle system
  49834. */
  49835. removeAlphaRemapGradient(): IParticleSystem;
  49836. /**
  49837. * Not supported by GPUParticleSystem
  49838. * @param gradient defines the gradient to use (between 0 and 1)
  49839. * @param color defines the color to affect to the specified gradient
  49840. * @returns the current particle system
  49841. */
  49842. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  49843. /**
  49844. * Not supported by GPUParticleSystem
  49845. * @param gradient defines the gradient to remove
  49846. * @returns the current particle system
  49847. */
  49848. removeRampGradient(): IParticleSystem;
  49849. /**
  49850. * Not supported by GPUParticleSystem
  49851. * @returns the list of ramp gradients
  49852. */
  49853. getRampGradients(): Nullable<Array<Color3Gradient>>;
  49854. /**
  49855. * Not supported by GPUParticleSystem
  49856. * Gets or sets a boolean indicating that ramp gradients must be used
  49857. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  49858. */
  49859. useRampGradients: boolean;
  49860. /**
  49861. * Not supported by GPUParticleSystem
  49862. * @param gradient defines the gradient to use (between 0 and 1)
  49863. * @param factor defines the life time factor to affect to the specified gradient
  49864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49865. * @returns the current particle system
  49866. */
  49867. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49868. /**
  49869. * Not supported by GPUParticleSystem
  49870. * @param gradient defines the gradient to remove
  49871. * @returns the current particle system
  49872. */
  49873. removeLifeTimeGradient(gradient: number): IParticleSystem;
  49874. /**
  49875. * Instantiates a GPU particle system.
  49876. * 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.
  49877. * @param name The name of the particle system
  49878. * @param options The options used to create the system
  49879. * @param scene The scene the particle system belongs to
  49880. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  49881. */
  49882. constructor(name: string, options: Partial<{
  49883. capacity: number;
  49884. randomTextureSize: number;
  49885. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  49886. protected _reset(): void;
  49887. private _createUpdateVAO;
  49888. private _createRenderVAO;
  49889. private _initialize;
  49890. /** @hidden */
  49891. _recreateUpdateEffect(): void;
  49892. /** @hidden */
  49893. _recreateRenderEffect(): void;
  49894. /**
  49895. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  49896. * @param preWarm defines if we are in the pre-warmimg phase
  49897. */
  49898. animate(preWarm?: boolean): void;
  49899. private _createFactorGradientTexture;
  49900. private _createSizeGradientTexture;
  49901. private _createAngularSpeedGradientTexture;
  49902. private _createVelocityGradientTexture;
  49903. private _createLimitVelocityGradientTexture;
  49904. private _createDragGradientTexture;
  49905. private _createColorGradientTexture;
  49906. /**
  49907. * Renders the particle system in its current state
  49908. * @param preWarm defines if the system should only update the particles but not render them
  49909. * @returns the current number of particles
  49910. */
  49911. render(preWarm?: boolean): number;
  49912. /**
  49913. * Rebuilds the particle system
  49914. */
  49915. rebuild(): void;
  49916. private _releaseBuffers;
  49917. private _releaseVAOs;
  49918. /**
  49919. * Disposes the particle system and free the associated resources
  49920. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  49921. */
  49922. dispose(disposeTexture?: boolean): void;
  49923. /**
  49924. * Clones the particle system.
  49925. * @param name The name of the cloned object
  49926. * @param newEmitter The new emitter to use
  49927. * @returns the cloned particle system
  49928. */
  49929. clone(name: string, newEmitter: any): GPUParticleSystem;
  49930. /**
  49931. * Serializes the particle system to a JSON object.
  49932. * @returns the JSON object
  49933. */
  49934. serialize(): any;
  49935. /**
  49936. * Parses a JSON object to create a GPU particle system.
  49937. * @param parsedParticleSystem The JSON object to parse
  49938. * @param scene The scene to create the particle system in
  49939. * @param rootUrl The root url to use to load external dependencies like texture
  49940. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  49941. * @returns the parsed GPU particle system
  49942. */
  49943. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  49944. }
  49945. }
  49946. declare module "babylonjs/Particles/particleSystemSet" {
  49947. import { Nullable } from "babylonjs/types";
  49948. import { Color3 } from "babylonjs/Maths/math";
  49949. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49951. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49952. import { Scene, IDisposable } from "babylonjs/scene";
  49953. /**
  49954. * Represents a set of particle systems working together to create a specific effect
  49955. */
  49956. export class ParticleSystemSet implements IDisposable {
  49957. private _emitterCreationOptions;
  49958. private _emitterNode;
  49959. /**
  49960. * Gets the particle system list
  49961. */
  49962. systems: IParticleSystem[];
  49963. /**
  49964. * Gets the emitter node used with this set
  49965. */
  49966. readonly emitterNode: Nullable<TransformNode>;
  49967. /**
  49968. * Creates a new emitter mesh as a sphere
  49969. * @param options defines the options used to create the sphere
  49970. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  49971. * @param scene defines the hosting scene
  49972. */
  49973. setEmitterAsSphere(options: {
  49974. diameter: number;
  49975. segments: number;
  49976. color: Color3;
  49977. }, renderingGroupId: number, scene: Scene): void;
  49978. /**
  49979. * Starts all particle systems of the set
  49980. * @param emitter defines an optional mesh to use as emitter for the particle systems
  49981. */
  49982. start(emitter?: AbstractMesh): void;
  49983. /**
  49984. * Release all associated resources
  49985. */
  49986. dispose(): void;
  49987. /**
  49988. * Serialize the set into a JSON compatible object
  49989. * @returns a JSON compatible representation of the set
  49990. */
  49991. serialize(): any;
  49992. /**
  49993. * Parse a new ParticleSystemSet from a serialized source
  49994. * @param data defines a JSON compatible representation of the set
  49995. * @param scene defines the hosting scene
  49996. * @param gpu defines if we want GPU particles or CPU particles
  49997. * @returns a new ParticleSystemSet
  49998. */
  49999. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50000. }
  50001. }
  50002. declare module "babylonjs/Particles/particleHelper" {
  50003. import { Nullable } from "babylonjs/types";
  50004. import { Scene } from "babylonjs/scene";
  50005. import { Vector3 } from "babylonjs/Maths/math";
  50006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50007. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50008. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  50009. /**
  50010. * This class is made for on one-liner static method to help creating particle system set.
  50011. */
  50012. export class ParticleHelper {
  50013. /**
  50014. * Gets or sets base Assets URL
  50015. */
  50016. static BaseAssetsUrl: string;
  50017. /**
  50018. * Create a default particle system that you can tweak
  50019. * @param emitter defines the emitter to use
  50020. * @param capacity defines the system capacity (default is 500 particles)
  50021. * @param scene defines the hosting scene
  50022. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50023. * @returns the new Particle system
  50024. */
  50025. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50026. /**
  50027. * This is the main static method (one-liner) of this helper to create different particle systems
  50028. * @param type This string represents the type to the particle system to create
  50029. * @param scene The scene where the particle system should live
  50030. * @param gpu If the system will use gpu
  50031. * @returns the ParticleSystemSet created
  50032. */
  50033. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50034. /**
  50035. * Static function used to export a particle system to a ParticleSystemSet variable.
  50036. * Please note that the emitter shape is not exported
  50037. * @param systems defines the particle systems to export
  50038. * @returns the created particle system set
  50039. */
  50040. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50041. }
  50042. }
  50043. declare module "babylonjs/Particles/particleSystemComponent" {
  50044. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50045. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  50046. import "babylonjs/Shaders/particles.vertex";
  50047. module "babylonjs/Engines/engine" {
  50048. interface Engine {
  50049. /**
  50050. * Create an effect to use with particle systems.
  50051. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50052. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50053. * @param uniformsNames defines a list of attribute names
  50054. * @param samplers defines an array of string used to represent textures
  50055. * @param defines defines the string containing the defines to use to compile the shaders
  50056. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50057. * @param onCompiled defines a function to call when the effect creation is successful
  50058. * @param onError defines a function to call when the effect creation has failed
  50059. * @returns the new Effect
  50060. */
  50061. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50062. }
  50063. }
  50064. module "babylonjs/Meshes/mesh" {
  50065. interface Mesh {
  50066. /**
  50067. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50068. * @returns an array of IParticleSystem
  50069. */
  50070. getEmittedParticleSystems(): IParticleSystem[];
  50071. /**
  50072. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50073. * @returns an array of IParticleSystem
  50074. */
  50075. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50076. }
  50077. }
  50078. /**
  50079. * @hidden
  50080. */
  50081. export var _IDoNeedToBeInTheBuild: number;
  50082. }
  50083. declare module "babylonjs/Particles/index" {
  50084. export * from "babylonjs/Particles/baseParticleSystem";
  50085. export * from "babylonjs/Particles/EmitterTypes/index";
  50086. export * from "babylonjs/Particles/gpuParticleSystem";
  50087. export * from "babylonjs/Particles/IParticleSystem";
  50088. export * from "babylonjs/Particles/particle";
  50089. export * from "babylonjs/Particles/particleHelper";
  50090. export * from "babylonjs/Particles/particleSystem";
  50091. export * from "babylonjs/Particles/particleSystemComponent";
  50092. export * from "babylonjs/Particles/particleSystemSet";
  50093. export * from "babylonjs/Particles/solidParticle";
  50094. export * from "babylonjs/Particles/solidParticleSystem";
  50095. export * from "babylonjs/Particles/subEmitter";
  50096. }
  50097. declare module "babylonjs/Physics/physicsEngineComponent" {
  50098. import { Nullable } from "babylonjs/types";
  50099. import { Observable, Observer } from "babylonjs/Misc/observable";
  50100. import { Vector3 } from "babylonjs/Maths/math";
  50101. import { Mesh } from "babylonjs/Meshes/mesh";
  50102. import { ISceneComponent } from "babylonjs/sceneComponent";
  50103. import { Scene } from "babylonjs/scene";
  50104. import { Node } from "babylonjs/node";
  50105. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50106. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50107. module "babylonjs/scene" {
  50108. interface Scene {
  50109. /** @hidden (Backing field) */
  50110. _physicsEngine: Nullable<IPhysicsEngine>;
  50111. /**
  50112. * Gets the current physics engine
  50113. * @returns a IPhysicsEngine or null if none attached
  50114. */
  50115. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50116. /**
  50117. * Enables physics to the current scene
  50118. * @param gravity defines the scene's gravity for the physics engine
  50119. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50120. * @return a boolean indicating if the physics engine was initialized
  50121. */
  50122. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50123. /**
  50124. * Disables and disposes the physics engine associated with the scene
  50125. */
  50126. disablePhysicsEngine(): void;
  50127. /**
  50128. * Gets a boolean indicating if there is an active physics engine
  50129. * @returns a boolean indicating if there is an active physics engine
  50130. */
  50131. isPhysicsEnabled(): boolean;
  50132. /**
  50133. * Deletes a physics compound impostor
  50134. * @param compound defines the compound to delete
  50135. */
  50136. deleteCompoundImpostor(compound: any): void;
  50137. /**
  50138. * An event triggered when physic simulation is about to be run
  50139. */
  50140. onBeforePhysicsObservable: Observable<Scene>;
  50141. /**
  50142. * An event triggered when physic simulation has been done
  50143. */
  50144. onAfterPhysicsObservable: Observable<Scene>;
  50145. }
  50146. }
  50147. module "babylonjs/Meshes/abstractMesh" {
  50148. interface AbstractMesh {
  50149. /** @hidden */
  50150. _physicsImpostor: Nullable<PhysicsImpostor>;
  50151. /**
  50152. * Gets or sets impostor used for physic simulation
  50153. * @see http://doc.babylonjs.com/features/physics_engine
  50154. */
  50155. physicsImpostor: Nullable<PhysicsImpostor>;
  50156. /**
  50157. * Gets the current physics impostor
  50158. * @see http://doc.babylonjs.com/features/physics_engine
  50159. * @returns a physics impostor or null
  50160. */
  50161. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50162. /** Apply a physic impulse to the mesh
  50163. * @param force defines the force to apply
  50164. * @param contactPoint defines where to apply the force
  50165. * @returns the current mesh
  50166. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50167. */
  50168. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50169. /**
  50170. * Creates a physic joint between two meshes
  50171. * @param otherMesh defines the other mesh to use
  50172. * @param pivot1 defines the pivot to use on this mesh
  50173. * @param pivot2 defines the pivot to use on the other mesh
  50174. * @param options defines additional options (can be plugin dependent)
  50175. * @returns the current mesh
  50176. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50177. */
  50178. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50179. /** @hidden */
  50180. _disposePhysicsObserver: Nullable<Observer<Node>>;
  50181. }
  50182. }
  50183. /**
  50184. * Defines the physics engine scene component responsible to manage a physics engine
  50185. */
  50186. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50187. /**
  50188. * The component name helpful to identify the component in the list of scene components.
  50189. */
  50190. readonly name: string;
  50191. /**
  50192. * The scene the component belongs to.
  50193. */
  50194. scene: Scene;
  50195. /**
  50196. * Creates a new instance of the component for the given scene
  50197. * @param scene Defines the scene to register the component in
  50198. */
  50199. constructor(scene: Scene);
  50200. /**
  50201. * Registers the component in a given scene
  50202. */
  50203. register(): void;
  50204. /**
  50205. * Rebuilds the elements related to this component in case of
  50206. * context lost for instance.
  50207. */
  50208. rebuild(): void;
  50209. /**
  50210. * Disposes the component and the associated ressources
  50211. */
  50212. dispose(): void;
  50213. }
  50214. }
  50215. declare module "babylonjs/Physics/physicsHelper" {
  50216. import { Nullable } from "babylonjs/types";
  50217. import { Vector3 } from "babylonjs/Maths/math";
  50218. import { Mesh } from "babylonjs/Meshes/mesh";
  50219. import { Ray } from "babylonjs/Culling/ray";
  50220. import { Scene } from "babylonjs/scene";
  50221. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50222. /**
  50223. * A helper for physics simulations
  50224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50225. */
  50226. export class PhysicsHelper {
  50227. private _scene;
  50228. private _physicsEngine;
  50229. /**
  50230. * Initializes the Physics helper
  50231. * @param scene Babylon.js scene
  50232. */
  50233. constructor(scene: Scene);
  50234. /**
  50235. * Applies a radial explosion impulse
  50236. * @param origin the origin of the explosion
  50237. * @param radius the explosion radius
  50238. * @param strength the explosion strength
  50239. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50240. * @returns A physics radial explosion event, or null
  50241. */
  50242. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50243. /**
  50244. * Applies a radial explosion force
  50245. * @param origin the origin of the explosion
  50246. * @param radius the explosion radius
  50247. * @param strength the explosion strength
  50248. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50249. * @returns A physics radial explosion event, or null
  50250. */
  50251. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50252. /**
  50253. * Creates a gravitational field
  50254. * @param origin the origin of the explosion
  50255. * @param radius the explosion radius
  50256. * @param strength the explosion strength
  50257. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50258. * @returns A physics gravitational field event, or null
  50259. */
  50260. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50261. /**
  50262. * Creates a physics updraft event
  50263. * @param origin the origin of the updraft
  50264. * @param radius the radius of the updraft
  50265. * @param strength the strength of the updraft
  50266. * @param height the height of the updraft
  50267. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50268. * @returns A physics updraft event, or null
  50269. */
  50270. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50271. /**
  50272. * Creates a physics vortex event
  50273. * @param origin the of the vortex
  50274. * @param radius the radius of the vortex
  50275. * @param strength the strength of the vortex
  50276. * @param height the height of the vortex
  50277. * @returns a Physics vortex event, or null
  50278. * A physics vortex event or null
  50279. */
  50280. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  50281. }
  50282. /**
  50283. * Represents a physics radial explosion event
  50284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50285. */
  50286. export class PhysicsRadialExplosionEvent {
  50287. private _scene;
  50288. private _sphere;
  50289. private _sphereOptions;
  50290. private _rays;
  50291. private _dataFetched;
  50292. /**
  50293. * Initializes a radial explosioin event
  50294. * @param scene BabylonJS scene
  50295. */
  50296. constructor(scene: Scene);
  50297. /**
  50298. * Returns the data related to the radial explosion event (sphere & rays).
  50299. * @returns The radial explosion event data
  50300. */
  50301. getData(): PhysicsRadialExplosionEventData;
  50302. /**
  50303. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50304. * @param impostor A physics imposter
  50305. * @param origin the origin of the explosion
  50306. * @param radius the explosion radius
  50307. * @param strength the explosion strength
  50308. * @param falloff possible options: Constant & Linear
  50309. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  50310. */
  50311. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  50312. /**
  50313. * Disposes the sphere.
  50314. * @param force Specifies if the sphere should be disposed by force
  50315. */
  50316. dispose(force?: boolean): void;
  50317. /*** Helpers ***/
  50318. private _prepareSphere;
  50319. private _intersectsWithSphere;
  50320. }
  50321. /**
  50322. * Represents a gravitational field event
  50323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50324. */
  50325. export class PhysicsGravitationalFieldEvent {
  50326. private _physicsHelper;
  50327. private _scene;
  50328. private _origin;
  50329. private _radius;
  50330. private _strength;
  50331. private _falloff;
  50332. private _tickCallback;
  50333. private _sphere;
  50334. private _dataFetched;
  50335. /**
  50336. * Initializes the physics gravitational field event
  50337. * @param physicsHelper A physics helper
  50338. * @param scene BabylonJS scene
  50339. * @param origin The origin position of the gravitational field event
  50340. * @param radius The radius of the gravitational field event
  50341. * @param strength The strength of the gravitational field event
  50342. * @param falloff The falloff for the gravitational field event
  50343. */
  50344. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  50345. /**
  50346. * Returns the data related to the gravitational field event (sphere).
  50347. * @returns A gravitational field event
  50348. */
  50349. getData(): PhysicsGravitationalFieldEventData;
  50350. /**
  50351. * Enables the gravitational field.
  50352. */
  50353. enable(): void;
  50354. /**
  50355. * Disables the gravitational field.
  50356. */
  50357. disable(): void;
  50358. /**
  50359. * Disposes the sphere.
  50360. * @param force The force to dispose from the gravitational field event
  50361. */
  50362. dispose(force?: boolean): void;
  50363. private _tick;
  50364. }
  50365. /**
  50366. * Represents a physics updraft event
  50367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50368. */
  50369. export class PhysicsUpdraftEvent {
  50370. private _scene;
  50371. private _origin;
  50372. private _radius;
  50373. private _strength;
  50374. private _height;
  50375. private _updraftMode;
  50376. private _physicsEngine;
  50377. private _originTop;
  50378. private _originDirection;
  50379. private _tickCallback;
  50380. private _cylinder;
  50381. private _cylinderPosition;
  50382. private _dataFetched;
  50383. /**
  50384. * Initializes the physics updraft event
  50385. * @param _scene BabylonJS scene
  50386. * @param _origin The origin position of the updraft
  50387. * @param _radius The radius of the updraft
  50388. * @param _strength The strength of the updraft
  50389. * @param _height The height of the updraft
  50390. * @param _updraftMode The mode of the updraft
  50391. */
  50392. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  50393. /**
  50394. * Returns the data related to the updraft event (cylinder).
  50395. * @returns A physics updraft event
  50396. */
  50397. getData(): PhysicsUpdraftEventData;
  50398. /**
  50399. * Enables the updraft.
  50400. */
  50401. enable(): void;
  50402. /**
  50403. * Disables the cortex.
  50404. */
  50405. disable(): void;
  50406. /**
  50407. * Disposes the sphere.
  50408. * @param force Specifies if the updraft should be disposed by force
  50409. */
  50410. dispose(force?: boolean): void;
  50411. private getImpostorForceAndContactPoint;
  50412. private _tick;
  50413. /*** Helpers ***/
  50414. private _prepareCylinder;
  50415. private _intersectsWithCylinder;
  50416. }
  50417. /**
  50418. * Represents a physics vortex event
  50419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50420. */
  50421. export class PhysicsVortexEvent {
  50422. private _scene;
  50423. private _origin;
  50424. private _radius;
  50425. private _strength;
  50426. private _height;
  50427. private _physicsEngine;
  50428. private _originTop;
  50429. private _centripetalForceThreshold;
  50430. private _updraftMultiplier;
  50431. private _tickCallback;
  50432. private _cylinder;
  50433. private _cylinderPosition;
  50434. private _dataFetched;
  50435. /**
  50436. * Initializes the physics vortex event
  50437. * @param _scene The BabylonJS scene
  50438. * @param _origin The origin position of the vortex
  50439. * @param _radius The radius of the vortex
  50440. * @param _strength The strength of the vortex
  50441. * @param _height The height of the vortex
  50442. */
  50443. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  50444. /**
  50445. * Returns the data related to the vortex event (cylinder).
  50446. * @returns The physics vortex event data
  50447. */
  50448. getData(): PhysicsVortexEventData;
  50449. /**
  50450. * Enables the vortex.
  50451. */
  50452. enable(): void;
  50453. /**
  50454. * Disables the cortex.
  50455. */
  50456. disable(): void;
  50457. /**
  50458. * Disposes the sphere.
  50459. * @param force
  50460. */
  50461. dispose(force?: boolean): void;
  50462. private getImpostorForceAndContactPoint;
  50463. private _tick;
  50464. /*** Helpers ***/
  50465. private _prepareCylinder;
  50466. private _intersectsWithCylinder;
  50467. }
  50468. /**
  50469. * The strenght of the force in correspondence to the distance of the affected object
  50470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50471. */
  50472. export enum PhysicsRadialImpulseFalloff {
  50473. /** Defines that impulse is constant in strength across it's whole radius */
  50474. Constant = 0,
  50475. /** DEfines that impulse gets weaker if it's further from the origin */
  50476. Linear = 1
  50477. }
  50478. /**
  50479. * The strength of the force in correspondence to the distance of the affected object
  50480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50481. */
  50482. export enum PhysicsUpdraftMode {
  50483. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  50484. Center = 0,
  50485. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  50486. Perpendicular = 1
  50487. }
  50488. /**
  50489. * Interface for a physics force and contact point
  50490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50491. */
  50492. export interface PhysicsForceAndContactPoint {
  50493. /**
  50494. * The force applied at the contact point
  50495. */
  50496. force: Vector3;
  50497. /**
  50498. * The contact point
  50499. */
  50500. contactPoint: Vector3;
  50501. }
  50502. /**
  50503. * Interface for radial explosion event data
  50504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50505. */
  50506. export interface PhysicsRadialExplosionEventData {
  50507. /**
  50508. * A sphere used for the radial explosion event
  50509. */
  50510. sphere: Mesh;
  50511. /**
  50512. * An array of rays for the radial explosion event
  50513. */
  50514. rays: Array<Ray>;
  50515. }
  50516. /**
  50517. * Interface for gravitational field event data
  50518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50519. */
  50520. export interface PhysicsGravitationalFieldEventData {
  50521. /**
  50522. * A sphere mesh used for the gravitational field event
  50523. */
  50524. sphere: Mesh;
  50525. }
  50526. /**
  50527. * Interface for updraft event data
  50528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50529. */
  50530. export interface PhysicsUpdraftEventData {
  50531. /**
  50532. * A cylinder used for the updraft event
  50533. */
  50534. cylinder: Mesh;
  50535. }
  50536. /**
  50537. * Interface for vortex event data
  50538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50539. */
  50540. export interface PhysicsVortexEventData {
  50541. /**
  50542. * A cylinder used for the vortex event
  50543. */
  50544. cylinder: Mesh;
  50545. }
  50546. }
  50547. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50548. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50549. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50550. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50551. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50552. import { Nullable } from "babylonjs/types";
  50553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50554. /**
  50555. * AmmoJS Physics plugin
  50556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50557. * @see https://github.com/kripken/ammo.js/
  50558. */
  50559. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50560. private _useDeltaForWorldStep;
  50561. /**
  50562. * Reference to the Ammo library
  50563. */
  50564. bjsAMMO: any;
  50565. /**
  50566. * Created ammoJS world which physics bodies are added to
  50567. */
  50568. world: any;
  50569. /**
  50570. * Name of the plugin
  50571. */
  50572. name: string;
  50573. private _timeStep;
  50574. private _fixedTimeStep;
  50575. private _maxSteps;
  50576. private _tmpQuaternion;
  50577. private _tmpAmmoTransform;
  50578. private _tmpAmmoQuaternion;
  50579. private _tmpAmmoConcreteContactResultCallback;
  50580. private _collisionConfiguration;
  50581. private _dispatcher;
  50582. private _overlappingPairCache;
  50583. private _solver;
  50584. private _tmpAmmoVectorA;
  50585. private _tmpAmmoVectorB;
  50586. private _tmpAmmoVectorC;
  50587. private _tmpContactCallbackResult;
  50588. private static readonly DISABLE_COLLISION_FLAG;
  50589. private static readonly KINEMATIC_FLAG;
  50590. private static readonly DISABLE_DEACTIVATION_FLAG;
  50591. /**
  50592. * Initializes the ammoJS plugin
  50593. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50594. * @param ammoInjection can be used to inject your own ammo reference
  50595. */
  50596. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50597. /**
  50598. * Sets the gravity of the physics world (m/(s^2))
  50599. * @param gravity Gravity to set
  50600. */
  50601. setGravity(gravity: Vector3): void;
  50602. /**
  50603. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50604. * @param timeStep timestep to use in seconds
  50605. */
  50606. setTimeStep(timeStep: number): void;
  50607. /**
  50608. * 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)
  50609. * @param fixedTimeStep fixedTimeStep to use in seconds
  50610. */
  50611. setFixedTimeStep(fixedTimeStep: number): void;
  50612. /**
  50613. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50614. * @param maxSteps the maximum number of steps by the physics engine per frame
  50615. */
  50616. setMaxSteps(maxSteps: number): void;
  50617. /**
  50618. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50619. * @returns the current timestep in seconds
  50620. */
  50621. getTimeStep(): number;
  50622. private _isImpostorInContact;
  50623. private _isImpostorPairInContact;
  50624. private _stepSimulation;
  50625. /**
  50626. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50627. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50628. * After the step the babylon meshes are set to the position of the physics imposters
  50629. * @param delta amount of time to step forward
  50630. * @param impostors array of imposters to update before/after the step
  50631. */
  50632. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50633. /**
  50634. * Applies an implulse on the imposter
  50635. * @param impostor imposter to apply impulse
  50636. * @param force amount of force to be applied to the imposter
  50637. * @param contactPoint the location to apply the impulse on the imposter
  50638. */
  50639. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50640. /**
  50641. * Applies a force on the imposter
  50642. * @param impostor imposter to apply force
  50643. * @param force amount of force to be applied to the imposter
  50644. * @param contactPoint the location to apply the force on the imposter
  50645. */
  50646. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50647. /**
  50648. * Creates a physics body using the plugin
  50649. * @param impostor the imposter to create the physics body on
  50650. */
  50651. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50652. /**
  50653. * Removes the physics body from the imposter and disposes of the body's memory
  50654. * @param impostor imposter to remove the physics body from
  50655. */
  50656. removePhysicsBody(impostor: PhysicsImpostor): void;
  50657. /**
  50658. * Generates a joint
  50659. * @param impostorJoint the imposter joint to create the joint with
  50660. */
  50661. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50662. /**
  50663. * Removes a joint
  50664. * @param impostorJoint the imposter joint to remove the joint from
  50665. */
  50666. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50667. private _addMeshVerts;
  50668. private _createShape;
  50669. /**
  50670. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50671. * @param impostor imposter containing the physics body and babylon object
  50672. */
  50673. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50674. /**
  50675. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50676. * @param impostor imposter containing the physics body and babylon object
  50677. * @param newPosition new position
  50678. * @param newRotation new rotation
  50679. */
  50680. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50681. /**
  50682. * If this plugin is supported
  50683. * @returns true if its supported
  50684. */
  50685. isSupported(): boolean;
  50686. /**
  50687. * Sets the linear velocity of the physics body
  50688. * @param impostor imposter to set the velocity on
  50689. * @param velocity velocity to set
  50690. */
  50691. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50692. /**
  50693. * Sets the angular velocity of the physics body
  50694. * @param impostor imposter to set the velocity on
  50695. * @param velocity velocity to set
  50696. */
  50697. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50698. /**
  50699. * gets the linear velocity
  50700. * @param impostor imposter to get linear velocity from
  50701. * @returns linear velocity
  50702. */
  50703. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50704. /**
  50705. * gets the angular velocity
  50706. * @param impostor imposter to get angular velocity from
  50707. * @returns angular velocity
  50708. */
  50709. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50710. /**
  50711. * Sets the mass of physics body
  50712. * @param impostor imposter to set the mass on
  50713. * @param mass mass to set
  50714. */
  50715. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50716. /**
  50717. * Gets the mass of the physics body
  50718. * @param impostor imposter to get the mass from
  50719. * @returns mass
  50720. */
  50721. getBodyMass(impostor: PhysicsImpostor): number;
  50722. /**
  50723. * Gets friction of the impostor
  50724. * @param impostor impostor to get friction from
  50725. * @returns friction value
  50726. */
  50727. getBodyFriction(impostor: PhysicsImpostor): number;
  50728. /**
  50729. * Sets friction of the impostor
  50730. * @param impostor impostor to set friction on
  50731. * @param friction friction value
  50732. */
  50733. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50734. /**
  50735. * Gets restitution of the impostor
  50736. * @param impostor impostor to get restitution from
  50737. * @returns restitution value
  50738. */
  50739. getBodyRestitution(impostor: PhysicsImpostor): number;
  50740. /**
  50741. * Sets resitution of the impostor
  50742. * @param impostor impostor to set resitution on
  50743. * @param restitution resitution value
  50744. */
  50745. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50746. /**
  50747. * Sleeps the physics body and stops it from being active
  50748. * @param impostor impostor to sleep
  50749. */
  50750. sleepBody(impostor: PhysicsImpostor): void;
  50751. /**
  50752. * Activates the physics body
  50753. * @param impostor impostor to activate
  50754. */
  50755. wakeUpBody(impostor: PhysicsImpostor): void;
  50756. /**
  50757. * Updates the distance parameters of the joint
  50758. * @param joint joint to update
  50759. * @param maxDistance maximum distance of the joint
  50760. * @param minDistance minimum distance of the joint
  50761. */
  50762. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50763. /**
  50764. * Sets a motor on the joint
  50765. * @param joint joint to set motor on
  50766. * @param speed speed of the motor
  50767. * @param maxForce maximum force of the motor
  50768. * @param motorIndex index of the motor
  50769. */
  50770. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50771. /**
  50772. * Sets the motors limit
  50773. * @param joint joint to set limit on
  50774. * @param upperLimit upper limit
  50775. * @param lowerLimit lower limit
  50776. */
  50777. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50778. /**
  50779. * Syncs the position and rotation of a mesh with the impostor
  50780. * @param mesh mesh to sync
  50781. * @param impostor impostor to update the mesh with
  50782. */
  50783. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50784. /**
  50785. * Gets the radius of the impostor
  50786. * @param impostor impostor to get radius from
  50787. * @returns the radius
  50788. */
  50789. getRadius(impostor: PhysicsImpostor): number;
  50790. /**
  50791. * Gets the box size of the impostor
  50792. * @param impostor impostor to get box size from
  50793. * @param result the resulting box size
  50794. */
  50795. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50796. /**
  50797. * Disposes of the impostor
  50798. */
  50799. dispose(): void;
  50800. }
  50801. }
  50802. declare module "babylonjs/Physics/Plugins/index" {
  50803. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  50804. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  50805. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  50806. }
  50807. declare module "babylonjs/Physics/index" {
  50808. export * from "babylonjs/Physics/IPhysicsEngine";
  50809. export * from "babylonjs/Physics/physicsEngine";
  50810. export * from "babylonjs/Physics/physicsEngineComponent";
  50811. export * from "babylonjs/Physics/physicsHelper";
  50812. export * from "babylonjs/Physics/physicsImpostor";
  50813. export * from "babylonjs/Physics/physicsJoint";
  50814. export * from "babylonjs/Physics/Plugins/index";
  50815. }
  50816. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  50817. /** @hidden */
  50818. export var blackAndWhitePixelShader: {
  50819. name: string;
  50820. shader: string;
  50821. };
  50822. }
  50823. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  50824. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50825. import { Camera } from "babylonjs/Cameras/camera";
  50826. import { Engine } from "babylonjs/Engines/engine";
  50827. import "babylonjs/Shaders/blackAndWhite.fragment";
  50828. /**
  50829. * Post process used to render in black and white
  50830. */
  50831. export class BlackAndWhitePostProcess extends PostProcess {
  50832. /**
  50833. * Linear about to convert he result to black and white (default: 1)
  50834. */
  50835. degree: number;
  50836. /**
  50837. * Creates a black and white post process
  50838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  50839. * @param name The name of the effect.
  50840. * @param options The required width/height ratio to downsize to before computing the render pass.
  50841. * @param camera The camera to apply the render pass to.
  50842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50843. * @param engine The engine which the post process will be applied. (default: current engine)
  50844. * @param reusable If the post process can be reused on the same frame. (default: false)
  50845. */
  50846. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50847. }
  50848. }
  50849. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  50850. import { Nullable } from "babylonjs/types";
  50851. import { Camera } from "babylonjs/Cameras/camera";
  50852. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50853. import { Engine } from "babylonjs/Engines/engine";
  50854. /**
  50855. * This represents a set of one or more post processes in Babylon.
  50856. * A post process can be used to apply a shader to a texture after it is rendered.
  50857. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50858. */
  50859. export class PostProcessRenderEffect {
  50860. private _postProcesses;
  50861. private _getPostProcesses;
  50862. private _singleInstance;
  50863. private _cameras;
  50864. private _indicesForCamera;
  50865. /**
  50866. * Name of the effect
  50867. * @hidden
  50868. */
  50869. _name: string;
  50870. /**
  50871. * Instantiates a post process render effect.
  50872. * A post process can be used to apply a shader to a texture after it is rendered.
  50873. * @param engine The engine the effect is tied to
  50874. * @param name The name of the effect
  50875. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  50876. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  50877. */
  50878. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  50879. /**
  50880. * Checks if all the post processes in the effect are supported.
  50881. */
  50882. readonly isSupported: boolean;
  50883. /**
  50884. * Updates the current state of the effect
  50885. * @hidden
  50886. */
  50887. _update(): void;
  50888. /**
  50889. * Attaches the effect on cameras
  50890. * @param cameras The camera to attach to.
  50891. * @hidden
  50892. */
  50893. _attachCameras(cameras: Camera): void;
  50894. /**
  50895. * Attaches the effect on cameras
  50896. * @param cameras The camera to attach to.
  50897. * @hidden
  50898. */
  50899. _attachCameras(cameras: Camera[]): void;
  50900. /**
  50901. * Detatches the effect on cameras
  50902. * @param cameras The camera to detatch from.
  50903. * @hidden
  50904. */
  50905. _detachCameras(cameras: Camera): void;
  50906. /**
  50907. * Detatches the effect on cameras
  50908. * @param cameras The camera to detatch from.
  50909. * @hidden
  50910. */
  50911. _detachCameras(cameras: Camera[]): void;
  50912. /**
  50913. * Enables the effect on given cameras
  50914. * @param cameras The camera to enable.
  50915. * @hidden
  50916. */
  50917. _enable(cameras: Camera): void;
  50918. /**
  50919. * Enables the effect on given cameras
  50920. * @param cameras The camera to enable.
  50921. * @hidden
  50922. */
  50923. _enable(cameras: Nullable<Camera[]>): void;
  50924. /**
  50925. * Disables the effect on the given cameras
  50926. * @param cameras The camera to disable.
  50927. * @hidden
  50928. */
  50929. _disable(cameras: Camera): void;
  50930. /**
  50931. * Disables the effect on the given cameras
  50932. * @param cameras The camera to disable.
  50933. * @hidden
  50934. */
  50935. _disable(cameras: Nullable<Camera[]>): void;
  50936. /**
  50937. * Gets a list of the post processes contained in the effect.
  50938. * @param camera The camera to get the post processes on.
  50939. * @returns The list of the post processes in the effect.
  50940. */
  50941. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  50942. }
  50943. }
  50944. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  50945. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50946. /** @hidden */
  50947. export var extractHighlightsPixelShader: {
  50948. name: string;
  50949. shader: string;
  50950. };
  50951. }
  50952. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  50953. import { Nullable } from "babylonjs/types";
  50954. import { Camera } from "babylonjs/Cameras/camera";
  50955. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50956. import { Engine } from "babylonjs/Engines/engine";
  50957. import "babylonjs/Shaders/extractHighlights.fragment";
  50958. /**
  50959. * 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.
  50960. */
  50961. export class ExtractHighlightsPostProcess extends PostProcess {
  50962. /**
  50963. * The luminance threshold, pixels below this value will be set to black.
  50964. */
  50965. threshold: number;
  50966. /** @hidden */
  50967. _exposure: number;
  50968. /**
  50969. * Post process which has the input texture to be used when performing highlight extraction
  50970. * @hidden
  50971. */
  50972. _inputPostProcess: Nullable<PostProcess>;
  50973. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50974. }
  50975. }
  50976. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  50977. /** @hidden */
  50978. export var bloomMergePixelShader: {
  50979. name: string;
  50980. shader: string;
  50981. };
  50982. }
  50983. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  50984. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50985. import { Nullable } from "babylonjs/types";
  50986. import { Engine } from "babylonjs/Engines/engine";
  50987. import { Camera } from "babylonjs/Cameras/camera";
  50988. import "babylonjs/Shaders/bloomMerge.fragment";
  50989. /**
  50990. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  50991. */
  50992. export class BloomMergePostProcess extends PostProcess {
  50993. /** Weight of the bloom to be added to the original input. */
  50994. weight: number;
  50995. /**
  50996. * Creates a new instance of @see BloomMergePostProcess
  50997. * @param name The name of the effect.
  50998. * @param originalFromInput Post process which's input will be used for the merge.
  50999. * @param blurred Blurred highlights post process which's output will be used.
  51000. * @param weight Weight of the bloom to be added to the original input.
  51001. * @param options The required width/height ratio to downsize to before computing the render pass.
  51002. * @param camera The camera to apply the render pass to.
  51003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51004. * @param engine The engine which the post process will be applied. (default: current engine)
  51005. * @param reusable If the post process can be reused on the same frame. (default: false)
  51006. * @param textureType Type of textures used when performing the post process. (default: 0)
  51007. * @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)
  51008. */
  51009. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51010. /** Weight of the bloom to be added to the original input. */
  51011. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51012. }
  51013. }
  51014. declare module "babylonjs/PostProcesses/bloomEffect" {
  51015. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51016. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51017. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  51018. import { Camera } from "babylonjs/Cameras/camera";
  51019. import { Scene } from "babylonjs/scene";
  51020. /**
  51021. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51022. */
  51023. export class BloomEffect extends PostProcessRenderEffect {
  51024. private bloomScale;
  51025. /**
  51026. * @hidden Internal
  51027. */
  51028. _effects: Array<PostProcess>;
  51029. /**
  51030. * @hidden Internal
  51031. */
  51032. _downscale: ExtractHighlightsPostProcess;
  51033. private _blurX;
  51034. private _blurY;
  51035. private _merge;
  51036. /**
  51037. * The luminance threshold to find bright areas of the image to bloom.
  51038. */
  51039. threshold: number;
  51040. /**
  51041. * The strength of the bloom.
  51042. */
  51043. weight: number;
  51044. /**
  51045. * Specifies the size of the bloom blur kernel, relative to the final output size
  51046. */
  51047. kernel: number;
  51048. /**
  51049. * Creates a new instance of @see BloomEffect
  51050. * @param scene The scene the effect belongs to.
  51051. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51052. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51053. * @param bloomWeight The the strength of bloom.
  51054. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51055. * @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)
  51056. */
  51057. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51058. /**
  51059. * Disposes each of the internal effects for a given camera.
  51060. * @param camera The camera to dispose the effect on.
  51061. */
  51062. disposeEffects(camera: Camera): void;
  51063. /**
  51064. * @hidden Internal
  51065. */
  51066. _updateEffects(): void;
  51067. /**
  51068. * Internal
  51069. * @returns if all the contained post processes are ready.
  51070. * @hidden
  51071. */
  51072. _isReady(): boolean;
  51073. }
  51074. }
  51075. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  51076. /** @hidden */
  51077. export var chromaticAberrationPixelShader: {
  51078. name: string;
  51079. shader: string;
  51080. };
  51081. }
  51082. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  51083. import { Vector2 } from "babylonjs/Maths/math";
  51084. import { Nullable } from "babylonjs/types";
  51085. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51086. import { Camera } from "babylonjs/Cameras/camera";
  51087. import { Engine } from "babylonjs/Engines/engine";
  51088. import "babylonjs/Shaders/chromaticAberration.fragment";
  51089. /**
  51090. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51091. */
  51092. export class ChromaticAberrationPostProcess extends PostProcess {
  51093. /**
  51094. * The amount of seperation of rgb channels (default: 30)
  51095. */
  51096. aberrationAmount: number;
  51097. /**
  51098. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51099. */
  51100. radialIntensity: number;
  51101. /**
  51102. * 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))
  51103. */
  51104. direction: Vector2;
  51105. /**
  51106. * 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))
  51107. */
  51108. centerPosition: Vector2;
  51109. /**
  51110. * Creates a new instance ChromaticAberrationPostProcess
  51111. * @param name The name of the effect.
  51112. * @param screenWidth The width of the screen to apply the effect on.
  51113. * @param screenHeight The height of the screen to apply the effect on.
  51114. * @param options The required width/height ratio to downsize to before computing the render pass.
  51115. * @param camera The camera to apply the render pass to.
  51116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51117. * @param engine The engine which the post process will be applied. (default: current engine)
  51118. * @param reusable If the post process can be reused on the same frame. (default: false)
  51119. * @param textureType Type of textures used when performing the post process. (default: 0)
  51120. * @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)
  51121. */
  51122. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51123. }
  51124. }
  51125. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  51126. /** @hidden */
  51127. export var circleOfConfusionPixelShader: {
  51128. name: string;
  51129. shader: string;
  51130. };
  51131. }
  51132. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  51133. import { Nullable } from "babylonjs/types";
  51134. import { Engine } from "babylonjs/Engines/engine";
  51135. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51136. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51137. import { Camera } from "babylonjs/Cameras/camera";
  51138. import "babylonjs/Shaders/circleOfConfusion.fragment";
  51139. /**
  51140. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51141. */
  51142. export class CircleOfConfusionPostProcess extends PostProcess {
  51143. /**
  51144. * 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.
  51145. */
  51146. lensSize: number;
  51147. /**
  51148. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51149. */
  51150. fStop: number;
  51151. /**
  51152. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51153. */
  51154. focusDistance: number;
  51155. /**
  51156. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51157. */
  51158. focalLength: number;
  51159. private _depthTexture;
  51160. /**
  51161. * Creates a new instance CircleOfConfusionPostProcess
  51162. * @param name The name of the effect.
  51163. * @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.
  51164. * @param options The required width/height ratio to downsize to before computing the render pass.
  51165. * @param camera The camera to apply the render pass to.
  51166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51167. * @param engine The engine which the post process will be applied. (default: current engine)
  51168. * @param reusable If the post process can be reused on the same frame. (default: false)
  51169. * @param textureType Type of textures used when performing the post process. (default: 0)
  51170. * @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)
  51171. */
  51172. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51173. /**
  51174. * 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.
  51175. */
  51176. depthTexture: RenderTargetTexture;
  51177. }
  51178. }
  51179. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  51180. /** @hidden */
  51181. export var colorCorrectionPixelShader: {
  51182. name: string;
  51183. shader: string;
  51184. };
  51185. }
  51186. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  51187. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51188. import { Engine } from "babylonjs/Engines/engine";
  51189. import { Camera } from "babylonjs/Cameras/camera";
  51190. import "babylonjs/Shaders/colorCorrection.fragment";
  51191. /**
  51192. *
  51193. * This post-process allows the modification of rendered colors by using
  51194. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51195. *
  51196. * The object needs to be provided an url to a texture containing the color
  51197. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51198. * Use an image editing software to tweak the LUT to match your needs.
  51199. *
  51200. * For an example of a color LUT, see here:
  51201. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51202. * For explanations on color grading, see here:
  51203. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51204. *
  51205. */
  51206. export class ColorCorrectionPostProcess extends PostProcess {
  51207. private _colorTableTexture;
  51208. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51209. }
  51210. }
  51211. declare module "babylonjs/Shaders/convolution.fragment" {
  51212. /** @hidden */
  51213. export var convolutionPixelShader: {
  51214. name: string;
  51215. shader: string;
  51216. };
  51217. }
  51218. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  51219. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51220. import { Nullable } from "babylonjs/types";
  51221. import { Camera } from "babylonjs/Cameras/camera";
  51222. import { Engine } from "babylonjs/Engines/engine";
  51223. import "babylonjs/Shaders/convolution.fragment";
  51224. /**
  51225. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51226. * input texture to perform effects such as edge detection or sharpening
  51227. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51228. */
  51229. export class ConvolutionPostProcess extends PostProcess {
  51230. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51231. kernel: number[];
  51232. /**
  51233. * Creates a new instance ConvolutionPostProcess
  51234. * @param name The name of the effect.
  51235. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51236. * @param options The required width/height ratio to downsize to before computing the render pass.
  51237. * @param camera The camera to apply the render pass to.
  51238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51239. * @param engine The engine which the post process will be applied. (default: current engine)
  51240. * @param reusable If the post process can be reused on the same frame. (default: false)
  51241. * @param textureType Type of textures used when performing the post process. (default: 0)
  51242. */
  51243. constructor(name: string,
  51244. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51245. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51246. /**
  51247. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51248. */
  51249. static EdgeDetect0Kernel: number[];
  51250. /**
  51251. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51252. */
  51253. static EdgeDetect1Kernel: number[];
  51254. /**
  51255. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51256. */
  51257. static EdgeDetect2Kernel: number[];
  51258. /**
  51259. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51260. */
  51261. static SharpenKernel: number[];
  51262. /**
  51263. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51264. */
  51265. static EmbossKernel: number[];
  51266. /**
  51267. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51268. */
  51269. static GaussianKernel: number[];
  51270. }
  51271. }
  51272. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  51273. import { Nullable } from "babylonjs/types";
  51274. import { Vector2 } from "babylonjs/Maths/math";
  51275. import { Camera } from "babylonjs/Cameras/camera";
  51276. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51277. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  51278. import { Engine } from "babylonjs/Engines/engine";
  51279. import { Scene } from "babylonjs/scene";
  51280. /**
  51281. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51282. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51283. * based on samples that have a large difference in distance than the center pixel.
  51284. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51285. */
  51286. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51287. direction: Vector2;
  51288. /**
  51289. * Creates a new instance CircleOfConfusionPostProcess
  51290. * @param name The name of the effect.
  51291. * @param scene The scene the effect belongs to.
  51292. * @param direction The direction the blur should be applied.
  51293. * @param kernel The size of the kernel used to blur.
  51294. * @param options The required width/height ratio to downsize to before computing the render pass.
  51295. * @param camera The camera to apply the render pass to.
  51296. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51297. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51298. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51299. * @param engine The engine which the post process will be applied. (default: current engine)
  51300. * @param reusable If the post process can be reused on the same frame. (default: false)
  51301. * @param textureType Type of textures used when performing the post process. (default: 0)
  51302. * @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)
  51303. */
  51304. 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);
  51305. }
  51306. }
  51307. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  51308. /** @hidden */
  51309. export var depthOfFieldMergePixelShader: {
  51310. name: string;
  51311. shader: string;
  51312. };
  51313. }
  51314. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  51315. import { Nullable } from "babylonjs/types";
  51316. import { Camera } from "babylonjs/Cameras/camera";
  51317. import { Effect } from "babylonjs/Materials/effect";
  51318. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51319. import { Engine } from "babylonjs/Engines/engine";
  51320. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  51321. /**
  51322. * Options to be set when merging outputs from the default pipeline.
  51323. */
  51324. export class DepthOfFieldMergePostProcessOptions {
  51325. /**
  51326. * The original image to merge on top of
  51327. */
  51328. originalFromInput: PostProcess;
  51329. /**
  51330. * Parameters to perform the merge of the depth of field effect
  51331. */
  51332. depthOfField?: {
  51333. circleOfConfusion: PostProcess;
  51334. blurSteps: Array<PostProcess>;
  51335. };
  51336. /**
  51337. * Parameters to perform the merge of bloom effect
  51338. */
  51339. bloom?: {
  51340. blurred: PostProcess;
  51341. weight: number;
  51342. };
  51343. }
  51344. /**
  51345. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51346. */
  51347. export class DepthOfFieldMergePostProcess extends PostProcess {
  51348. private blurSteps;
  51349. /**
  51350. * Creates a new instance of DepthOfFieldMergePostProcess
  51351. * @param name The name of the effect.
  51352. * @param originalFromInput Post process which's input will be used for the merge.
  51353. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51354. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51355. * @param options The required width/height ratio to downsize to before computing the render pass.
  51356. * @param camera The camera to apply the render pass to.
  51357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51358. * @param engine The engine which the post process will be applied. (default: current engine)
  51359. * @param reusable If the post process can be reused on the same frame. (default: false)
  51360. * @param textureType Type of textures used when performing the post process. (default: 0)
  51361. * @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)
  51362. */
  51363. 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);
  51364. /**
  51365. * Updates the effect with the current post process compile time values and recompiles the shader.
  51366. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51367. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51368. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51369. * @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
  51370. * @param onCompiled Called when the shader has been compiled.
  51371. * @param onError Called if there is an error when compiling a shader.
  51372. */
  51373. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51374. }
  51375. }
  51376. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  51377. import { Nullable } from "babylonjs/types";
  51378. import { Camera } from "babylonjs/Cameras/camera";
  51379. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51380. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51381. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51382. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  51383. import { Scene } from "babylonjs/scene";
  51384. /**
  51385. * Specifies the level of max blur that should be applied when using the depth of field effect
  51386. */
  51387. export enum DepthOfFieldEffectBlurLevel {
  51388. /**
  51389. * Subtle blur
  51390. */
  51391. Low = 0,
  51392. /**
  51393. * Medium blur
  51394. */
  51395. Medium = 1,
  51396. /**
  51397. * Large blur
  51398. */
  51399. High = 2
  51400. }
  51401. /**
  51402. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51403. */
  51404. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51405. private _circleOfConfusion;
  51406. /**
  51407. * @hidden Internal, blurs from high to low
  51408. */
  51409. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51410. private _depthOfFieldBlurY;
  51411. private _dofMerge;
  51412. /**
  51413. * @hidden Internal post processes in depth of field effect
  51414. */
  51415. _effects: Array<PostProcess>;
  51416. /**
  51417. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51418. */
  51419. focalLength: number;
  51420. /**
  51421. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51422. */
  51423. fStop: number;
  51424. /**
  51425. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51426. */
  51427. focusDistance: number;
  51428. /**
  51429. * 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.
  51430. */
  51431. lensSize: number;
  51432. /**
  51433. * Creates a new instance DepthOfFieldEffect
  51434. * @param scene The scene the effect belongs to.
  51435. * @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.
  51436. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51437. * @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)
  51438. */
  51439. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  51440. /**
  51441. * 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.
  51442. */
  51443. depthTexture: RenderTargetTexture;
  51444. /**
  51445. * Disposes each of the internal effects for a given camera.
  51446. * @param camera The camera to dispose the effect on.
  51447. */
  51448. disposeEffects(camera: Camera): void;
  51449. /**
  51450. * @hidden Internal
  51451. */
  51452. _updateEffects(): void;
  51453. /**
  51454. * Internal
  51455. * @returns if all the contained post processes are ready.
  51456. * @hidden
  51457. */
  51458. _isReady(): boolean;
  51459. }
  51460. }
  51461. declare module "babylonjs/Shaders/displayPass.fragment" {
  51462. /** @hidden */
  51463. export var displayPassPixelShader: {
  51464. name: string;
  51465. shader: string;
  51466. };
  51467. }
  51468. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  51469. import { Nullable } from "babylonjs/types";
  51470. import { Camera } from "babylonjs/Cameras/camera";
  51471. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51472. import { Engine } from "babylonjs/Engines/engine";
  51473. import "babylonjs/Shaders/displayPass.fragment";
  51474. /**
  51475. * DisplayPassPostProcess which produces an output the same as it's input
  51476. */
  51477. export class DisplayPassPostProcess extends PostProcess {
  51478. /**
  51479. * Creates the DisplayPassPostProcess
  51480. * @param name The name of the effect.
  51481. * @param options The required width/height ratio to downsize to before computing the render pass.
  51482. * @param camera The camera to apply the render pass to.
  51483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51484. * @param engine The engine which the post process will be applied. (default: current engine)
  51485. * @param reusable If the post process can be reused on the same frame. (default: false)
  51486. */
  51487. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51488. }
  51489. }
  51490. declare module "babylonjs/Shaders/filter.fragment" {
  51491. /** @hidden */
  51492. export var filterPixelShader: {
  51493. name: string;
  51494. shader: string;
  51495. };
  51496. }
  51497. declare module "babylonjs/PostProcesses/filterPostProcess" {
  51498. import { Nullable } from "babylonjs/types";
  51499. import { Matrix } from "babylonjs/Maths/math";
  51500. import { Camera } from "babylonjs/Cameras/camera";
  51501. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51502. import { Engine } from "babylonjs/Engines/engine";
  51503. import "babylonjs/Shaders/filter.fragment";
  51504. /**
  51505. * Applies a kernel filter to the image
  51506. */
  51507. export class FilterPostProcess extends PostProcess {
  51508. /** The matrix to be applied to the image */
  51509. kernelMatrix: Matrix;
  51510. /**
  51511. *
  51512. * @param name The name of the effect.
  51513. * @param kernelMatrix The matrix to be applied to the image
  51514. * @param options The required width/height ratio to downsize to before computing the render pass.
  51515. * @param camera The camera to apply the render pass to.
  51516. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51517. * @param engine The engine which the post process will be applied. (default: current engine)
  51518. * @param reusable If the post process can be reused on the same frame. (default: false)
  51519. */
  51520. constructor(name: string,
  51521. /** The matrix to be applied to the image */
  51522. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51523. }
  51524. }
  51525. declare module "babylonjs/Shaders/fxaa.fragment" {
  51526. /** @hidden */
  51527. export var fxaaPixelShader: {
  51528. name: string;
  51529. shader: string;
  51530. };
  51531. }
  51532. declare module "babylonjs/Shaders/fxaa.vertex" {
  51533. /** @hidden */
  51534. export var fxaaVertexShader: {
  51535. name: string;
  51536. shader: string;
  51537. };
  51538. }
  51539. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  51540. import { Nullable } from "babylonjs/types";
  51541. import { Camera } from "babylonjs/Cameras/camera";
  51542. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51543. import { Engine } from "babylonjs/Engines/engine";
  51544. import "babylonjs/Shaders/fxaa.fragment";
  51545. import "babylonjs/Shaders/fxaa.vertex";
  51546. /**
  51547. * Fxaa post process
  51548. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  51549. */
  51550. export class FxaaPostProcess extends PostProcess {
  51551. /** @hidden */
  51552. texelWidth: number;
  51553. /** @hidden */
  51554. texelHeight: number;
  51555. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51556. private _getDefines;
  51557. }
  51558. }
  51559. declare module "babylonjs/Shaders/grain.fragment" {
  51560. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51561. /** @hidden */
  51562. export var grainPixelShader: {
  51563. name: string;
  51564. shader: string;
  51565. };
  51566. }
  51567. declare module "babylonjs/PostProcesses/grainPostProcess" {
  51568. import { Nullable } from "babylonjs/types";
  51569. import { Camera } from "babylonjs/Cameras/camera";
  51570. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51571. import { Engine } from "babylonjs/Engines/engine";
  51572. import "babylonjs/Shaders/grain.fragment";
  51573. /**
  51574. * The GrainPostProcess adds noise to the image at mid luminance levels
  51575. */
  51576. export class GrainPostProcess extends PostProcess {
  51577. /**
  51578. * The intensity of the grain added (default: 30)
  51579. */
  51580. intensity: number;
  51581. /**
  51582. * If the grain should be randomized on every frame
  51583. */
  51584. animated: boolean;
  51585. /**
  51586. * Creates a new instance of @see GrainPostProcess
  51587. * @param name The name of the effect.
  51588. * @param options The required width/height ratio to downsize to before computing the render pass.
  51589. * @param camera The camera to apply the render pass to.
  51590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51591. * @param engine The engine which the post process will be applied. (default: current engine)
  51592. * @param reusable If the post process can be reused on the same frame. (default: false)
  51593. * @param textureType Type of textures used when performing the post process. (default: 0)
  51594. * @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)
  51595. */
  51596. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51597. }
  51598. }
  51599. declare module "babylonjs/Shaders/highlights.fragment" {
  51600. /** @hidden */
  51601. export var highlightsPixelShader: {
  51602. name: string;
  51603. shader: string;
  51604. };
  51605. }
  51606. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  51607. import { Nullable } from "babylonjs/types";
  51608. import { Camera } from "babylonjs/Cameras/camera";
  51609. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51610. import { Engine } from "babylonjs/Engines/engine";
  51611. import "babylonjs/Shaders/highlights.fragment";
  51612. /**
  51613. * Extracts highlights from the image
  51614. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51615. */
  51616. export class HighlightsPostProcess extends PostProcess {
  51617. /**
  51618. * Extracts highlights from the image
  51619. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51620. * @param name The name of the effect.
  51621. * @param options The required width/height ratio to downsize to before computing the render pass.
  51622. * @param camera The camera to apply the render pass to.
  51623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51624. * @param engine The engine which the post process will be applied. (default: current engine)
  51625. * @param reusable If the post process can be reused on the same frame. (default: false)
  51626. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  51627. */
  51628. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51629. }
  51630. }
  51631. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  51632. /** @hidden */
  51633. export var mrtFragmentDeclaration: {
  51634. name: string;
  51635. shader: string;
  51636. };
  51637. }
  51638. declare module "babylonjs/Shaders/geometry.fragment" {
  51639. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  51640. /** @hidden */
  51641. export var geometryPixelShader: {
  51642. name: string;
  51643. shader: string;
  51644. };
  51645. }
  51646. declare module "babylonjs/Shaders/geometry.vertex" {
  51647. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51648. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51649. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51650. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51651. /** @hidden */
  51652. export var geometryVertexShader: {
  51653. name: string;
  51654. shader: string;
  51655. };
  51656. }
  51657. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  51658. import { Matrix } from "babylonjs/Maths/math";
  51659. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51660. import { Mesh } from "babylonjs/Meshes/mesh";
  51661. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  51662. import { Effect } from "babylonjs/Materials/effect";
  51663. import { Scene } from "babylonjs/scene";
  51664. import "babylonjs/Shaders/geometry.fragment";
  51665. import "babylonjs/Shaders/geometry.vertex";
  51666. /**
  51667. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  51668. */
  51669. export class GeometryBufferRenderer {
  51670. /**
  51671. * Constant used to retrieve the position texture index in the G-Buffer textures array
  51672. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  51673. */
  51674. static readonly POSITION_TEXTURE_TYPE: number;
  51675. /**
  51676. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  51677. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  51678. */
  51679. static readonly VELOCITY_TEXTURE_TYPE: number;
  51680. /**
  51681. * Dictionary used to store the previous transformation matrices of each rendered mesh
  51682. * in order to compute objects velocities when enableVelocity is set to "true"
  51683. * @hidden
  51684. */
  51685. _previousTransformationMatrices: {
  51686. [index: number]: Matrix;
  51687. };
  51688. private _scene;
  51689. private _multiRenderTarget;
  51690. private _ratio;
  51691. private _enablePosition;
  51692. private _enableVelocity;
  51693. private _positionIndex;
  51694. private _velocityIndex;
  51695. protected _effect: Effect;
  51696. protected _cachedDefines: string;
  51697. /**
  51698. * Set the render list (meshes to be rendered) used in the G buffer.
  51699. */
  51700. renderList: Mesh[];
  51701. /**
  51702. * Gets wether or not G buffer are supported by the running hardware.
  51703. * This requires draw buffer supports
  51704. */
  51705. readonly isSupported: boolean;
  51706. /**
  51707. * Returns the index of the given texture type in the G-Buffer textures array
  51708. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  51709. * @returns the index of the given texture type in the G-Buffer textures array
  51710. */
  51711. getTextureIndex(textureType: number): number;
  51712. /**
  51713. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  51714. */
  51715. /**
  51716. * Sets whether or not objects positions are enabled for the G buffer.
  51717. */
  51718. enablePosition: boolean;
  51719. /**
  51720. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  51721. */
  51722. /**
  51723. * Sets wether or not objects velocities are enabled for the G buffer.
  51724. */
  51725. enableVelocity: boolean;
  51726. /**
  51727. * Gets the scene associated with the buffer.
  51728. */
  51729. readonly scene: Scene;
  51730. /**
  51731. * Gets the ratio used by the buffer during its creation.
  51732. * How big is the buffer related to the main canvas.
  51733. */
  51734. readonly ratio: number;
  51735. /** @hidden */
  51736. static _SceneComponentInitialization: (scene: Scene) => void;
  51737. /**
  51738. * Creates a new G Buffer for the scene
  51739. * @param scene The scene the buffer belongs to
  51740. * @param ratio How big is the buffer related to the main canvas.
  51741. */
  51742. constructor(scene: Scene, ratio?: number);
  51743. /**
  51744. * Checks wether everything is ready to render a submesh to the G buffer.
  51745. * @param subMesh the submesh to check readiness for
  51746. * @param useInstances is the mesh drawn using instance or not
  51747. * @returns true if ready otherwise false
  51748. */
  51749. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51750. /**
  51751. * Gets the current underlying G Buffer.
  51752. * @returns the buffer
  51753. */
  51754. getGBuffer(): MultiRenderTarget;
  51755. /**
  51756. * Gets the number of samples used to render the buffer (anti aliasing).
  51757. */
  51758. /**
  51759. * Sets the number of samples used to render the buffer (anti aliasing).
  51760. */
  51761. samples: number;
  51762. /**
  51763. * Disposes the renderer and frees up associated resources.
  51764. */
  51765. dispose(): void;
  51766. protected _createRenderTargets(): void;
  51767. }
  51768. }
  51769. declare module "babylonjs/Shaders/motionBlur.fragment" {
  51770. /** @hidden */
  51771. export var motionBlurPixelShader: {
  51772. name: string;
  51773. shader: string;
  51774. };
  51775. }
  51776. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  51777. import { Nullable } from "babylonjs/types";
  51778. import { Camera } from "babylonjs/Cameras/camera";
  51779. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51780. import { Scene } from "babylonjs/scene";
  51781. import "babylonjs/Shaders/motionBlur.fragment";
  51782. import { Engine } from "babylonjs/Engines/engine";
  51783. /**
  51784. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  51785. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  51786. * As an example, all you have to do is to create the post-process:
  51787. * var mb = new BABYLON.MotionBlurPostProcess(
  51788. * 'mb', // The name of the effect.
  51789. * scene, // The scene containing the objects to blur according to their velocity.
  51790. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  51791. * camera // The camera to apply the render pass to.
  51792. * );
  51793. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  51794. */
  51795. export class MotionBlurPostProcess extends PostProcess {
  51796. /**
  51797. * Defines how much the image is blurred by the movement. Default value is equal to 1
  51798. */
  51799. motionStrength: number;
  51800. /**
  51801. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  51802. */
  51803. /**
  51804. * Sets the number of iterations to be used for motion blur quality
  51805. */
  51806. motionBlurSamples: number;
  51807. private _motionBlurSamples;
  51808. private _geometryBufferRenderer;
  51809. /**
  51810. * Creates a new instance MotionBlurPostProcess
  51811. * @param name The name of the effect.
  51812. * @param scene The scene containing the objects to blur according to their velocity.
  51813. * @param options The required width/height ratio to downsize to before computing the render pass.
  51814. * @param camera The camera to apply the render pass to.
  51815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51816. * @param engine The engine which the post process will be applied. (default: current engine)
  51817. * @param reusable If the post process can be reused on the same frame. (default: false)
  51818. * @param textureType Type of textures used when performing the post process. (default: 0)
  51819. * @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)
  51820. */
  51821. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51822. /**
  51823. * Disposes the post process.
  51824. * @param camera The camera to dispose the post process on.
  51825. */
  51826. dispose(camera?: Camera): void;
  51827. }
  51828. }
  51829. declare module "babylonjs/Shaders/refraction.fragment" {
  51830. /** @hidden */
  51831. export var refractionPixelShader: {
  51832. name: string;
  51833. shader: string;
  51834. };
  51835. }
  51836. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  51837. import { Color3 } from "babylonjs/Maths/math";
  51838. import { Camera } from "babylonjs/Cameras/camera";
  51839. import { Texture } from "babylonjs/Materials/Textures/texture";
  51840. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51841. import { Engine } from "babylonjs/Engines/engine";
  51842. import "babylonjs/Shaders/refraction.fragment";
  51843. /**
  51844. * Post process which applies a refractin texture
  51845. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  51846. */
  51847. export class RefractionPostProcess extends PostProcess {
  51848. /** the base color of the refraction (used to taint the rendering) */
  51849. color: Color3;
  51850. /** simulated refraction depth */
  51851. depth: number;
  51852. /** the coefficient of the base color (0 to remove base color tainting) */
  51853. colorLevel: number;
  51854. private _refTexture;
  51855. private _ownRefractionTexture;
  51856. /**
  51857. * Gets or sets the refraction texture
  51858. * Please note that you are responsible for disposing the texture if you set it manually
  51859. */
  51860. refractionTexture: Texture;
  51861. /**
  51862. * Initializes the RefractionPostProcess
  51863. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  51864. * @param name The name of the effect.
  51865. * @param refractionTextureUrl Url of the refraction texture to use
  51866. * @param color the base color of the refraction (used to taint the rendering)
  51867. * @param depth simulated refraction depth
  51868. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  51869. * @param camera The camera to apply the render pass to.
  51870. * @param options The required width/height ratio to downsize to before computing the render pass.
  51871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51872. * @param engine The engine which the post process will be applied. (default: current engine)
  51873. * @param reusable If the post process can be reused on the same frame. (default: false)
  51874. */
  51875. constructor(name: string, refractionTextureUrl: string,
  51876. /** the base color of the refraction (used to taint the rendering) */
  51877. color: Color3,
  51878. /** simulated refraction depth */
  51879. depth: number,
  51880. /** the coefficient of the base color (0 to remove base color tainting) */
  51881. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51882. /**
  51883. * Disposes of the post process
  51884. * @param camera Camera to dispose post process on
  51885. */
  51886. dispose(camera: Camera): void;
  51887. }
  51888. }
  51889. declare module "babylonjs/Shaders/sharpen.fragment" {
  51890. /** @hidden */
  51891. export var sharpenPixelShader: {
  51892. name: string;
  51893. shader: string;
  51894. };
  51895. }
  51896. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  51897. import { Nullable } from "babylonjs/types";
  51898. import { Camera } from "babylonjs/Cameras/camera";
  51899. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51900. import "babylonjs/Shaders/sharpen.fragment";
  51901. import { Engine } from "babylonjs/Engines/engine";
  51902. /**
  51903. * The SharpenPostProcess applies a sharpen kernel to every pixel
  51904. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51905. */
  51906. export class SharpenPostProcess extends PostProcess {
  51907. /**
  51908. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  51909. */
  51910. colorAmount: number;
  51911. /**
  51912. * How much sharpness should be applied (default: 0.3)
  51913. */
  51914. edgeAmount: number;
  51915. /**
  51916. * Creates a new instance ConvolutionPostProcess
  51917. * @param name The name of the effect.
  51918. * @param options The required width/height ratio to downsize to before computing the render pass.
  51919. * @param camera The camera to apply the render pass to.
  51920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51921. * @param engine The engine which the post process will be applied. (default: current engine)
  51922. * @param reusable If the post process can be reused on the same frame. (default: false)
  51923. * @param textureType Type of textures used when performing the post process. (default: 0)
  51924. * @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)
  51925. */
  51926. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51927. }
  51928. }
  51929. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  51930. import { Nullable } from "babylonjs/types";
  51931. import { Camera } from "babylonjs/Cameras/camera";
  51932. import { Engine } from "babylonjs/Engines/engine";
  51933. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51934. /**
  51935. * PostProcessRenderPipeline
  51936. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51937. */
  51938. export class PostProcessRenderPipeline {
  51939. private engine;
  51940. private _renderEffects;
  51941. private _renderEffectsForIsolatedPass;
  51942. /**
  51943. * @hidden
  51944. */
  51945. protected _cameras: Camera[];
  51946. /** @hidden */
  51947. _name: string;
  51948. /**
  51949. * Initializes a PostProcessRenderPipeline
  51950. * @param engine engine to add the pipeline to
  51951. * @param name name of the pipeline
  51952. */
  51953. constructor(engine: Engine, name: string);
  51954. /**
  51955. * "PostProcessRenderPipeline"
  51956. * @returns "PostProcessRenderPipeline"
  51957. */
  51958. getClassName(): string;
  51959. /**
  51960. * If all the render effects in the pipeline are support
  51961. */
  51962. readonly isSupported: boolean;
  51963. /**
  51964. * Adds an effect to the pipeline
  51965. * @param renderEffect the effect to add
  51966. */
  51967. addEffect(renderEffect: PostProcessRenderEffect): void;
  51968. /** @hidden */
  51969. _rebuild(): void;
  51970. /** @hidden */
  51971. _enableEffect(renderEffectName: string, cameras: Camera): void;
  51972. /** @hidden */
  51973. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  51974. /** @hidden */
  51975. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  51976. /** @hidden */
  51977. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  51978. /** @hidden */
  51979. _attachCameras(cameras: Camera, unique: boolean): void;
  51980. /** @hidden */
  51981. _attachCameras(cameras: Camera[], unique: boolean): void;
  51982. /** @hidden */
  51983. _detachCameras(cameras: Camera): void;
  51984. /** @hidden */
  51985. _detachCameras(cameras: Nullable<Camera[]>): void;
  51986. /** @hidden */
  51987. _update(): void;
  51988. /** @hidden */
  51989. _reset(): void;
  51990. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  51991. /**
  51992. * Disposes of the pipeline
  51993. */
  51994. dispose(): void;
  51995. }
  51996. }
  51997. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  51998. import { IAnimatable } from "babylonjs/Misc/tools";
  51999. import { Camera } from "babylonjs/Cameras/camera";
  52000. import { IDisposable } from "babylonjs/scene";
  52001. import { Scene } from "babylonjs/scene";
  52002. import { Animation } from "babylonjs/Animations/animation";
  52003. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  52004. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  52005. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  52006. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  52007. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52008. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52009. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  52010. /**
  52011. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52012. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52013. */
  52014. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52015. private _scene;
  52016. private _camerasToBeAttached;
  52017. /**
  52018. * ID of the sharpen post process,
  52019. */
  52020. private readonly SharpenPostProcessId;
  52021. /**
  52022. * @ignore
  52023. * ID of the image processing post process;
  52024. */
  52025. readonly ImageProcessingPostProcessId: string;
  52026. /**
  52027. * @ignore
  52028. * ID of the Fast Approximate Anti-Aliasing post process;
  52029. */
  52030. readonly FxaaPostProcessId: string;
  52031. /**
  52032. * ID of the chromatic aberration post process,
  52033. */
  52034. private readonly ChromaticAberrationPostProcessId;
  52035. /**
  52036. * ID of the grain post process
  52037. */
  52038. private readonly GrainPostProcessId;
  52039. /**
  52040. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52041. */
  52042. sharpen: SharpenPostProcess;
  52043. private _sharpenEffect;
  52044. private bloom;
  52045. /**
  52046. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52047. */
  52048. depthOfField: DepthOfFieldEffect;
  52049. /**
  52050. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52051. */
  52052. fxaa: FxaaPostProcess;
  52053. /**
  52054. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52055. */
  52056. imageProcessing: ImageProcessingPostProcess;
  52057. /**
  52058. * Chromatic aberration post process which will shift rgb colors in the image
  52059. */
  52060. chromaticAberration: ChromaticAberrationPostProcess;
  52061. private _chromaticAberrationEffect;
  52062. /**
  52063. * Grain post process which add noise to the image
  52064. */
  52065. grain: GrainPostProcess;
  52066. private _grainEffect;
  52067. /**
  52068. * Glow post process which adds a glow to emmisive areas of the image
  52069. */
  52070. private _glowLayer;
  52071. /**
  52072. * Animations which can be used to tweak settings over a period of time
  52073. */
  52074. animations: Animation[];
  52075. private _imageProcessingConfigurationObserver;
  52076. private _sharpenEnabled;
  52077. private _bloomEnabled;
  52078. private _depthOfFieldEnabled;
  52079. private _depthOfFieldBlurLevel;
  52080. private _fxaaEnabled;
  52081. private _imageProcessingEnabled;
  52082. private _defaultPipelineTextureType;
  52083. private _bloomScale;
  52084. private _chromaticAberrationEnabled;
  52085. private _grainEnabled;
  52086. private _buildAllowed;
  52087. /**
  52088. * Enable or disable the sharpen process from the pipeline
  52089. */
  52090. sharpenEnabled: boolean;
  52091. private _resizeObserver;
  52092. private _hardwareScaleLevel;
  52093. private _bloomKernel;
  52094. /**
  52095. * Specifies the size of the bloom blur kernel, relative to the final output size
  52096. */
  52097. bloomKernel: number;
  52098. /**
  52099. * Specifies the weight of the bloom in the final rendering
  52100. */
  52101. private _bloomWeight;
  52102. /**
  52103. * Specifies the luma threshold for the area that will be blurred by the bloom
  52104. */
  52105. private _bloomThreshold;
  52106. private _hdr;
  52107. /**
  52108. * The strength of the bloom.
  52109. */
  52110. bloomWeight: number;
  52111. /**
  52112. * The strength of the bloom.
  52113. */
  52114. bloomThreshold: number;
  52115. /**
  52116. * The scale of the bloom, lower value will provide better performance.
  52117. */
  52118. bloomScale: number;
  52119. /**
  52120. * Enable or disable the bloom from the pipeline
  52121. */
  52122. bloomEnabled: boolean;
  52123. private _rebuildBloom;
  52124. /**
  52125. * If the depth of field is enabled.
  52126. */
  52127. depthOfFieldEnabled: boolean;
  52128. /**
  52129. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52130. */
  52131. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52132. /**
  52133. * If the anti aliasing is enabled.
  52134. */
  52135. fxaaEnabled: boolean;
  52136. private _samples;
  52137. /**
  52138. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52139. */
  52140. samples: number;
  52141. /**
  52142. * If image processing is enabled.
  52143. */
  52144. imageProcessingEnabled: boolean;
  52145. /**
  52146. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52147. */
  52148. glowLayerEnabled: boolean;
  52149. /**
  52150. * Enable or disable the chromaticAberration process from the pipeline
  52151. */
  52152. chromaticAberrationEnabled: boolean;
  52153. /**
  52154. * Enable or disable the grain process from the pipeline
  52155. */
  52156. grainEnabled: boolean;
  52157. /**
  52158. * @constructor
  52159. * @param name - The rendering pipeline name (default: "")
  52160. * @param hdr - If high dynamic range textures should be used (default: true)
  52161. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52162. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52163. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52164. */
  52165. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52166. /**
  52167. * Force the compilation of the entire pipeline.
  52168. */
  52169. prepare(): void;
  52170. private _hasCleared;
  52171. private _prevPostProcess;
  52172. private _prevPrevPostProcess;
  52173. private _setAutoClearAndTextureSharing;
  52174. private _depthOfFieldSceneObserver;
  52175. private _buildPipeline;
  52176. private _disposePostProcesses;
  52177. /**
  52178. * Adds a camera to the pipeline
  52179. * @param camera the camera to be added
  52180. */
  52181. addCamera(camera: Camera): void;
  52182. /**
  52183. * Removes a camera from the pipeline
  52184. * @param camera the camera to remove
  52185. */
  52186. removeCamera(camera: Camera): void;
  52187. /**
  52188. * Dispose of the pipeline and stop all post processes
  52189. */
  52190. dispose(): void;
  52191. /**
  52192. * Serialize the rendering pipeline (Used when exporting)
  52193. * @returns the serialized object
  52194. */
  52195. serialize(): any;
  52196. /**
  52197. * Parse the serialized pipeline
  52198. * @param source Source pipeline.
  52199. * @param scene The scene to load the pipeline to.
  52200. * @param rootUrl The URL of the serialized pipeline.
  52201. * @returns An instantiated pipeline from the serialized object.
  52202. */
  52203. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52204. }
  52205. }
  52206. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  52207. /** @hidden */
  52208. export var lensHighlightsPixelShader: {
  52209. name: string;
  52210. shader: string;
  52211. };
  52212. }
  52213. declare module "babylonjs/Shaders/depthOfField.fragment" {
  52214. /** @hidden */
  52215. export var depthOfFieldPixelShader: {
  52216. name: string;
  52217. shader: string;
  52218. };
  52219. }
  52220. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  52221. import { Camera } from "babylonjs/Cameras/camera";
  52222. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52223. import { Scene } from "babylonjs/scene";
  52224. import "babylonjs/Shaders/chromaticAberration.fragment";
  52225. import "babylonjs/Shaders/lensHighlights.fragment";
  52226. import "babylonjs/Shaders/depthOfField.fragment";
  52227. /**
  52228. * BABYLON.JS Chromatic Aberration GLSL Shader
  52229. * Author: Olivier Guyot
  52230. * Separates very slightly R, G and B colors on the edges of the screen
  52231. * Inspired by Francois Tarlier & Martins Upitis
  52232. */
  52233. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52234. /**
  52235. * @ignore
  52236. * The chromatic aberration PostProcess id in the pipeline
  52237. */
  52238. LensChromaticAberrationEffect: string;
  52239. /**
  52240. * @ignore
  52241. * The highlights enhancing PostProcess id in the pipeline
  52242. */
  52243. HighlightsEnhancingEffect: string;
  52244. /**
  52245. * @ignore
  52246. * The depth-of-field PostProcess id in the pipeline
  52247. */
  52248. LensDepthOfFieldEffect: string;
  52249. private _scene;
  52250. private _depthTexture;
  52251. private _grainTexture;
  52252. private _chromaticAberrationPostProcess;
  52253. private _highlightsPostProcess;
  52254. private _depthOfFieldPostProcess;
  52255. private _edgeBlur;
  52256. private _grainAmount;
  52257. private _chromaticAberration;
  52258. private _distortion;
  52259. private _highlightsGain;
  52260. private _highlightsThreshold;
  52261. private _dofDistance;
  52262. private _dofAperture;
  52263. private _dofDarken;
  52264. private _dofPentagon;
  52265. private _blurNoise;
  52266. /**
  52267. * @constructor
  52268. *
  52269. * Effect parameters are as follow:
  52270. * {
  52271. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52272. * edge_blur: number; // from 0 to x (1 for realism)
  52273. * distortion: number; // from 0 to x (1 for realism)
  52274. * grain_amount: number; // from 0 to 1
  52275. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52276. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52277. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52278. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52279. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52280. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52281. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52282. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52283. * }
  52284. * Note: if an effect parameter is unset, effect is disabled
  52285. *
  52286. * @param name The rendering pipeline name
  52287. * @param parameters - An object containing all parameters (see above)
  52288. * @param scene The scene linked to this pipeline
  52289. * @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)
  52290. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52291. */
  52292. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52293. /**
  52294. * Sets the amount of blur at the edges
  52295. * @param amount blur amount
  52296. */
  52297. setEdgeBlur(amount: number): void;
  52298. /**
  52299. * Sets edge blur to 0
  52300. */
  52301. disableEdgeBlur(): void;
  52302. /**
  52303. * Sets the amout of grain
  52304. * @param amount Amount of grain
  52305. */
  52306. setGrainAmount(amount: number): void;
  52307. /**
  52308. * Set grain amount to 0
  52309. */
  52310. disableGrain(): void;
  52311. /**
  52312. * Sets the chromatic aberration amount
  52313. * @param amount amount of chromatic aberration
  52314. */
  52315. setChromaticAberration(amount: number): void;
  52316. /**
  52317. * Sets chromatic aberration amount to 0
  52318. */
  52319. disableChromaticAberration(): void;
  52320. /**
  52321. * Sets the EdgeDistortion amount
  52322. * @param amount amount of EdgeDistortion
  52323. */
  52324. setEdgeDistortion(amount: number): void;
  52325. /**
  52326. * Sets edge distortion to 0
  52327. */
  52328. disableEdgeDistortion(): void;
  52329. /**
  52330. * Sets the FocusDistance amount
  52331. * @param amount amount of FocusDistance
  52332. */
  52333. setFocusDistance(amount: number): void;
  52334. /**
  52335. * Disables depth of field
  52336. */
  52337. disableDepthOfField(): void;
  52338. /**
  52339. * Sets the Aperture amount
  52340. * @param amount amount of Aperture
  52341. */
  52342. setAperture(amount: number): void;
  52343. /**
  52344. * Sets the DarkenOutOfFocus amount
  52345. * @param amount amount of DarkenOutOfFocus
  52346. */
  52347. setDarkenOutOfFocus(amount: number): void;
  52348. /**
  52349. * Creates a pentagon bokeh effect
  52350. */
  52351. enablePentagonBokeh(): void;
  52352. /**
  52353. * Disables the pentagon bokeh effect
  52354. */
  52355. disablePentagonBokeh(): void;
  52356. /**
  52357. * Enables noise blur
  52358. */
  52359. enableNoiseBlur(): void;
  52360. /**
  52361. * Disables noise blur
  52362. */
  52363. disableNoiseBlur(): void;
  52364. /**
  52365. * Sets the HighlightsGain amount
  52366. * @param amount amount of HighlightsGain
  52367. */
  52368. setHighlightsGain(amount: number): void;
  52369. /**
  52370. * Sets the HighlightsThreshold amount
  52371. * @param amount amount of HighlightsThreshold
  52372. */
  52373. setHighlightsThreshold(amount: number): void;
  52374. /**
  52375. * Disables highlights
  52376. */
  52377. disableHighlights(): void;
  52378. /**
  52379. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52380. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52381. */
  52382. dispose(disableDepthRender?: boolean): void;
  52383. private _createChromaticAberrationPostProcess;
  52384. private _createHighlightsPostProcess;
  52385. private _createDepthOfFieldPostProcess;
  52386. private _createGrainTexture;
  52387. }
  52388. }
  52389. declare module "babylonjs/Shaders/ssao2.fragment" {
  52390. /** @hidden */
  52391. export var ssao2PixelShader: {
  52392. name: string;
  52393. shader: string;
  52394. };
  52395. }
  52396. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  52397. /** @hidden */
  52398. export var ssaoCombinePixelShader: {
  52399. name: string;
  52400. shader: string;
  52401. };
  52402. }
  52403. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  52404. import { Camera } from "babylonjs/Cameras/camera";
  52405. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52406. import { Scene } from "babylonjs/scene";
  52407. import "babylonjs/Shaders/ssao2.fragment";
  52408. import "babylonjs/Shaders/ssaoCombine.fragment";
  52409. /**
  52410. * Render pipeline to produce ssao effect
  52411. */
  52412. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  52413. /**
  52414. * @ignore
  52415. * The PassPostProcess id in the pipeline that contains the original scene color
  52416. */
  52417. SSAOOriginalSceneColorEffect: string;
  52418. /**
  52419. * @ignore
  52420. * The SSAO PostProcess id in the pipeline
  52421. */
  52422. SSAORenderEffect: string;
  52423. /**
  52424. * @ignore
  52425. * The horizontal blur PostProcess id in the pipeline
  52426. */
  52427. SSAOBlurHRenderEffect: string;
  52428. /**
  52429. * @ignore
  52430. * The vertical blur PostProcess id in the pipeline
  52431. */
  52432. SSAOBlurVRenderEffect: string;
  52433. /**
  52434. * @ignore
  52435. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52436. */
  52437. SSAOCombineRenderEffect: string;
  52438. /**
  52439. * The output strength of the SSAO post-process. Default value is 1.0.
  52440. */
  52441. totalStrength: number;
  52442. /**
  52443. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  52444. */
  52445. maxZ: number;
  52446. /**
  52447. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  52448. */
  52449. minZAspect: number;
  52450. private _samples;
  52451. /**
  52452. * Number of samples used for the SSAO calculations. Default value is 8
  52453. */
  52454. samples: number;
  52455. private _textureSamples;
  52456. /**
  52457. * Number of samples to use for antialiasing
  52458. */
  52459. textureSamples: number;
  52460. /**
  52461. * Ratio object used for SSAO ratio and blur ratio
  52462. */
  52463. private _ratio;
  52464. /**
  52465. * Dynamically generated sphere sampler.
  52466. */
  52467. private _sampleSphere;
  52468. /**
  52469. * Blur filter offsets
  52470. */
  52471. private _samplerOffsets;
  52472. private _expensiveBlur;
  52473. /**
  52474. * If bilateral blur should be used
  52475. */
  52476. expensiveBlur: boolean;
  52477. /**
  52478. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  52479. */
  52480. radius: number;
  52481. /**
  52482. * The base color of the SSAO post-process
  52483. * The final result is "base + ssao" between [0, 1]
  52484. */
  52485. base: number;
  52486. /**
  52487. * Support test.
  52488. */
  52489. static readonly IsSupported: boolean;
  52490. private _scene;
  52491. private _depthTexture;
  52492. private _normalTexture;
  52493. private _randomTexture;
  52494. private _originalColorPostProcess;
  52495. private _ssaoPostProcess;
  52496. private _blurHPostProcess;
  52497. private _blurVPostProcess;
  52498. private _ssaoCombinePostProcess;
  52499. private _firstUpdate;
  52500. /**
  52501. * @constructor
  52502. * @param name The rendering pipeline name
  52503. * @param scene The scene linked to this pipeline
  52504. * @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 }
  52505. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52506. */
  52507. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52508. /**
  52509. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52510. */
  52511. dispose(disableGeometryBufferRenderer?: boolean): void;
  52512. private _createBlurPostProcess;
  52513. /** @hidden */
  52514. _rebuild(): void;
  52515. private _bits;
  52516. private _radicalInverse_VdC;
  52517. private _hammersley;
  52518. private _hemisphereSample_uniform;
  52519. private _generateHemisphere;
  52520. private _createSSAOPostProcess;
  52521. private _createSSAOCombinePostProcess;
  52522. private _createRandomTexture;
  52523. /**
  52524. * Serialize the rendering pipeline (Used when exporting)
  52525. * @returns the serialized object
  52526. */
  52527. serialize(): any;
  52528. /**
  52529. * Parse the serialized pipeline
  52530. * @param source Source pipeline.
  52531. * @param scene The scene to load the pipeline to.
  52532. * @param rootUrl The URL of the serialized pipeline.
  52533. * @returns An instantiated pipeline from the serialized object.
  52534. */
  52535. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  52536. }
  52537. }
  52538. declare module "babylonjs/Shaders/ssao.fragment" {
  52539. /** @hidden */
  52540. export var ssaoPixelShader: {
  52541. name: string;
  52542. shader: string;
  52543. };
  52544. }
  52545. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  52546. import { Camera } from "babylonjs/Cameras/camera";
  52547. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52548. import { Scene } from "babylonjs/scene";
  52549. import "babylonjs/Shaders/ssao.fragment";
  52550. import "babylonjs/Shaders/ssaoCombine.fragment";
  52551. /**
  52552. * Render pipeline to produce ssao effect
  52553. */
  52554. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  52555. /**
  52556. * @ignore
  52557. * The PassPostProcess id in the pipeline that contains the original scene color
  52558. */
  52559. SSAOOriginalSceneColorEffect: string;
  52560. /**
  52561. * @ignore
  52562. * The SSAO PostProcess id in the pipeline
  52563. */
  52564. SSAORenderEffect: string;
  52565. /**
  52566. * @ignore
  52567. * The horizontal blur PostProcess id in the pipeline
  52568. */
  52569. SSAOBlurHRenderEffect: string;
  52570. /**
  52571. * @ignore
  52572. * The vertical blur PostProcess id in the pipeline
  52573. */
  52574. SSAOBlurVRenderEffect: string;
  52575. /**
  52576. * @ignore
  52577. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52578. */
  52579. SSAOCombineRenderEffect: string;
  52580. /**
  52581. * The output strength of the SSAO post-process. Default value is 1.0.
  52582. */
  52583. totalStrength: number;
  52584. /**
  52585. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  52586. */
  52587. radius: number;
  52588. /**
  52589. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  52590. * Must not be equal to fallOff and superior to fallOff.
  52591. * Default value is 0.975
  52592. */
  52593. area: number;
  52594. /**
  52595. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  52596. * Must not be equal to area and inferior to area.
  52597. * Default value is 0.0
  52598. */
  52599. fallOff: number;
  52600. /**
  52601. * The base color of the SSAO post-process
  52602. * The final result is "base + ssao" between [0, 1]
  52603. */
  52604. base: number;
  52605. private _scene;
  52606. private _depthTexture;
  52607. private _randomTexture;
  52608. private _originalColorPostProcess;
  52609. private _ssaoPostProcess;
  52610. private _blurHPostProcess;
  52611. private _blurVPostProcess;
  52612. private _ssaoCombinePostProcess;
  52613. private _firstUpdate;
  52614. /**
  52615. * @constructor
  52616. * @param name - The rendering pipeline name
  52617. * @param scene - The scene linked to this pipeline
  52618. * @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 }
  52619. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  52620. */
  52621. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52622. /**
  52623. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52624. */
  52625. dispose(disableDepthRender?: boolean): void;
  52626. private _createBlurPostProcess;
  52627. /** @hidden */
  52628. _rebuild(): void;
  52629. private _createSSAOPostProcess;
  52630. private _createSSAOCombinePostProcess;
  52631. private _createRandomTexture;
  52632. }
  52633. }
  52634. declare module "babylonjs/Shaders/standard.fragment" {
  52635. /** @hidden */
  52636. export var standardPixelShader: {
  52637. name: string;
  52638. shader: string;
  52639. };
  52640. }
  52641. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  52642. import { Nullable } from "babylonjs/types";
  52643. import { IAnimatable } from "babylonjs/Misc/tools";
  52644. import { Camera } from "babylonjs/Cameras/camera";
  52645. import { Texture } from "babylonjs/Materials/Textures/texture";
  52646. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52647. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52648. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  52649. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52650. import { IDisposable } from "babylonjs/scene";
  52651. import { SpotLight } from "babylonjs/Lights/spotLight";
  52652. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  52653. import { Scene } from "babylonjs/scene";
  52654. import { Animation } from "babylonjs/Animations/animation";
  52655. import "babylonjs/Shaders/standard.fragment";
  52656. /**
  52657. * Standard rendering pipeline
  52658. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  52659. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  52660. */
  52661. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52662. /**
  52663. * Public members
  52664. */
  52665. /**
  52666. * Post-process which contains the original scene color before the pipeline applies all the effects
  52667. */
  52668. originalPostProcess: Nullable<PostProcess>;
  52669. /**
  52670. * Post-process used to down scale an image x4
  52671. */
  52672. downSampleX4PostProcess: Nullable<PostProcess>;
  52673. /**
  52674. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  52675. */
  52676. brightPassPostProcess: Nullable<PostProcess>;
  52677. /**
  52678. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  52679. */
  52680. blurHPostProcesses: PostProcess[];
  52681. /**
  52682. * Post-process array storing all the vertical blur post-processes used by the pipeline
  52683. */
  52684. blurVPostProcesses: PostProcess[];
  52685. /**
  52686. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  52687. */
  52688. textureAdderPostProcess: Nullable<PostProcess>;
  52689. /**
  52690. * Post-process used to create volumetric lighting effect
  52691. */
  52692. volumetricLightPostProcess: Nullable<PostProcess>;
  52693. /**
  52694. * Post-process used to smooth the previous volumetric light post-process on the X axis
  52695. */
  52696. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  52697. /**
  52698. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  52699. */
  52700. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  52701. /**
  52702. * Post-process used to merge the volumetric light effect and the real scene color
  52703. */
  52704. volumetricLightMergePostProces: Nullable<PostProcess>;
  52705. /**
  52706. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  52707. */
  52708. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  52709. /**
  52710. * Base post-process used to calculate the average luminance of the final image for HDR
  52711. */
  52712. luminancePostProcess: Nullable<PostProcess>;
  52713. /**
  52714. * Post-processes used to create down sample post-processes in order to get
  52715. * the average luminance of the final image for HDR
  52716. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  52717. */
  52718. luminanceDownSamplePostProcesses: PostProcess[];
  52719. /**
  52720. * Post-process used to create a HDR effect (light adaptation)
  52721. */
  52722. hdrPostProcess: Nullable<PostProcess>;
  52723. /**
  52724. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  52725. */
  52726. textureAdderFinalPostProcess: Nullable<PostProcess>;
  52727. /**
  52728. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  52729. */
  52730. lensFlareFinalPostProcess: Nullable<PostProcess>;
  52731. /**
  52732. * Post-process used to merge the final HDR post-process and the real scene color
  52733. */
  52734. hdrFinalPostProcess: Nullable<PostProcess>;
  52735. /**
  52736. * Post-process used to create a lens flare effect
  52737. */
  52738. lensFlarePostProcess: Nullable<PostProcess>;
  52739. /**
  52740. * Post-process that merges the result of the lens flare post-process and the real scene color
  52741. */
  52742. lensFlareComposePostProcess: Nullable<PostProcess>;
  52743. /**
  52744. * Post-process used to create a motion blur effect
  52745. */
  52746. motionBlurPostProcess: Nullable<PostProcess>;
  52747. /**
  52748. * Post-process used to create a depth of field effect
  52749. */
  52750. depthOfFieldPostProcess: Nullable<PostProcess>;
  52751. /**
  52752. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52753. */
  52754. fxaaPostProcess: Nullable<FxaaPostProcess>;
  52755. /**
  52756. * Represents the brightness threshold in order to configure the illuminated surfaces
  52757. */
  52758. brightThreshold: number;
  52759. /**
  52760. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  52761. */
  52762. blurWidth: number;
  52763. /**
  52764. * Sets if the blur for highlighted surfaces must be only horizontal
  52765. */
  52766. horizontalBlur: boolean;
  52767. /**
  52768. * Sets the overall exposure used by the pipeline
  52769. */
  52770. exposure: number;
  52771. /**
  52772. * Texture used typically to simulate "dirty" on camera lens
  52773. */
  52774. lensTexture: Nullable<Texture>;
  52775. /**
  52776. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  52777. */
  52778. volumetricLightCoefficient: number;
  52779. /**
  52780. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  52781. */
  52782. volumetricLightPower: number;
  52783. /**
  52784. * Used the set the blur intensity to smooth the volumetric lights
  52785. */
  52786. volumetricLightBlurScale: number;
  52787. /**
  52788. * Light (spot or directional) used to generate the volumetric lights rays
  52789. * The source light must have a shadow generate so the pipeline can get its
  52790. * depth map
  52791. */
  52792. sourceLight: Nullable<SpotLight | DirectionalLight>;
  52793. /**
  52794. * For eye adaptation, represents the minimum luminance the eye can see
  52795. */
  52796. hdrMinimumLuminance: number;
  52797. /**
  52798. * For eye adaptation, represents the decrease luminance speed
  52799. */
  52800. hdrDecreaseRate: number;
  52801. /**
  52802. * For eye adaptation, represents the increase luminance speed
  52803. */
  52804. hdrIncreaseRate: number;
  52805. /**
  52806. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  52807. */
  52808. lensColorTexture: Nullable<Texture>;
  52809. /**
  52810. * The overall strengh for the lens flare effect
  52811. */
  52812. lensFlareStrength: number;
  52813. /**
  52814. * Dispersion coefficient for lens flare ghosts
  52815. */
  52816. lensFlareGhostDispersal: number;
  52817. /**
  52818. * Main lens flare halo width
  52819. */
  52820. lensFlareHaloWidth: number;
  52821. /**
  52822. * Based on the lens distortion effect, defines how much the lens flare result
  52823. * is distorted
  52824. */
  52825. lensFlareDistortionStrength: number;
  52826. /**
  52827. * Lens star texture must be used to simulate rays on the flares and is available
  52828. * in the documentation
  52829. */
  52830. lensStarTexture: Nullable<Texture>;
  52831. /**
  52832. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  52833. * flare effect by taking account of the dirt texture
  52834. */
  52835. lensFlareDirtTexture: Nullable<Texture>;
  52836. /**
  52837. * Represents the focal length for the depth of field effect
  52838. */
  52839. depthOfFieldDistance: number;
  52840. /**
  52841. * Represents the blur intensity for the blurred part of the depth of field effect
  52842. */
  52843. depthOfFieldBlurWidth: number;
  52844. /**
  52845. * For motion blur, defines how much the image is blurred by the movement
  52846. */
  52847. motionStrength: number;
  52848. /**
  52849. * List of animations for the pipeline (IAnimatable implementation)
  52850. */
  52851. animations: Animation[];
  52852. /**
  52853. * Private members
  52854. */
  52855. private _scene;
  52856. private _currentDepthOfFieldSource;
  52857. private _basePostProcess;
  52858. private _hdrCurrentLuminance;
  52859. private _floatTextureType;
  52860. private _ratio;
  52861. private _bloomEnabled;
  52862. private _depthOfFieldEnabled;
  52863. private _vlsEnabled;
  52864. private _lensFlareEnabled;
  52865. private _hdrEnabled;
  52866. private _motionBlurEnabled;
  52867. private _fxaaEnabled;
  52868. private _motionBlurSamples;
  52869. private _volumetricLightStepsCount;
  52870. private _samples;
  52871. /**
  52872. * @ignore
  52873. * Specifies if the bloom pipeline is enabled
  52874. */
  52875. BloomEnabled: boolean;
  52876. /**
  52877. * @ignore
  52878. * Specifies if the depth of field pipeline is enabed
  52879. */
  52880. DepthOfFieldEnabled: boolean;
  52881. /**
  52882. * @ignore
  52883. * Specifies if the lens flare pipeline is enabed
  52884. */
  52885. LensFlareEnabled: boolean;
  52886. /**
  52887. * @ignore
  52888. * Specifies if the HDR pipeline is enabled
  52889. */
  52890. HDREnabled: boolean;
  52891. /**
  52892. * @ignore
  52893. * Specifies if the volumetric lights scattering effect is enabled
  52894. */
  52895. VLSEnabled: boolean;
  52896. /**
  52897. * @ignore
  52898. * Specifies if the motion blur effect is enabled
  52899. */
  52900. MotionBlurEnabled: boolean;
  52901. /**
  52902. * Specifies if anti-aliasing is enabled
  52903. */
  52904. fxaaEnabled: boolean;
  52905. /**
  52906. * Specifies the number of steps used to calculate the volumetric lights
  52907. * Typically in interval [50, 200]
  52908. */
  52909. volumetricLightStepsCount: number;
  52910. /**
  52911. * Specifies the number of samples used for the motion blur effect
  52912. * Typically in interval [16, 64]
  52913. */
  52914. motionBlurSamples: number;
  52915. /**
  52916. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52917. */
  52918. samples: number;
  52919. /**
  52920. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  52921. * @constructor
  52922. * @param name The rendering pipeline name
  52923. * @param scene The scene linked to this pipeline
  52924. * @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)
  52925. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  52926. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52927. */
  52928. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  52929. private _buildPipeline;
  52930. private _createDownSampleX4PostProcess;
  52931. private _createBrightPassPostProcess;
  52932. private _createBlurPostProcesses;
  52933. private _createTextureAdderPostProcess;
  52934. private _createVolumetricLightPostProcess;
  52935. private _createLuminancePostProcesses;
  52936. private _createHdrPostProcess;
  52937. private _createLensFlarePostProcess;
  52938. private _createDepthOfFieldPostProcess;
  52939. private _createMotionBlurPostProcess;
  52940. private _getDepthTexture;
  52941. private _disposePostProcesses;
  52942. /**
  52943. * Dispose of the pipeline and stop all post processes
  52944. */
  52945. dispose(): void;
  52946. /**
  52947. * Serialize the rendering pipeline (Used when exporting)
  52948. * @returns the serialized object
  52949. */
  52950. serialize(): any;
  52951. /**
  52952. * Parse the serialized pipeline
  52953. * @param source Source pipeline.
  52954. * @param scene The scene to load the pipeline to.
  52955. * @param rootUrl The URL of the serialized pipeline.
  52956. * @returns An instantiated pipeline from the serialized object.
  52957. */
  52958. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  52959. /**
  52960. * Luminance steps
  52961. */
  52962. static LuminanceSteps: number;
  52963. }
  52964. }
  52965. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  52966. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  52967. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  52968. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  52969. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  52970. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  52971. }
  52972. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  52973. import { Camera } from "babylonjs/Cameras/camera";
  52974. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52975. /**
  52976. * PostProcessRenderPipelineManager class
  52977. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52978. */
  52979. export class PostProcessRenderPipelineManager {
  52980. private _renderPipelines;
  52981. /**
  52982. * Initializes a PostProcessRenderPipelineManager
  52983. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52984. */
  52985. constructor();
  52986. /**
  52987. * Adds a pipeline to the manager
  52988. * @param renderPipeline The pipeline to add
  52989. */
  52990. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52991. /**
  52992. * Attaches a camera to the pipeline
  52993. * @param renderPipelineName The name of the pipeline to attach to
  52994. * @param cameras the camera to attach
  52995. * @param unique if the camera can be attached multiple times to the pipeline
  52996. */
  52997. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52998. /**
  52999. * Detaches a camera from the pipeline
  53000. * @param renderPipelineName The name of the pipeline to detach from
  53001. * @param cameras the camera to detach
  53002. */
  53003. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53004. /**
  53005. * Enables an effect by name on a pipeline
  53006. * @param renderPipelineName the name of the pipeline to enable the effect in
  53007. * @param renderEffectName the name of the effect to enable
  53008. * @param cameras the cameras that the effect should be enabled on
  53009. */
  53010. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53011. /**
  53012. * Disables an effect by name on a pipeline
  53013. * @param renderPipelineName the name of the pipeline to disable the effect in
  53014. * @param renderEffectName the name of the effect to disable
  53015. * @param cameras the cameras that the effect should be disabled on
  53016. */
  53017. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53018. /**
  53019. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53020. */
  53021. update(): void;
  53022. /** @hidden */
  53023. _rebuild(): void;
  53024. /**
  53025. * Disposes of the manager and pipelines
  53026. */
  53027. dispose(): void;
  53028. }
  53029. }
  53030. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53031. import { ISceneComponent } from "babylonjs/sceneComponent";
  53032. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53033. import { Scene } from "babylonjs/scene";
  53034. module "babylonjs/scene" {
  53035. interface Scene {
  53036. /** @hidden (Backing field) */
  53037. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53038. /**
  53039. * Gets the postprocess render pipeline manager
  53040. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53041. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53042. */
  53043. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53044. }
  53045. }
  53046. /**
  53047. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53048. */
  53049. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53050. /**
  53051. * The component name helpfull to identify the component in the list of scene components.
  53052. */
  53053. readonly name: string;
  53054. /**
  53055. * The scene the component belongs to.
  53056. */
  53057. scene: Scene;
  53058. /**
  53059. * Creates a new instance of the component for the given scene
  53060. * @param scene Defines the scene to register the component in
  53061. */
  53062. constructor(scene: Scene);
  53063. /**
  53064. * Registers the component in a given scene
  53065. */
  53066. register(): void;
  53067. /**
  53068. * Rebuilds the elements related to this component in case of
  53069. * context lost for instance.
  53070. */
  53071. rebuild(): void;
  53072. /**
  53073. * Disposes the component and the associated ressources
  53074. */
  53075. dispose(): void;
  53076. private _gatherRenderTargets;
  53077. }
  53078. }
  53079. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  53080. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  53081. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53082. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53083. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53084. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53085. }
  53086. declare module "babylonjs/Shaders/tonemap.fragment" {
  53087. /** @hidden */
  53088. export var tonemapPixelShader: {
  53089. name: string;
  53090. shader: string;
  53091. };
  53092. }
  53093. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  53094. import { Camera } from "babylonjs/Cameras/camera";
  53095. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53096. import "babylonjs/Shaders/tonemap.fragment";
  53097. import { Engine } from "babylonjs/Engines/engine";
  53098. /** Defines operator used for tonemapping */
  53099. export enum TonemappingOperator {
  53100. /** Hable */
  53101. Hable = 0,
  53102. /** Reinhard */
  53103. Reinhard = 1,
  53104. /** HejiDawson */
  53105. HejiDawson = 2,
  53106. /** Photographic */
  53107. Photographic = 3
  53108. }
  53109. /**
  53110. * Defines a post process to apply tone mapping
  53111. */
  53112. export class TonemapPostProcess extends PostProcess {
  53113. private _operator;
  53114. /** Defines the required exposure adjustement */
  53115. exposureAdjustment: number;
  53116. /**
  53117. * Creates a new TonemapPostProcess
  53118. * @param name defines the name of the postprocess
  53119. * @param _operator defines the operator to use
  53120. * @param exposureAdjustment defines the required exposure adjustement
  53121. * @param camera defines the camera to use (can be null)
  53122. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53123. * @param engine defines the hosting engine (can be ignore if camera is set)
  53124. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53125. */
  53126. constructor(name: string, _operator: TonemappingOperator,
  53127. /** Defines the required exposure adjustement */
  53128. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53129. }
  53130. }
  53131. declare module "babylonjs/Shaders/depth.vertex" {
  53132. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53133. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53134. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53135. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53136. /** @hidden */
  53137. export var depthVertexShader: {
  53138. name: string;
  53139. shader: string;
  53140. };
  53141. }
  53142. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  53143. /** @hidden */
  53144. export var volumetricLightScatteringPixelShader: {
  53145. name: string;
  53146. shader: string;
  53147. };
  53148. }
  53149. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  53150. /** @hidden */
  53151. export var volumetricLightScatteringPassPixelShader: {
  53152. name: string;
  53153. shader: string;
  53154. };
  53155. }
  53156. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  53157. import { Vector3 } from "babylonjs/Maths/math";
  53158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53159. import { Mesh } from "babylonjs/Meshes/mesh";
  53160. import { Camera } from "babylonjs/Cameras/camera";
  53161. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53162. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53163. import { Scene } from "babylonjs/scene";
  53164. import "babylonjs/Shaders/depth.vertex";
  53165. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  53166. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  53167. import { Engine } from "babylonjs/Engines/engine";
  53168. /**
  53169. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53170. */
  53171. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53172. private _volumetricLightScatteringPass;
  53173. private _volumetricLightScatteringRTT;
  53174. private _viewPort;
  53175. private _screenCoordinates;
  53176. private _cachedDefines;
  53177. /**
  53178. * If not undefined, the mesh position is computed from the attached node position
  53179. */
  53180. attachedNode: {
  53181. position: Vector3;
  53182. };
  53183. /**
  53184. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53185. */
  53186. customMeshPosition: Vector3;
  53187. /**
  53188. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53189. */
  53190. useCustomMeshPosition: boolean;
  53191. /**
  53192. * If the post-process should inverse the light scattering direction
  53193. */
  53194. invert: boolean;
  53195. /**
  53196. * The internal mesh used by the post-process
  53197. */
  53198. mesh: Mesh;
  53199. /**
  53200. * @hidden
  53201. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53202. */
  53203. useDiffuseColor: boolean;
  53204. /**
  53205. * Array containing the excluded meshes not rendered in the internal pass
  53206. */
  53207. excludedMeshes: AbstractMesh[];
  53208. /**
  53209. * Controls the overall intensity of the post-process
  53210. */
  53211. exposure: number;
  53212. /**
  53213. * Dissipates each sample's contribution in range [0, 1]
  53214. */
  53215. decay: number;
  53216. /**
  53217. * Controls the overall intensity of each sample
  53218. */
  53219. weight: number;
  53220. /**
  53221. * Controls the density of each sample
  53222. */
  53223. density: number;
  53224. /**
  53225. * @constructor
  53226. * @param name The post-process name
  53227. * @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)
  53228. * @param camera The camera that the post-process will be attached to
  53229. * @param mesh The mesh used to create the light scattering
  53230. * @param samples The post-process quality, default 100
  53231. * @param samplingModeThe post-process filtering mode
  53232. * @param engine The babylon engine
  53233. * @param reusable If the post-process is reusable
  53234. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53235. */
  53236. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53237. /**
  53238. * Returns the string "VolumetricLightScatteringPostProcess"
  53239. * @returns "VolumetricLightScatteringPostProcess"
  53240. */
  53241. getClassName(): string;
  53242. private _isReady;
  53243. /**
  53244. * Sets the new light position for light scattering effect
  53245. * @param position The new custom light position
  53246. */
  53247. setCustomMeshPosition(position: Vector3): void;
  53248. /**
  53249. * Returns the light position for light scattering effect
  53250. * @return Vector3 The custom light position
  53251. */
  53252. getCustomMeshPosition(): Vector3;
  53253. /**
  53254. * Disposes the internal assets and detaches the post-process from the camera
  53255. */
  53256. dispose(camera: Camera): void;
  53257. /**
  53258. * Returns the render target texture used by the post-process
  53259. * @return the render target texture used by the post-process
  53260. */
  53261. getPass(): RenderTargetTexture;
  53262. private _meshExcluded;
  53263. private _createPass;
  53264. private _updateMeshScreenCoordinates;
  53265. /**
  53266. * Creates a default mesh for the Volumeric Light Scattering post-process
  53267. * @param name The mesh name
  53268. * @param scene The scene where to create the mesh
  53269. * @return the default mesh
  53270. */
  53271. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53272. }
  53273. }
  53274. declare module "babylonjs/PostProcesses/index" {
  53275. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  53276. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  53277. export * from "babylonjs/PostProcesses/bloomEffect";
  53278. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  53279. export * from "babylonjs/PostProcesses/blurPostProcess";
  53280. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53281. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  53282. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  53283. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  53284. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53285. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  53286. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  53287. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  53288. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53289. export * from "babylonjs/PostProcesses/filterPostProcess";
  53290. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  53291. export * from "babylonjs/PostProcesses/grainPostProcess";
  53292. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  53293. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53294. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  53295. export * from "babylonjs/PostProcesses/passPostProcess";
  53296. export * from "babylonjs/PostProcesses/postProcess";
  53297. export * from "babylonjs/PostProcesses/postProcessManager";
  53298. export * from "babylonjs/PostProcesses/refractionPostProcess";
  53299. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  53300. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  53301. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  53302. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  53303. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  53304. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  53305. }
  53306. declare module "babylonjs/Probes/index" {
  53307. export * from "babylonjs/Probes/reflectionProbe";
  53308. }
  53309. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  53310. import { Scene } from "babylonjs/scene";
  53311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53312. import { Color3 } from "babylonjs/Maths/math";
  53313. import { SmartArray } from "babylonjs/Misc/smartArray";
  53314. import { ISceneComponent } from "babylonjs/sceneComponent";
  53315. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  53316. import "babylonjs/Shaders/color.fragment";
  53317. import "babylonjs/Shaders/color.vertex";
  53318. module "babylonjs/scene" {
  53319. interface Scene {
  53320. /** @hidden (Backing field) */
  53321. _boundingBoxRenderer: BoundingBoxRenderer;
  53322. /** @hidden (Backing field) */
  53323. _forceShowBoundingBoxes: boolean;
  53324. /**
  53325. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53326. */
  53327. forceShowBoundingBoxes: boolean;
  53328. /**
  53329. * Gets the bounding box renderer associated with the scene
  53330. * @returns a BoundingBoxRenderer
  53331. */
  53332. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53333. }
  53334. }
  53335. module "babylonjs/Meshes/abstractMesh" {
  53336. interface AbstractMesh {
  53337. /** @hidden (Backing field) */
  53338. _showBoundingBox: boolean;
  53339. /**
  53340. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53341. */
  53342. showBoundingBox: boolean;
  53343. }
  53344. }
  53345. /**
  53346. * Component responsible of rendering the bounding box of the meshes in a scene.
  53347. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53348. */
  53349. export class BoundingBoxRenderer implements ISceneComponent {
  53350. /**
  53351. * The component name helpfull to identify the component in the list of scene components.
  53352. */
  53353. readonly name: string;
  53354. /**
  53355. * The scene the component belongs to.
  53356. */
  53357. scene: Scene;
  53358. /**
  53359. * Color of the bounding box lines placed in front of an object
  53360. */
  53361. frontColor: Color3;
  53362. /**
  53363. * Color of the bounding box lines placed behind an object
  53364. */
  53365. backColor: Color3;
  53366. /**
  53367. * Defines if the renderer should show the back lines or not
  53368. */
  53369. showBackLines: boolean;
  53370. /**
  53371. * @hidden
  53372. */
  53373. renderList: SmartArray<BoundingBox>;
  53374. private _colorShader;
  53375. private _vertexBuffers;
  53376. private _indexBuffer;
  53377. /**
  53378. * Instantiates a new bounding box renderer in a scene.
  53379. * @param scene the scene the renderer renders in
  53380. */
  53381. constructor(scene: Scene);
  53382. /**
  53383. * Registers the component in a given scene
  53384. */
  53385. register(): void;
  53386. private _evaluateSubMesh;
  53387. private _activeMesh;
  53388. private _prepareRessources;
  53389. private _createIndexBuffer;
  53390. /**
  53391. * Rebuilds the elements related to this component in case of
  53392. * context lost for instance.
  53393. */
  53394. rebuild(): void;
  53395. /**
  53396. * @hidden
  53397. */
  53398. reset(): void;
  53399. /**
  53400. * Render the bounding boxes of a specific rendering group
  53401. * @param renderingGroupId defines the rendering group to render
  53402. */
  53403. render(renderingGroupId: number): void;
  53404. /**
  53405. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53406. * @param mesh Define the mesh to render the occlusion bounding box for
  53407. */
  53408. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53409. /**
  53410. * Dispose and release the resources attached to this renderer.
  53411. */
  53412. dispose(): void;
  53413. }
  53414. }
  53415. declare module "babylonjs/Shaders/depth.fragment" {
  53416. /** @hidden */
  53417. export var depthPixelShader: {
  53418. name: string;
  53419. shader: string;
  53420. };
  53421. }
  53422. declare module "babylonjs/Rendering/depthRenderer" {
  53423. import { Nullable } from "babylonjs/types";
  53424. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53425. import { Scene } from "babylonjs/scene";
  53426. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53427. import { Camera } from "babylonjs/Cameras/camera";
  53428. import "babylonjs/Shaders/depth.fragment";
  53429. import "babylonjs/Shaders/depth.vertex";
  53430. /**
  53431. * This represents a depth renderer in Babylon.
  53432. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53433. */
  53434. export class DepthRenderer {
  53435. private _scene;
  53436. private _depthMap;
  53437. private _effect;
  53438. private _cachedDefines;
  53439. private _camera;
  53440. /**
  53441. * Specifiess that the depth renderer will only be used within
  53442. * the camera it is created for.
  53443. * This can help forcing its rendering during the camera processing.
  53444. */
  53445. useOnlyInActiveCamera: boolean;
  53446. /** @hidden */
  53447. static _SceneComponentInitialization: (scene: Scene) => void;
  53448. /**
  53449. * Instantiates a depth renderer
  53450. * @param scene The scene the renderer belongs to
  53451. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53452. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53453. */
  53454. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53455. /**
  53456. * Creates the depth rendering effect and checks if the effect is ready.
  53457. * @param subMesh The submesh to be used to render the depth map of
  53458. * @param useInstances If multiple world instances should be used
  53459. * @returns if the depth renderer is ready to render the depth map
  53460. */
  53461. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53462. /**
  53463. * Gets the texture which the depth map will be written to.
  53464. * @returns The depth map texture
  53465. */
  53466. getDepthMap(): RenderTargetTexture;
  53467. /**
  53468. * Disposes of the depth renderer.
  53469. */
  53470. dispose(): void;
  53471. }
  53472. }
  53473. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  53474. import { Nullable } from "babylonjs/types";
  53475. import { Scene } from "babylonjs/scene";
  53476. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  53477. import { Camera } from "babylonjs/Cameras/camera";
  53478. import { ISceneComponent } from "babylonjs/sceneComponent";
  53479. module "babylonjs/scene" {
  53480. interface Scene {
  53481. /** @hidden (Backing field) */
  53482. _depthRenderer: {
  53483. [id: string]: DepthRenderer;
  53484. };
  53485. /**
  53486. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53487. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53488. * @returns the created depth renderer
  53489. */
  53490. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53491. /**
  53492. * Disables a depth renderer for a given camera
  53493. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53494. */
  53495. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53496. }
  53497. }
  53498. /**
  53499. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  53500. * in several rendering techniques.
  53501. */
  53502. export class DepthRendererSceneComponent implements ISceneComponent {
  53503. /**
  53504. * The component name helpfull to identify the component in the list of scene components.
  53505. */
  53506. readonly name: string;
  53507. /**
  53508. * The scene the component belongs to.
  53509. */
  53510. scene: Scene;
  53511. /**
  53512. * Creates a new instance of the component for the given scene
  53513. * @param scene Defines the scene to register the component in
  53514. */
  53515. constructor(scene: Scene);
  53516. /**
  53517. * Registers the component in a given scene
  53518. */
  53519. register(): void;
  53520. /**
  53521. * Rebuilds the elements related to this component in case of
  53522. * context lost for instance.
  53523. */
  53524. rebuild(): void;
  53525. /**
  53526. * Disposes the component and the associated ressources
  53527. */
  53528. dispose(): void;
  53529. private _gatherRenderTargets;
  53530. private _gatherActiveCameraRenderTargets;
  53531. }
  53532. }
  53533. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53534. import { Nullable } from "babylonjs/types";
  53535. import { Scene } from "babylonjs/scene";
  53536. import { ISceneComponent } from "babylonjs/sceneComponent";
  53537. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53538. module "babylonjs/scene" {
  53539. interface Scene {
  53540. /** @hidden (Backing field) */
  53541. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53542. /**
  53543. * Gets or Sets the current geometry buffer associated to the scene.
  53544. */
  53545. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53546. /**
  53547. * Enables a GeometryBufferRender and associates it with the scene
  53548. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53549. * @returns the GeometryBufferRenderer
  53550. */
  53551. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53552. /**
  53553. * Disables the GeometryBufferRender associated with the scene
  53554. */
  53555. disableGeometryBufferRenderer(): void;
  53556. }
  53557. }
  53558. /**
  53559. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53560. * in several rendering techniques.
  53561. */
  53562. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53563. /**
  53564. * The component name helpful to identify the component in the list of scene components.
  53565. */
  53566. readonly name: string;
  53567. /**
  53568. * The scene the component belongs to.
  53569. */
  53570. scene: Scene;
  53571. /**
  53572. * Creates a new instance of the component for the given scene
  53573. * @param scene Defines the scene to register the component in
  53574. */
  53575. constructor(scene: Scene);
  53576. /**
  53577. * Registers the component in a given scene
  53578. */
  53579. register(): void;
  53580. /**
  53581. * Rebuilds the elements related to this component in case of
  53582. * context lost for instance.
  53583. */
  53584. rebuild(): void;
  53585. /**
  53586. * Disposes the component and the associated ressources
  53587. */
  53588. dispose(): void;
  53589. private _gatherRenderTargets;
  53590. }
  53591. }
  53592. declare module "babylonjs/Shaders/outline.fragment" {
  53593. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53594. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53595. /** @hidden */
  53596. export var outlinePixelShader: {
  53597. name: string;
  53598. shader: string;
  53599. };
  53600. }
  53601. declare module "babylonjs/Shaders/outline.vertex" {
  53602. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53603. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53604. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53605. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53606. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53607. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53608. /** @hidden */
  53609. export var outlineVertexShader: {
  53610. name: string;
  53611. shader: string;
  53612. };
  53613. }
  53614. declare module "babylonjs/Rendering/outlineRenderer" {
  53615. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53616. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  53617. import { Scene } from "babylonjs/scene";
  53618. import { ISceneComponent } from "babylonjs/sceneComponent";
  53619. import "babylonjs/Shaders/outline.fragment";
  53620. import "babylonjs/Shaders/outline.vertex";
  53621. module "babylonjs/scene" {
  53622. interface Scene {
  53623. /** @hidden */
  53624. _outlineRenderer: OutlineRenderer;
  53625. /**
  53626. * Gets the outline renderer associated with the scene
  53627. * @returns a OutlineRenderer
  53628. */
  53629. getOutlineRenderer(): OutlineRenderer;
  53630. }
  53631. }
  53632. module "babylonjs/Meshes/abstractMesh" {
  53633. interface AbstractMesh {
  53634. /** @hidden (Backing field) */
  53635. _renderOutline: boolean;
  53636. /**
  53637. * Gets or sets a boolean indicating if the outline must be rendered as well
  53638. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  53639. */
  53640. renderOutline: boolean;
  53641. /** @hidden (Backing field) */
  53642. _renderOverlay: boolean;
  53643. /**
  53644. * Gets or sets a boolean indicating if the overlay must be rendered as well
  53645. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  53646. */
  53647. renderOverlay: boolean;
  53648. }
  53649. }
  53650. /**
  53651. * This class is responsible to draw bothe outline/overlay of meshes.
  53652. * It should not be used directly but through the available method on mesh.
  53653. */
  53654. export class OutlineRenderer implements ISceneComponent {
  53655. /**
  53656. * The name of the component. Each component must have a unique name.
  53657. */
  53658. name: string;
  53659. /**
  53660. * The scene the component belongs to.
  53661. */
  53662. scene: Scene;
  53663. /**
  53664. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  53665. */
  53666. zOffset: number;
  53667. private _engine;
  53668. private _effect;
  53669. private _cachedDefines;
  53670. private _savedDepthWrite;
  53671. /**
  53672. * Instantiates a new outline renderer. (There could be only one per scene).
  53673. * @param scene Defines the scene it belongs to
  53674. */
  53675. constructor(scene: Scene);
  53676. /**
  53677. * Register the component to one instance of a scene.
  53678. */
  53679. register(): void;
  53680. /**
  53681. * Rebuilds the elements related to this component in case of
  53682. * context lost for instance.
  53683. */
  53684. rebuild(): void;
  53685. /**
  53686. * Disposes the component and the associated ressources.
  53687. */
  53688. dispose(): void;
  53689. /**
  53690. * Renders the outline in the canvas.
  53691. * @param subMesh Defines the sumesh to render
  53692. * @param batch Defines the batch of meshes in case of instances
  53693. * @param useOverlay Defines if the rendering is for the overlay or the outline
  53694. */
  53695. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  53696. /**
  53697. * Returns whether or not the outline renderer is ready for a given submesh.
  53698. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  53699. * @param subMesh Defines the submesh to check readyness for
  53700. * @param useInstances Defines wheter wee are trying to render instances or not
  53701. * @returns true if ready otherwise false
  53702. */
  53703. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53704. private _beforeRenderingMesh;
  53705. private _afterRenderingMesh;
  53706. }
  53707. }
  53708. declare module "babylonjs/Rendering/index" {
  53709. export * from "babylonjs/Rendering/boundingBoxRenderer";
  53710. export * from "babylonjs/Rendering/depthRenderer";
  53711. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  53712. export * from "babylonjs/Rendering/edgesRenderer";
  53713. export * from "babylonjs/Rendering/geometryBufferRenderer";
  53714. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53715. export * from "babylonjs/Rendering/outlineRenderer";
  53716. export * from "babylonjs/Rendering/renderingGroup";
  53717. export * from "babylonjs/Rendering/renderingManager";
  53718. export * from "babylonjs/Rendering/utilityLayerRenderer";
  53719. }
  53720. declare module "babylonjs/Sprites/index" {
  53721. export * from "babylonjs/Sprites/sprite";
  53722. export * from "babylonjs/Sprites/spriteManager";
  53723. export * from "babylonjs/Sprites/spriteSceneComponent";
  53724. }
  53725. declare module "babylonjs/Misc/assetsManager" {
  53726. import { Scene } from "babylonjs/scene";
  53727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53728. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53729. import { Skeleton } from "babylonjs/Bones/skeleton";
  53730. import { Observable } from "babylonjs/Misc/observable";
  53731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53732. import { Texture } from "babylonjs/Materials/Textures/texture";
  53733. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53734. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  53735. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  53736. /**
  53737. * Defines the list of states available for a task inside a AssetsManager
  53738. */
  53739. export enum AssetTaskState {
  53740. /**
  53741. * Initialization
  53742. */
  53743. INIT = 0,
  53744. /**
  53745. * Running
  53746. */
  53747. RUNNING = 1,
  53748. /**
  53749. * Done
  53750. */
  53751. DONE = 2,
  53752. /**
  53753. * Error
  53754. */
  53755. ERROR = 3
  53756. }
  53757. /**
  53758. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  53759. */
  53760. export abstract class AbstractAssetTask {
  53761. /**
  53762. * Task name
  53763. */ name: string;
  53764. /**
  53765. * Callback called when the task is successful
  53766. */
  53767. onSuccess: (task: any) => void;
  53768. /**
  53769. * Callback called when the task is not successful
  53770. */
  53771. onError: (task: any, message?: string, exception?: any) => void;
  53772. /**
  53773. * Creates a new AssetsManager
  53774. * @param name defines the name of the task
  53775. */
  53776. constructor(
  53777. /**
  53778. * Task name
  53779. */ name: string);
  53780. private _isCompleted;
  53781. private _taskState;
  53782. private _errorObject;
  53783. /**
  53784. * Get if the task is completed
  53785. */
  53786. readonly isCompleted: boolean;
  53787. /**
  53788. * Gets the current state of the task
  53789. */
  53790. readonly taskState: AssetTaskState;
  53791. /**
  53792. * Gets the current error object (if task is in error)
  53793. */
  53794. readonly errorObject: {
  53795. message?: string;
  53796. exception?: any;
  53797. };
  53798. /**
  53799. * Internal only
  53800. * @hidden
  53801. */
  53802. _setErrorObject(message?: string, exception?: any): void;
  53803. /**
  53804. * Execute the current task
  53805. * @param scene defines the scene where you want your assets to be loaded
  53806. * @param onSuccess is a callback called when the task is successfully executed
  53807. * @param onError is a callback called if an error occurs
  53808. */
  53809. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53810. /**
  53811. * Execute the current task
  53812. * @param scene defines the scene where you want your assets to be loaded
  53813. * @param onSuccess is a callback called when the task is successfully executed
  53814. * @param onError is a callback called if an error occurs
  53815. */
  53816. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53817. /**
  53818. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  53819. * This can be used with failed tasks that have the reason for failure fixed.
  53820. */
  53821. reset(): void;
  53822. private onErrorCallback;
  53823. private onDoneCallback;
  53824. }
  53825. /**
  53826. * Define the interface used by progress events raised during assets loading
  53827. */
  53828. export interface IAssetsProgressEvent {
  53829. /**
  53830. * Defines the number of remaining tasks to process
  53831. */
  53832. remainingCount: number;
  53833. /**
  53834. * Defines the total number of tasks
  53835. */
  53836. totalCount: number;
  53837. /**
  53838. * Defines the task that was just processed
  53839. */
  53840. task: AbstractAssetTask;
  53841. }
  53842. /**
  53843. * Class used to share progress information about assets loading
  53844. */
  53845. export class AssetsProgressEvent implements IAssetsProgressEvent {
  53846. /**
  53847. * Defines the number of remaining tasks to process
  53848. */
  53849. remainingCount: number;
  53850. /**
  53851. * Defines the total number of tasks
  53852. */
  53853. totalCount: number;
  53854. /**
  53855. * Defines the task that was just processed
  53856. */
  53857. task: AbstractAssetTask;
  53858. /**
  53859. * Creates a AssetsProgressEvent
  53860. * @param remainingCount defines the number of remaining tasks to process
  53861. * @param totalCount defines the total number of tasks
  53862. * @param task defines the task that was just processed
  53863. */
  53864. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  53865. }
  53866. /**
  53867. * Define a task used by AssetsManager to load meshes
  53868. */
  53869. export class MeshAssetTask extends AbstractAssetTask {
  53870. /**
  53871. * Defines the name of the task
  53872. */
  53873. name: string;
  53874. /**
  53875. * Defines the list of mesh's names you want to load
  53876. */
  53877. meshesNames: any;
  53878. /**
  53879. * Defines the root url to use as a base to load your meshes and associated resources
  53880. */
  53881. rootUrl: string;
  53882. /**
  53883. * Defines the filename of the scene to load from
  53884. */
  53885. sceneFilename: string;
  53886. /**
  53887. * Gets the list of loaded meshes
  53888. */
  53889. loadedMeshes: Array<AbstractMesh>;
  53890. /**
  53891. * Gets the list of loaded particle systems
  53892. */
  53893. loadedParticleSystems: Array<IParticleSystem>;
  53894. /**
  53895. * Gets the list of loaded skeletons
  53896. */
  53897. loadedSkeletons: Array<Skeleton>;
  53898. /**
  53899. * Gets the list of loaded animation groups
  53900. */
  53901. loadedAnimationGroups: Array<AnimationGroup>;
  53902. /**
  53903. * Callback called when the task is successful
  53904. */
  53905. onSuccess: (task: MeshAssetTask) => void;
  53906. /**
  53907. * Callback called when the task is successful
  53908. */
  53909. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  53910. /**
  53911. * Creates a new MeshAssetTask
  53912. * @param name defines the name of the task
  53913. * @param meshesNames defines the list of mesh's names you want to load
  53914. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  53915. * @param sceneFilename defines the filename of the scene to load from
  53916. */
  53917. constructor(
  53918. /**
  53919. * Defines the name of the task
  53920. */
  53921. name: string,
  53922. /**
  53923. * Defines the list of mesh's names you want to load
  53924. */
  53925. meshesNames: any,
  53926. /**
  53927. * Defines the root url to use as a base to load your meshes and associated resources
  53928. */
  53929. rootUrl: string,
  53930. /**
  53931. * Defines the filename of the scene to load from
  53932. */
  53933. sceneFilename: string);
  53934. /**
  53935. * Execute the current task
  53936. * @param scene defines the scene where you want your assets to be loaded
  53937. * @param onSuccess is a callback called when the task is successfully executed
  53938. * @param onError is a callback called if an error occurs
  53939. */
  53940. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53941. }
  53942. /**
  53943. * Define a task used by AssetsManager to load text content
  53944. */
  53945. export class TextFileAssetTask extends AbstractAssetTask {
  53946. /**
  53947. * Defines the name of the task
  53948. */
  53949. name: string;
  53950. /**
  53951. * Defines the location of the file to load
  53952. */
  53953. url: string;
  53954. /**
  53955. * Gets the loaded text string
  53956. */
  53957. text: string;
  53958. /**
  53959. * Callback called when the task is successful
  53960. */
  53961. onSuccess: (task: TextFileAssetTask) => void;
  53962. /**
  53963. * Callback called when the task is successful
  53964. */
  53965. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  53966. /**
  53967. * Creates a new TextFileAssetTask object
  53968. * @param name defines the name of the task
  53969. * @param url defines the location of the file to load
  53970. */
  53971. constructor(
  53972. /**
  53973. * Defines the name of the task
  53974. */
  53975. name: string,
  53976. /**
  53977. * Defines the location of the file to load
  53978. */
  53979. url: string);
  53980. /**
  53981. * Execute the current task
  53982. * @param scene defines the scene where you want your assets to be loaded
  53983. * @param onSuccess is a callback called when the task is successfully executed
  53984. * @param onError is a callback called if an error occurs
  53985. */
  53986. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53987. }
  53988. /**
  53989. * Define a task used by AssetsManager to load binary data
  53990. */
  53991. export class BinaryFileAssetTask extends AbstractAssetTask {
  53992. /**
  53993. * Defines the name of the task
  53994. */
  53995. name: string;
  53996. /**
  53997. * Defines the location of the file to load
  53998. */
  53999. url: string;
  54000. /**
  54001. * Gets the lodaded data (as an array buffer)
  54002. */
  54003. data: ArrayBuffer;
  54004. /**
  54005. * Callback called when the task is successful
  54006. */
  54007. onSuccess: (task: BinaryFileAssetTask) => void;
  54008. /**
  54009. * Callback called when the task is successful
  54010. */
  54011. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54012. /**
  54013. * Creates a new BinaryFileAssetTask object
  54014. * @param name defines the name of the new task
  54015. * @param url defines the location of the file to load
  54016. */
  54017. constructor(
  54018. /**
  54019. * Defines the name of the task
  54020. */
  54021. name: string,
  54022. /**
  54023. * Defines the location of the file to load
  54024. */
  54025. url: string);
  54026. /**
  54027. * Execute the current task
  54028. * @param scene defines the scene where you want your assets to be loaded
  54029. * @param onSuccess is a callback called when the task is successfully executed
  54030. * @param onError is a callback called if an error occurs
  54031. */
  54032. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54033. }
  54034. /**
  54035. * Define a task used by AssetsManager to load images
  54036. */
  54037. export class ImageAssetTask extends AbstractAssetTask {
  54038. /**
  54039. * Defines the name of the task
  54040. */
  54041. name: string;
  54042. /**
  54043. * Defines the location of the image to load
  54044. */
  54045. url: string;
  54046. /**
  54047. * Gets the loaded images
  54048. */
  54049. image: HTMLImageElement;
  54050. /**
  54051. * Callback called when the task is successful
  54052. */
  54053. onSuccess: (task: ImageAssetTask) => void;
  54054. /**
  54055. * Callback called when the task is successful
  54056. */
  54057. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54058. /**
  54059. * Creates a new ImageAssetTask
  54060. * @param name defines the name of the task
  54061. * @param url defines the location of the image to load
  54062. */
  54063. constructor(
  54064. /**
  54065. * Defines the name of the task
  54066. */
  54067. name: string,
  54068. /**
  54069. * Defines the location of the image to load
  54070. */
  54071. url: string);
  54072. /**
  54073. * Execute the current task
  54074. * @param scene defines the scene where you want your assets to be loaded
  54075. * @param onSuccess is a callback called when the task is successfully executed
  54076. * @param onError is a callback called if an error occurs
  54077. */
  54078. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54079. }
  54080. /**
  54081. * Defines the interface used by texture loading tasks
  54082. */
  54083. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54084. /**
  54085. * Gets the loaded texture
  54086. */
  54087. texture: TEX;
  54088. }
  54089. /**
  54090. * Define a task used by AssetsManager to load 2D textures
  54091. */
  54092. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54093. /**
  54094. * Defines the name of the task
  54095. */
  54096. name: string;
  54097. /**
  54098. * Defines the location of the file to load
  54099. */
  54100. url: string;
  54101. /**
  54102. * Defines if mipmap should not be generated (default is false)
  54103. */
  54104. noMipmap?: boolean | undefined;
  54105. /**
  54106. * Defines if texture must be inverted on Y axis (default is false)
  54107. */
  54108. invertY?: boolean | undefined;
  54109. /**
  54110. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54111. */
  54112. samplingMode: number;
  54113. /**
  54114. * Gets the loaded texture
  54115. */
  54116. texture: Texture;
  54117. /**
  54118. * Callback called when the task is successful
  54119. */
  54120. onSuccess: (task: TextureAssetTask) => void;
  54121. /**
  54122. * Callback called when the task is successful
  54123. */
  54124. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54125. /**
  54126. * Creates a new TextureAssetTask object
  54127. * @param name defines the name of the task
  54128. * @param url defines the location of the file to load
  54129. * @param noMipmap defines if mipmap should not be generated (default is false)
  54130. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54131. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54132. */
  54133. constructor(
  54134. /**
  54135. * Defines the name of the task
  54136. */
  54137. name: string,
  54138. /**
  54139. * Defines the location of the file to load
  54140. */
  54141. url: string,
  54142. /**
  54143. * Defines if mipmap should not be generated (default is false)
  54144. */
  54145. noMipmap?: boolean | undefined,
  54146. /**
  54147. * Defines if texture must be inverted on Y axis (default is false)
  54148. */
  54149. invertY?: boolean | undefined,
  54150. /**
  54151. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54152. */
  54153. samplingMode?: number);
  54154. /**
  54155. * Execute the current task
  54156. * @param scene defines the scene where you want your assets to be loaded
  54157. * @param onSuccess is a callback called when the task is successfully executed
  54158. * @param onError is a callback called if an error occurs
  54159. */
  54160. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54161. }
  54162. /**
  54163. * Define a task used by AssetsManager to load cube textures
  54164. */
  54165. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54166. /**
  54167. * Defines the name of the task
  54168. */
  54169. name: string;
  54170. /**
  54171. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54172. */
  54173. url: string;
  54174. /**
  54175. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54176. */
  54177. extensions?: string[] | undefined;
  54178. /**
  54179. * Defines if mipmaps should not be generated (default is false)
  54180. */
  54181. noMipmap?: boolean | undefined;
  54182. /**
  54183. * Defines the explicit list of files (undefined by default)
  54184. */
  54185. files?: string[] | undefined;
  54186. /**
  54187. * Gets the loaded texture
  54188. */
  54189. texture: CubeTexture;
  54190. /**
  54191. * Callback called when the task is successful
  54192. */
  54193. onSuccess: (task: CubeTextureAssetTask) => void;
  54194. /**
  54195. * Callback called when the task is successful
  54196. */
  54197. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54198. /**
  54199. * Creates a new CubeTextureAssetTask
  54200. * @param name defines the name of the task
  54201. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54202. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54203. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54204. * @param files defines the explicit list of files (undefined by default)
  54205. */
  54206. constructor(
  54207. /**
  54208. * Defines the name of the task
  54209. */
  54210. name: string,
  54211. /**
  54212. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54213. */
  54214. url: string,
  54215. /**
  54216. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54217. */
  54218. extensions?: string[] | undefined,
  54219. /**
  54220. * Defines if mipmaps should not be generated (default is false)
  54221. */
  54222. noMipmap?: boolean | undefined,
  54223. /**
  54224. * Defines the explicit list of files (undefined by default)
  54225. */
  54226. files?: string[] | undefined);
  54227. /**
  54228. * Execute the current task
  54229. * @param scene defines the scene where you want your assets to be loaded
  54230. * @param onSuccess is a callback called when the task is successfully executed
  54231. * @param onError is a callback called if an error occurs
  54232. */
  54233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54234. }
  54235. /**
  54236. * Define a task used by AssetsManager to load HDR cube textures
  54237. */
  54238. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54239. /**
  54240. * Defines the name of the task
  54241. */
  54242. name: string;
  54243. /**
  54244. * Defines the location of the file to load
  54245. */
  54246. url: string;
  54247. /**
  54248. * Defines the desired size (the more it increases the longer the generation will be)
  54249. */
  54250. size: number;
  54251. /**
  54252. * Defines if mipmaps should not be generated (default is false)
  54253. */
  54254. noMipmap: boolean;
  54255. /**
  54256. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54257. */
  54258. generateHarmonics: boolean;
  54259. /**
  54260. * 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)
  54261. */
  54262. gammaSpace: boolean;
  54263. /**
  54264. * Internal Use Only
  54265. */
  54266. reserved: boolean;
  54267. /**
  54268. * Gets the loaded texture
  54269. */
  54270. texture: HDRCubeTexture;
  54271. /**
  54272. * Callback called when the task is successful
  54273. */
  54274. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54275. /**
  54276. * Callback called when the task is successful
  54277. */
  54278. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54279. /**
  54280. * Creates a new HDRCubeTextureAssetTask object
  54281. * @param name defines the name of the task
  54282. * @param url defines the location of the file to load
  54283. * @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.
  54284. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54285. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54286. * @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)
  54287. * @param reserved Internal use only
  54288. */
  54289. constructor(
  54290. /**
  54291. * Defines the name of the task
  54292. */
  54293. name: string,
  54294. /**
  54295. * Defines the location of the file to load
  54296. */
  54297. url: string,
  54298. /**
  54299. * Defines the desired size (the more it increases the longer the generation will be)
  54300. */
  54301. size: number,
  54302. /**
  54303. * Defines if mipmaps should not be generated (default is false)
  54304. */
  54305. noMipmap?: boolean,
  54306. /**
  54307. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54308. */
  54309. generateHarmonics?: boolean,
  54310. /**
  54311. * 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)
  54312. */
  54313. gammaSpace?: boolean,
  54314. /**
  54315. * Internal Use Only
  54316. */
  54317. reserved?: boolean);
  54318. /**
  54319. * Execute the current task
  54320. * @param scene defines the scene where you want your assets to be loaded
  54321. * @param onSuccess is a callback called when the task is successfully executed
  54322. * @param onError is a callback called if an error occurs
  54323. */
  54324. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54325. }
  54326. /**
  54327. * This class can be used to easily import assets into a scene
  54328. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54329. */
  54330. export class AssetsManager {
  54331. private _scene;
  54332. private _isLoading;
  54333. protected _tasks: AbstractAssetTask[];
  54334. protected _waitingTasksCount: number;
  54335. protected _totalTasksCount: number;
  54336. /**
  54337. * Callback called when all tasks are processed
  54338. */
  54339. onFinish: (tasks: AbstractAssetTask[]) => void;
  54340. /**
  54341. * Callback called when a task is successful
  54342. */
  54343. onTaskSuccess: (task: AbstractAssetTask) => void;
  54344. /**
  54345. * Callback called when a task had an error
  54346. */
  54347. onTaskError: (task: AbstractAssetTask) => void;
  54348. /**
  54349. * Callback called when a task is done (whatever the result is)
  54350. */
  54351. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54352. /**
  54353. * Observable called when all tasks are processed
  54354. */
  54355. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54356. /**
  54357. * Observable called when a task had an error
  54358. */
  54359. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54360. /**
  54361. * Observable called when a task is successful
  54362. */
  54363. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54364. /**
  54365. * Observable called when a task is done (whatever the result is)
  54366. */
  54367. onProgressObservable: Observable<IAssetsProgressEvent>;
  54368. /**
  54369. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54370. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54371. */
  54372. useDefaultLoadingScreen: boolean;
  54373. /**
  54374. * Creates a new AssetsManager
  54375. * @param scene defines the scene to work on
  54376. */
  54377. constructor(scene: Scene);
  54378. /**
  54379. * Add a MeshAssetTask to the list of active tasks
  54380. * @param taskName defines the name of the new task
  54381. * @param meshesNames defines the name of meshes to load
  54382. * @param rootUrl defines the root url to use to locate files
  54383. * @param sceneFilename defines the filename of the scene file
  54384. * @returns a new MeshAssetTask object
  54385. */
  54386. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54387. /**
  54388. * Add a TextFileAssetTask to the list of active tasks
  54389. * @param taskName defines the name of the new task
  54390. * @param url defines the url of the file to load
  54391. * @returns a new TextFileAssetTask object
  54392. */
  54393. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54394. /**
  54395. * Add a BinaryFileAssetTask to the list of active tasks
  54396. * @param taskName defines the name of the new task
  54397. * @param url defines the url of the file to load
  54398. * @returns a new BinaryFileAssetTask object
  54399. */
  54400. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54401. /**
  54402. * Add a ImageAssetTask to the list of active tasks
  54403. * @param taskName defines the name of the new task
  54404. * @param url defines the url of the file to load
  54405. * @returns a new ImageAssetTask object
  54406. */
  54407. addImageTask(taskName: string, url: string): ImageAssetTask;
  54408. /**
  54409. * Add a TextureAssetTask to the list of active tasks
  54410. * @param taskName defines the name of the new task
  54411. * @param url defines the url of the file to load
  54412. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54413. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54414. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54415. * @returns a new TextureAssetTask object
  54416. */
  54417. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54418. /**
  54419. * Add a CubeTextureAssetTask to the list of active tasks
  54420. * @param taskName defines the name of the new task
  54421. * @param url defines the url of the file to load
  54422. * @param extensions defines the extension to use to load the cube map (can be null)
  54423. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54424. * @param files defines the list of files to load (can be null)
  54425. * @returns a new CubeTextureAssetTask object
  54426. */
  54427. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54428. /**
  54429. *
  54430. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54431. * @param taskName defines the name of the new task
  54432. * @param url defines the url of the file to load
  54433. * @param size defines the size you want for the cubemap (can be null)
  54434. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54435. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54436. * @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)
  54437. * @param reserved Internal use only
  54438. * @returns a new HDRCubeTextureAssetTask object
  54439. */
  54440. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54441. /**
  54442. * Remove a task from the assets manager.
  54443. * @param task the task to remove
  54444. */
  54445. removeTask(task: AbstractAssetTask): void;
  54446. private _decreaseWaitingTasksCount;
  54447. private _runTask;
  54448. /**
  54449. * Reset the AssetsManager and remove all tasks
  54450. * @return the current instance of the AssetsManager
  54451. */
  54452. reset(): AssetsManager;
  54453. /**
  54454. * Start the loading process
  54455. * @return the current instance of the AssetsManager
  54456. */
  54457. load(): AssetsManager;
  54458. }
  54459. }
  54460. declare module "babylonjs/Misc/deferred" {
  54461. /**
  54462. * Wrapper class for promise with external resolve and reject.
  54463. */
  54464. export class Deferred<T> {
  54465. /**
  54466. * The promise associated with this deferred object.
  54467. */
  54468. readonly promise: Promise<T>;
  54469. private _resolve;
  54470. private _reject;
  54471. /**
  54472. * The resolve method of the promise associated with this deferred object.
  54473. */
  54474. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54475. /**
  54476. * The reject method of the promise associated with this deferred object.
  54477. */
  54478. readonly reject: (reason?: any) => void;
  54479. /**
  54480. * Constructor for this deferred object.
  54481. */
  54482. constructor();
  54483. }
  54484. }
  54485. declare module "babylonjs/Misc/filesInput" {
  54486. import { Engine } from "babylonjs/Engines/engine";
  54487. import { Scene } from "babylonjs/scene";
  54488. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  54489. /**
  54490. * Class used to help managing file picking and drag'n'drop
  54491. */
  54492. export class FilesInput {
  54493. /**
  54494. * List of files ready to be loaded
  54495. */
  54496. static readonly FilesToLoad: {
  54497. [key: string]: File;
  54498. };
  54499. /**
  54500. * Callback called when a file is processed
  54501. */
  54502. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  54503. private _engine;
  54504. private _currentScene;
  54505. private _sceneLoadedCallback;
  54506. private _progressCallback;
  54507. private _additionalRenderLoopLogicCallback;
  54508. private _textureLoadingCallback;
  54509. private _startingProcessingFilesCallback;
  54510. private _onReloadCallback;
  54511. private _errorCallback;
  54512. private _elementToMonitor;
  54513. private _sceneFileToLoad;
  54514. private _filesToLoad;
  54515. /**
  54516. * Creates a new FilesInput
  54517. * @param engine defines the rendering engine
  54518. * @param scene defines the hosting scene
  54519. * @param sceneLoadedCallback callback called when scene is loaded
  54520. * @param progressCallback callback called to track progress
  54521. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  54522. * @param textureLoadingCallback callback called when a texture is loading
  54523. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  54524. * @param onReloadCallback callback called when a reload is requested
  54525. * @param errorCallback callback call if an error occurs
  54526. */
  54527. 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);
  54528. private _dragEnterHandler;
  54529. private _dragOverHandler;
  54530. private _dropHandler;
  54531. /**
  54532. * Calls this function to listen to drag'n'drop events on a specific DOM element
  54533. * @param elementToMonitor defines the DOM element to track
  54534. */
  54535. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  54536. /**
  54537. * Release all associated resources
  54538. */
  54539. dispose(): void;
  54540. private renderFunction;
  54541. private drag;
  54542. private drop;
  54543. private _traverseFolder;
  54544. private _processFiles;
  54545. /**
  54546. * Load files from a drop event
  54547. * @param event defines the drop event to use as source
  54548. */
  54549. loadFiles(event: any): void;
  54550. private _processReload;
  54551. /**
  54552. * Reload the current scene from the loaded files
  54553. */
  54554. reload(): void;
  54555. }
  54556. }
  54557. declare module "babylonjs/Misc/HighDynamicRange/index" {
  54558. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  54559. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  54560. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54561. }
  54562. declare module "babylonjs/Misc/sceneOptimizer" {
  54563. import { Scene, IDisposable } from "babylonjs/scene";
  54564. import { Observable } from "babylonjs/Misc/observable";
  54565. /**
  54566. * Defines the root class used to create scene optimization to use with SceneOptimizer
  54567. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54568. */
  54569. export class SceneOptimization {
  54570. /**
  54571. * Defines the priority of this optimization (0 by default which means first in the list)
  54572. */
  54573. priority: number;
  54574. /**
  54575. * Gets a string describing the action executed by the current optimization
  54576. * @returns description string
  54577. */
  54578. getDescription(): string;
  54579. /**
  54580. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54581. * @param scene defines the current scene where to apply this optimization
  54582. * @param optimizer defines the current optimizer
  54583. * @returns true if everything that can be done was applied
  54584. */
  54585. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54586. /**
  54587. * Creates the SceneOptimization object
  54588. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54589. * @param desc defines the description associated with the optimization
  54590. */
  54591. constructor(
  54592. /**
  54593. * Defines the priority of this optimization (0 by default which means first in the list)
  54594. */
  54595. priority?: number);
  54596. }
  54597. /**
  54598. * Defines an optimization used to reduce the size of render target textures
  54599. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54600. */
  54601. export class TextureOptimization extends SceneOptimization {
  54602. /**
  54603. * Defines the priority of this optimization (0 by default which means first in the list)
  54604. */
  54605. priority: number;
  54606. /**
  54607. * 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
  54608. */
  54609. maximumSize: number;
  54610. /**
  54611. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54612. */
  54613. step: number;
  54614. /**
  54615. * Gets a string describing the action executed by the current optimization
  54616. * @returns description string
  54617. */
  54618. getDescription(): string;
  54619. /**
  54620. * Creates the TextureOptimization object
  54621. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54622. * @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
  54623. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54624. */
  54625. constructor(
  54626. /**
  54627. * Defines the priority of this optimization (0 by default which means first in the list)
  54628. */
  54629. priority?: number,
  54630. /**
  54631. * 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
  54632. */
  54633. maximumSize?: number,
  54634. /**
  54635. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54636. */
  54637. step?: number);
  54638. /**
  54639. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54640. * @param scene defines the current scene where to apply this optimization
  54641. * @param optimizer defines the current optimizer
  54642. * @returns true if everything that can be done was applied
  54643. */
  54644. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54645. }
  54646. /**
  54647. * Defines an optimization used to increase or decrease the rendering resolution
  54648. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54649. */
  54650. export class HardwareScalingOptimization extends SceneOptimization {
  54651. /**
  54652. * Defines the priority of this optimization (0 by default which means first in the list)
  54653. */
  54654. priority: number;
  54655. /**
  54656. * Defines the maximum scale to use (2 by default)
  54657. */
  54658. maximumScale: number;
  54659. /**
  54660. * Defines the step to use between two passes (0.5 by default)
  54661. */
  54662. step: number;
  54663. private _currentScale;
  54664. private _directionOffset;
  54665. /**
  54666. * Gets a string describing the action executed by the current optimization
  54667. * @return description string
  54668. */
  54669. getDescription(): string;
  54670. /**
  54671. * Creates the HardwareScalingOptimization object
  54672. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54673. * @param maximumScale defines the maximum scale to use (2 by default)
  54674. * @param step defines the step to use between two passes (0.5 by default)
  54675. */
  54676. constructor(
  54677. /**
  54678. * Defines the priority of this optimization (0 by default which means first in the list)
  54679. */
  54680. priority?: number,
  54681. /**
  54682. * Defines the maximum scale to use (2 by default)
  54683. */
  54684. maximumScale?: number,
  54685. /**
  54686. * Defines the step to use between two passes (0.5 by default)
  54687. */
  54688. step?: number);
  54689. /**
  54690. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54691. * @param scene defines the current scene where to apply this optimization
  54692. * @param optimizer defines the current optimizer
  54693. * @returns true if everything that can be done was applied
  54694. */
  54695. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54696. }
  54697. /**
  54698. * Defines an optimization used to remove shadows
  54699. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54700. */
  54701. export class ShadowsOptimization extends SceneOptimization {
  54702. /**
  54703. * Gets a string describing the action executed by the current optimization
  54704. * @return description string
  54705. */
  54706. getDescription(): string;
  54707. /**
  54708. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54709. * @param scene defines the current scene where to apply this optimization
  54710. * @param optimizer defines the current optimizer
  54711. * @returns true if everything that can be done was applied
  54712. */
  54713. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54714. }
  54715. /**
  54716. * Defines an optimization used to turn post-processes off
  54717. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54718. */
  54719. export class PostProcessesOptimization extends SceneOptimization {
  54720. /**
  54721. * Gets a string describing the action executed by the current optimization
  54722. * @return description string
  54723. */
  54724. getDescription(): string;
  54725. /**
  54726. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54727. * @param scene defines the current scene where to apply this optimization
  54728. * @param optimizer defines the current optimizer
  54729. * @returns true if everything that can be done was applied
  54730. */
  54731. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54732. }
  54733. /**
  54734. * Defines an optimization used to turn lens flares off
  54735. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54736. */
  54737. export class LensFlaresOptimization extends SceneOptimization {
  54738. /**
  54739. * Gets a string describing the action executed by the current optimization
  54740. * @return description string
  54741. */
  54742. getDescription(): string;
  54743. /**
  54744. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54745. * @param scene defines the current scene where to apply this optimization
  54746. * @param optimizer defines the current optimizer
  54747. * @returns true if everything that can be done was applied
  54748. */
  54749. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54750. }
  54751. /**
  54752. * Defines an optimization based on user defined callback.
  54753. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54754. */
  54755. export class CustomOptimization extends SceneOptimization {
  54756. /**
  54757. * Callback called to apply the custom optimization.
  54758. */
  54759. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  54760. /**
  54761. * Callback called to get custom description
  54762. */
  54763. onGetDescription: () => string;
  54764. /**
  54765. * Gets a string describing the action executed by the current optimization
  54766. * @returns description string
  54767. */
  54768. getDescription(): string;
  54769. /**
  54770. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54771. * @param scene defines the current scene where to apply this optimization
  54772. * @param optimizer defines the current optimizer
  54773. * @returns true if everything that can be done was applied
  54774. */
  54775. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54776. }
  54777. /**
  54778. * Defines an optimization used to turn particles off
  54779. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54780. */
  54781. export class ParticlesOptimization extends SceneOptimization {
  54782. /**
  54783. * Gets a string describing the action executed by the current optimization
  54784. * @return description string
  54785. */
  54786. getDescription(): string;
  54787. /**
  54788. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54789. * @param scene defines the current scene where to apply this optimization
  54790. * @param optimizer defines the current optimizer
  54791. * @returns true if everything that can be done was applied
  54792. */
  54793. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54794. }
  54795. /**
  54796. * Defines an optimization used to turn render targets off
  54797. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54798. */
  54799. export class RenderTargetsOptimization extends SceneOptimization {
  54800. /**
  54801. * Gets a string describing the action executed by the current optimization
  54802. * @return description string
  54803. */
  54804. getDescription(): string;
  54805. /**
  54806. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54807. * @param scene defines the current scene where to apply this optimization
  54808. * @param optimizer defines the current optimizer
  54809. * @returns true if everything that can be done was applied
  54810. */
  54811. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54812. }
  54813. /**
  54814. * Defines an optimization used to merge meshes with compatible materials
  54815. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54816. */
  54817. export class MergeMeshesOptimization extends SceneOptimization {
  54818. private static _UpdateSelectionTree;
  54819. /**
  54820. * Gets or sets a boolean which defines if optimization octree has to be updated
  54821. */
  54822. /**
  54823. * Gets or sets a boolean which defines if optimization octree has to be updated
  54824. */
  54825. static UpdateSelectionTree: boolean;
  54826. /**
  54827. * Gets a string describing the action executed by the current optimization
  54828. * @return description string
  54829. */
  54830. getDescription(): string;
  54831. private _canBeMerged;
  54832. /**
  54833. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54834. * @param scene defines the current scene where to apply this optimization
  54835. * @param optimizer defines the current optimizer
  54836. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  54837. * @returns true if everything that can be done was applied
  54838. */
  54839. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  54840. }
  54841. /**
  54842. * Defines a list of options used by SceneOptimizer
  54843. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54844. */
  54845. export class SceneOptimizerOptions {
  54846. /**
  54847. * Defines the target frame rate to reach (60 by default)
  54848. */
  54849. targetFrameRate: number;
  54850. /**
  54851. * Defines the interval between two checkes (2000ms by default)
  54852. */
  54853. trackerDuration: number;
  54854. /**
  54855. * Gets the list of optimizations to apply
  54856. */
  54857. optimizations: SceneOptimization[];
  54858. /**
  54859. * Creates a new list of options used by SceneOptimizer
  54860. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  54861. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  54862. */
  54863. constructor(
  54864. /**
  54865. * Defines the target frame rate to reach (60 by default)
  54866. */
  54867. targetFrameRate?: number,
  54868. /**
  54869. * Defines the interval between two checkes (2000ms by default)
  54870. */
  54871. trackerDuration?: number);
  54872. /**
  54873. * Add a new optimization
  54874. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  54875. * @returns the current SceneOptimizerOptions
  54876. */
  54877. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  54878. /**
  54879. * Add a new custom optimization
  54880. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  54881. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  54882. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54883. * @returns the current SceneOptimizerOptions
  54884. */
  54885. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  54886. /**
  54887. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  54888. * @param targetFrameRate defines the target frame rate (60 by default)
  54889. * @returns a SceneOptimizerOptions object
  54890. */
  54891. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54892. /**
  54893. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  54894. * @param targetFrameRate defines the target frame rate (60 by default)
  54895. * @returns a SceneOptimizerOptions object
  54896. */
  54897. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54898. /**
  54899. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  54900. * @param targetFrameRate defines the target frame rate (60 by default)
  54901. * @returns a SceneOptimizerOptions object
  54902. */
  54903. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54904. }
  54905. /**
  54906. * Class used to run optimizations in order to reach a target frame rate
  54907. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54908. */
  54909. export class SceneOptimizer implements IDisposable {
  54910. private _isRunning;
  54911. private _options;
  54912. private _scene;
  54913. private _currentPriorityLevel;
  54914. private _targetFrameRate;
  54915. private _trackerDuration;
  54916. private _currentFrameRate;
  54917. private _sceneDisposeObserver;
  54918. private _improvementMode;
  54919. /**
  54920. * Defines an observable called when the optimizer reaches the target frame rate
  54921. */
  54922. onSuccessObservable: Observable<SceneOptimizer>;
  54923. /**
  54924. * Defines an observable called when the optimizer enables an optimization
  54925. */
  54926. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  54927. /**
  54928. * Defines an observable called when the optimizer is not able to reach the target frame rate
  54929. */
  54930. onFailureObservable: Observable<SceneOptimizer>;
  54931. /**
  54932. * Gets a boolean indicating if the optimizer is in improvement mode
  54933. */
  54934. readonly isInImprovementMode: boolean;
  54935. /**
  54936. * Gets the current priority level (0 at start)
  54937. */
  54938. readonly currentPriorityLevel: number;
  54939. /**
  54940. * Gets the current frame rate checked by the SceneOptimizer
  54941. */
  54942. readonly currentFrameRate: number;
  54943. /**
  54944. * Gets or sets the current target frame rate (60 by default)
  54945. */
  54946. /**
  54947. * Gets or sets the current target frame rate (60 by default)
  54948. */
  54949. targetFrameRate: number;
  54950. /**
  54951. * Gets or sets the current interval between two checks (every 2000ms by default)
  54952. */
  54953. /**
  54954. * Gets or sets the current interval between two checks (every 2000ms by default)
  54955. */
  54956. trackerDuration: number;
  54957. /**
  54958. * Gets the list of active optimizations
  54959. */
  54960. readonly optimizations: SceneOptimization[];
  54961. /**
  54962. * Creates a new SceneOptimizer
  54963. * @param scene defines the scene to work on
  54964. * @param options defines the options to use with the SceneOptimizer
  54965. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  54966. * @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)
  54967. */
  54968. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  54969. /**
  54970. * Stops the current optimizer
  54971. */
  54972. stop(): void;
  54973. /**
  54974. * Reset the optimizer to initial step (current priority level = 0)
  54975. */
  54976. reset(): void;
  54977. /**
  54978. * Start the optimizer. By default it will try to reach a specific framerate
  54979. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  54980. */
  54981. start(): void;
  54982. private _checkCurrentState;
  54983. /**
  54984. * Release all resources
  54985. */
  54986. dispose(): void;
  54987. /**
  54988. * Helper function to create a SceneOptimizer with one single line of code
  54989. * @param scene defines the scene to work on
  54990. * @param options defines the options to use with the SceneOptimizer
  54991. * @param onSuccess defines a callback to call on success
  54992. * @param onFailure defines a callback to call on failure
  54993. * @returns the new SceneOptimizer object
  54994. */
  54995. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  54996. }
  54997. }
  54998. declare module "babylonjs/Misc/sceneSerializer" {
  54999. import { Scene } from "babylonjs/scene";
  55000. /**
  55001. * Class used to serialize a scene into a string
  55002. */
  55003. export class SceneSerializer {
  55004. /**
  55005. * Clear cache used by a previous serialization
  55006. */
  55007. static ClearCache(): void;
  55008. /**
  55009. * Serialize a scene into a JSON compatible object
  55010. * @param scene defines the scene to serialize
  55011. * @returns a JSON compatible object
  55012. */
  55013. static Serialize(scene: Scene): any;
  55014. /**
  55015. * Serialize a mesh into a JSON compatible object
  55016. * @param toSerialize defines the mesh to serialize
  55017. * @param withParents defines if parents must be serialized as well
  55018. * @param withChildren defines if children must be serialized as well
  55019. * @returns a JSON compatible object
  55020. */
  55021. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55022. }
  55023. }
  55024. declare module "babylonjs/Misc/videoRecorder" {
  55025. import { Nullable } from "babylonjs/types";
  55026. import { Engine } from "babylonjs/Engines/engine";
  55027. /**
  55028. * This represents the different options avilable for the video capture.
  55029. */
  55030. export interface VideoRecorderOptions {
  55031. /** Defines the mime type of the video */
  55032. mimeType: string;
  55033. /** Defines the video the video should be recorded at */
  55034. fps: number;
  55035. /** Defines the chunk size for the recording data */
  55036. recordChunckSize: number;
  55037. }
  55038. /**
  55039. * This can helps recording videos from BabylonJS.
  55040. * This is based on the available WebRTC functionalities of the browser.
  55041. *
  55042. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55043. */
  55044. export class VideoRecorder {
  55045. private static readonly _defaultOptions;
  55046. /**
  55047. * Returns wehther or not the VideoRecorder is available in your browser.
  55048. * @param engine Defines the Babylon Engine to check the support for
  55049. * @returns true if supported otherwise false
  55050. */
  55051. static IsSupported(engine: Engine): boolean;
  55052. private readonly _options;
  55053. private _canvas;
  55054. private _mediaRecorder;
  55055. private _recordedChunks;
  55056. private _fileName;
  55057. private _resolve;
  55058. private _reject;
  55059. /**
  55060. * True wether a recording is already in progress.
  55061. */
  55062. readonly isRecording: boolean;
  55063. /**
  55064. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55065. * a video file.
  55066. * @param engine Defines the BabylonJS Engine you wish to record
  55067. * @param options Defines options that can be used to customized the capture
  55068. */
  55069. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55070. /**
  55071. * Stops the current recording before the default capture timeout passed in the startRecording
  55072. * functions.
  55073. */
  55074. stopRecording(): void;
  55075. /**
  55076. * Starts recording the canvas for a max duration specified in parameters.
  55077. * @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.
  55078. * @param maxDuration Defines the maximum recording time in seconds.
  55079. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55080. * @return a promise callback at the end of the recording with the video data in Blob.
  55081. */
  55082. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55083. /**
  55084. * Releases internal resources used during the recording.
  55085. */
  55086. dispose(): void;
  55087. private _handleDataAvailable;
  55088. private _handleError;
  55089. private _handleStop;
  55090. }
  55091. }
  55092. declare module "babylonjs/Misc/workerPool" {
  55093. import { IDisposable } from "babylonjs/scene";
  55094. /**
  55095. * Helper class to push actions to a pool of workers.
  55096. */
  55097. export class WorkerPool implements IDisposable {
  55098. private _workerInfos;
  55099. private _pendingActions;
  55100. /**
  55101. * Constructor
  55102. * @param workers Array of workers to use for actions
  55103. */
  55104. constructor(workers: Array<Worker>);
  55105. /**
  55106. * Terminates all workers and clears any pending actions.
  55107. */
  55108. dispose(): void;
  55109. /**
  55110. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55111. * pended until a worker has completed its action.
  55112. * @param action The action to perform. Call onComplete when the action is complete.
  55113. */
  55114. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55115. private _execute;
  55116. }
  55117. }
  55118. declare module "babylonjs/Misc/screenshotTools" {
  55119. import { Camera } from "babylonjs/Cameras/camera";
  55120. import { Engine } from "babylonjs/Engines/engine";
  55121. /**
  55122. * Class containing a set of static utilities functions for screenshots
  55123. */
  55124. export class ScreenshotTools {
  55125. /**
  55126. * Captures a screenshot of the current rendering
  55127. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55128. * @param engine defines the rendering engine
  55129. * @param camera defines the source camera
  55130. * @param size This parameter can be set to a single number or to an object with the
  55131. * following (optional) properties: precision, width, height. If a single number is passed,
  55132. * it will be used for both width and height. If an object is passed, the screenshot size
  55133. * will be derived from the parameters. The precision property is a multiplier allowing
  55134. * rendering at a higher or lower resolution
  55135. * @param successCallback defines the callback receives a single parameter which contains the
  55136. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55137. * src parameter of an <img> to display it
  55138. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55139. * Check your browser for supported MIME types
  55140. */
  55141. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55142. /**
  55143. * Generates an image screenshot from the specified camera.
  55144. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55145. * @param engine The engine to use for rendering
  55146. * @param camera The camera to use for rendering
  55147. * @param size This parameter can be set to a single number or to an object with the
  55148. * following (optional) properties: precision, width, height. If a single number is passed,
  55149. * it will be used for both width and height. If an object is passed, the screenshot size
  55150. * will be derived from the parameters. The precision property is a multiplier allowing
  55151. * rendering at a higher or lower resolution
  55152. * @param successCallback The callback receives a single parameter which contains the
  55153. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55154. * src parameter of an <img> to display it
  55155. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55156. * Check your browser for supported MIME types
  55157. * @param samples Texture samples (default: 1)
  55158. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55159. * @param fileName A name for for the downloaded file.
  55160. */
  55161. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55162. }
  55163. }
  55164. declare module "babylonjs/Misc/index" {
  55165. export * from "babylonjs/Misc/andOrNotEvaluator";
  55166. export * from "babylonjs/Misc/assetsManager";
  55167. export * from "babylonjs/Misc/dds";
  55168. export * from "babylonjs/Misc/decorators";
  55169. export * from "babylonjs/Misc/deferred";
  55170. export * from "babylonjs/Misc/environmentTextureTools";
  55171. export * from "babylonjs/Misc/filesInput";
  55172. export * from "babylonjs/Misc/HighDynamicRange/index";
  55173. export * from "babylonjs/Misc/khronosTextureContainer";
  55174. export * from "babylonjs/Misc/observable";
  55175. export * from "babylonjs/Misc/performanceMonitor";
  55176. export * from "babylonjs/Misc/promise";
  55177. export * from "babylonjs/Misc/sceneOptimizer";
  55178. export * from "babylonjs/Misc/sceneSerializer";
  55179. export * from "babylonjs/Misc/smartArray";
  55180. export * from "babylonjs/Misc/stringDictionary";
  55181. export * from "babylonjs/Misc/tags";
  55182. export * from "babylonjs/Misc/textureTools";
  55183. export * from "babylonjs/Misc/tga";
  55184. export * from "babylonjs/Misc/tools";
  55185. export * from "babylonjs/Misc/videoRecorder";
  55186. export * from "babylonjs/Misc/virtualJoystick";
  55187. export * from "babylonjs/Misc/workerPool";
  55188. export * from "babylonjs/Misc/logger";
  55189. export * from "babylonjs/Misc/typeStore";
  55190. export * from "babylonjs/Misc/filesInputStore";
  55191. export * from "babylonjs/Misc/deepCopier";
  55192. export * from "babylonjs/Misc/pivotTools";
  55193. export * from "babylonjs/Misc/precisionDate";
  55194. export * from "babylonjs/Misc/screenshotTools";
  55195. export * from "babylonjs/Misc/typeStore";
  55196. }
  55197. declare module "babylonjs/index" {
  55198. export * from "babylonjs/abstractScene";
  55199. export * from "babylonjs/Actions/index";
  55200. export * from "babylonjs/Animations/index";
  55201. export * from "babylonjs/assetContainer";
  55202. export * from "babylonjs/Audio/index";
  55203. export * from "babylonjs/Behaviors/index";
  55204. export * from "babylonjs/Bones/index";
  55205. export * from "babylonjs/Cameras/index";
  55206. export * from "babylonjs/Collisions/index";
  55207. export * from "babylonjs/Culling/index";
  55208. export * from "babylonjs/Debug/index";
  55209. export * from "babylonjs/Engines/index";
  55210. export * from "babylonjs/Events/index";
  55211. export * from "babylonjs/Gamepads/index";
  55212. export * from "babylonjs/Gizmos/index";
  55213. export * from "babylonjs/Helpers/index";
  55214. export * from "babylonjs/Instrumentation/index";
  55215. export * from "babylonjs/Layers/index";
  55216. export * from "babylonjs/LensFlares/index";
  55217. export * from "babylonjs/Lights/index";
  55218. export * from "babylonjs/Loading/index";
  55219. export * from "babylonjs/Materials/index";
  55220. export * from "babylonjs/Maths/index";
  55221. export * from "babylonjs/Meshes/index";
  55222. export * from "babylonjs/Morph/index";
  55223. export * from "babylonjs/node";
  55224. export * from "babylonjs/Offline/index";
  55225. export * from "babylonjs/Particles/index";
  55226. export * from "babylonjs/Physics/index";
  55227. export * from "babylonjs/PostProcesses/index";
  55228. export * from "babylonjs/Probes/index";
  55229. export * from "babylonjs/Rendering/index";
  55230. export * from "babylonjs/scene";
  55231. export * from "babylonjs/sceneComponent";
  55232. export * from "babylonjs/Sprites/index";
  55233. export * from "babylonjs/States/index";
  55234. export * from "babylonjs/Misc/index";
  55235. export * from "babylonjs/types";
  55236. }
  55237. declare module "babylonjs/Legacy/legacy" {
  55238. export * from "babylonjs/index";
  55239. }
  55240. declare module "babylonjs/Shaders/blur.fragment" {
  55241. /** @hidden */
  55242. export var blurPixelShader: {
  55243. name: string;
  55244. shader: string;
  55245. };
  55246. }
  55247. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  55248. /** @hidden */
  55249. export var bones300Declaration: {
  55250. name: string;
  55251. shader: string;
  55252. };
  55253. }
  55254. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  55255. /** @hidden */
  55256. export var instances300Declaration: {
  55257. name: string;
  55258. shader: string;
  55259. };
  55260. }
  55261. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  55262. /** @hidden */
  55263. export var pointCloudVertexDeclaration: {
  55264. name: string;
  55265. shader: string;
  55266. };
  55267. }
  55268. // Mixins
  55269. interface Window {
  55270. mozIndexedDB: IDBFactory;
  55271. webkitIndexedDB: IDBFactory;
  55272. msIndexedDB: IDBFactory;
  55273. webkitURL: typeof URL;
  55274. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55275. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55276. WebGLRenderingContext: WebGLRenderingContext;
  55277. MSGesture: MSGesture;
  55278. CANNON: any;
  55279. AudioContext: AudioContext;
  55280. webkitAudioContext: AudioContext;
  55281. PointerEvent: any;
  55282. Math: Math;
  55283. Uint8Array: Uint8ArrayConstructor;
  55284. Float32Array: Float32ArrayConstructor;
  55285. mozURL: typeof URL;
  55286. msURL: typeof URL;
  55287. VRFrameData: any; // WebVR, from specs 1.1
  55288. DracoDecoderModule: any;
  55289. setImmediate(handler: (...args: any[]) => void): number;
  55290. }
  55291. interface Document {
  55292. mozCancelFullScreen(): void;
  55293. msCancelFullScreen(): void;
  55294. webkitCancelFullScreen(): void;
  55295. requestPointerLock(): void;
  55296. exitPointerLock(): void;
  55297. mozFullScreen: boolean;
  55298. msIsFullScreen: boolean;
  55299. readonly webkitIsFullScreen: boolean;
  55300. readonly pointerLockElement: Element;
  55301. mozPointerLockElement: HTMLElement;
  55302. msPointerLockElement: HTMLElement;
  55303. webkitPointerLockElement: HTMLElement;
  55304. }
  55305. interface HTMLCanvasElement {
  55306. requestPointerLock(): void;
  55307. msRequestPointerLock?(): void;
  55308. mozRequestPointerLock?(): void;
  55309. webkitRequestPointerLock?(): void;
  55310. /** Track wether a record is in progress */
  55311. isRecording: boolean;
  55312. /** Capture Stream method defined by some browsers */
  55313. captureStream(fps?: number): MediaStream;
  55314. }
  55315. interface CanvasRenderingContext2D {
  55316. msImageSmoothingEnabled: boolean;
  55317. }
  55318. interface MouseEvent {
  55319. mozMovementX: number;
  55320. mozMovementY: number;
  55321. webkitMovementX: number;
  55322. webkitMovementY: number;
  55323. msMovementX: number;
  55324. msMovementY: number;
  55325. }
  55326. interface Navigator {
  55327. mozGetVRDevices: (any: any) => any;
  55328. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55329. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55330. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55331. webkitGetGamepads(): Gamepad[];
  55332. msGetGamepads(): Gamepad[];
  55333. webkitGamepads(): Gamepad[];
  55334. }
  55335. interface HTMLVideoElement {
  55336. mozSrcObject: any;
  55337. }
  55338. interface Math {
  55339. fround(x: number): number;
  55340. imul(a: number, b: number): number;
  55341. }
  55342. interface WebGLProgram {
  55343. context?: WebGLRenderingContext;
  55344. vertexShader?: WebGLShader;
  55345. fragmentShader?: WebGLShader;
  55346. isParallelCompiled: boolean;
  55347. onCompiled?: () => void;
  55348. }
  55349. interface WebGLRenderingContext {
  55350. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55351. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55352. vertexAttribDivisor(index: number, divisor: number): void;
  55353. createVertexArray(): any;
  55354. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55355. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55356. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55357. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55358. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55359. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55360. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55361. // Queries
  55362. createQuery(): WebGLQuery;
  55363. deleteQuery(query: WebGLQuery): void;
  55364. beginQuery(target: number, query: WebGLQuery): void;
  55365. endQuery(target: number): void;
  55366. getQueryParameter(query: WebGLQuery, pname: number): any;
  55367. getQuery(target: number, pname: number): any;
  55368. MAX_SAMPLES: number;
  55369. RGBA8: number;
  55370. READ_FRAMEBUFFER: number;
  55371. DRAW_FRAMEBUFFER: number;
  55372. UNIFORM_BUFFER: number;
  55373. HALF_FLOAT_OES: number;
  55374. RGBA16F: number;
  55375. RGBA32F: number;
  55376. R32F: number;
  55377. RG32F: number;
  55378. RGB32F: number;
  55379. R16F: number;
  55380. RG16F: number;
  55381. RGB16F: number;
  55382. RED: number;
  55383. RG: number;
  55384. R8: number;
  55385. RG8: number;
  55386. UNSIGNED_INT_24_8: number;
  55387. DEPTH24_STENCIL8: number;
  55388. /* Multiple Render Targets */
  55389. drawBuffers(buffers: number[]): void;
  55390. readBuffer(src: number): void;
  55391. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55392. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55393. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55394. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55395. // Occlusion Query
  55396. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55397. ANY_SAMPLES_PASSED: number;
  55398. QUERY_RESULT_AVAILABLE: number;
  55399. QUERY_RESULT: number;
  55400. }
  55401. interface WebGLBuffer {
  55402. references: number;
  55403. capacity: number;
  55404. is32Bits: boolean;
  55405. }
  55406. interface WebGLProgram {
  55407. transformFeedback?: WebGLTransformFeedback | null;
  55408. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55409. }
  55410. interface EXT_disjoint_timer_query {
  55411. QUERY_COUNTER_BITS_EXT: number;
  55412. TIME_ELAPSED_EXT: number;
  55413. TIMESTAMP_EXT: number;
  55414. GPU_DISJOINT_EXT: number;
  55415. QUERY_RESULT_EXT: number;
  55416. QUERY_RESULT_AVAILABLE_EXT: number;
  55417. queryCounterEXT(query: WebGLQuery, target: number): void;
  55418. createQueryEXT(): WebGLQuery;
  55419. beginQueryEXT(target: number, query: WebGLQuery): void;
  55420. endQueryEXT(target: number): void;
  55421. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55422. deleteQueryEXT(query: WebGLQuery): void;
  55423. }
  55424. interface WebGLUniformLocation {
  55425. _currentState: any;
  55426. }
  55427. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55428. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55429. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55430. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55431. interface WebGLRenderingContext {
  55432. readonly RASTERIZER_DISCARD: number;
  55433. readonly DEPTH_COMPONENT24: number;
  55434. readonly TEXTURE_3D: number;
  55435. readonly TEXTURE_2D_ARRAY: number;
  55436. readonly TEXTURE_COMPARE_FUNC: number;
  55437. readonly TEXTURE_COMPARE_MODE: number;
  55438. readonly COMPARE_REF_TO_TEXTURE: number;
  55439. readonly TEXTURE_WRAP_R: number;
  55440. readonly HALF_FLOAT: number;
  55441. readonly RGB8: number;
  55442. readonly RED_INTEGER: number;
  55443. readonly RG_INTEGER: number;
  55444. readonly RGB_INTEGER: number;
  55445. readonly RGBA_INTEGER: number;
  55446. readonly R8_SNORM: number;
  55447. readonly RG8_SNORM: number;
  55448. readonly RGB8_SNORM: number;
  55449. readonly RGBA8_SNORM: number;
  55450. readonly R8I: number;
  55451. readonly RG8I: number;
  55452. readonly RGB8I: number;
  55453. readonly RGBA8I: number;
  55454. readonly R8UI: number;
  55455. readonly RG8UI: number;
  55456. readonly RGB8UI: number;
  55457. readonly RGBA8UI: number;
  55458. readonly R16I: number;
  55459. readonly RG16I: number;
  55460. readonly RGB16I: number;
  55461. readonly RGBA16I: number;
  55462. readonly R16UI: number;
  55463. readonly RG16UI: number;
  55464. readonly RGB16UI: number;
  55465. readonly RGBA16UI: number;
  55466. readonly R32I: number;
  55467. readonly RG32I: number;
  55468. readonly RGB32I: number;
  55469. readonly RGBA32I: number;
  55470. readonly R32UI: number;
  55471. readonly RG32UI: number;
  55472. readonly RGB32UI: number;
  55473. readonly RGBA32UI: number;
  55474. readonly RGB10_A2UI: number;
  55475. readonly R11F_G11F_B10F: number;
  55476. readonly RGB9_E5: number;
  55477. readonly RGB10_A2: number;
  55478. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55479. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55480. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55481. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55482. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55483. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55484. 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;
  55485. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55486. readonly TRANSFORM_FEEDBACK: number;
  55487. readonly INTERLEAVED_ATTRIBS: number;
  55488. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55489. createTransformFeedback(): WebGLTransformFeedback;
  55490. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55491. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55492. beginTransformFeedback(primitiveMode: number): void;
  55493. endTransformFeedback(): void;
  55494. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55495. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55496. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55497. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55498. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55499. }
  55500. interface ImageBitmap {
  55501. readonly width: number;
  55502. readonly height: number;
  55503. close(): void;
  55504. }
  55505. interface WebGLQuery extends WebGLObject {
  55506. }
  55507. declare var WebGLQuery: {
  55508. prototype: WebGLQuery;
  55509. new(): WebGLQuery;
  55510. };
  55511. interface WebGLSampler extends WebGLObject {
  55512. }
  55513. declare var WebGLSampler: {
  55514. prototype: WebGLSampler;
  55515. new(): WebGLSampler;
  55516. };
  55517. interface WebGLSync extends WebGLObject {
  55518. }
  55519. declare var WebGLSync: {
  55520. prototype: WebGLSync;
  55521. new(): WebGLSync;
  55522. };
  55523. interface WebGLTransformFeedback extends WebGLObject {
  55524. }
  55525. declare var WebGLTransformFeedback: {
  55526. prototype: WebGLTransformFeedback;
  55527. new(): WebGLTransformFeedback;
  55528. };
  55529. interface WebGLVertexArrayObject extends WebGLObject {
  55530. }
  55531. declare var WebGLVertexArrayObject: {
  55532. prototype: WebGLVertexArrayObject;
  55533. new(): WebGLVertexArrayObject;
  55534. };
  55535. // Type definitions for WebVR API
  55536. // Project: https://w3c.github.io/webvr/
  55537. // Definitions by: six a <https://github.com/lostfictions>
  55538. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55539. interface VRDisplay extends EventTarget {
  55540. /**
  55541. * Dictionary of capabilities describing the VRDisplay.
  55542. */
  55543. readonly capabilities: VRDisplayCapabilities;
  55544. /**
  55545. * z-depth defining the far plane of the eye view frustum
  55546. * enables mapping of values in the render target depth
  55547. * attachment to scene coordinates. Initially set to 10000.0.
  55548. */
  55549. depthFar: number;
  55550. /**
  55551. * z-depth defining the near plane of the eye view frustum
  55552. * enables mapping of values in the render target depth
  55553. * attachment to scene coordinates. Initially set to 0.01.
  55554. */
  55555. depthNear: number;
  55556. /**
  55557. * An identifier for this distinct VRDisplay. Used as an
  55558. * association point in the Gamepad API.
  55559. */
  55560. readonly displayId: number;
  55561. /**
  55562. * A display name, a user-readable name identifying it.
  55563. */
  55564. readonly displayName: string;
  55565. readonly isConnected: boolean;
  55566. readonly isPresenting: boolean;
  55567. /**
  55568. * If this VRDisplay supports room-scale experiences, the optional
  55569. * stage attribute contains details on the room-scale parameters.
  55570. */
  55571. readonly stageParameters: VRStageParameters | null;
  55572. /**
  55573. * Passing the value returned by `requestAnimationFrame` to
  55574. * `cancelAnimationFrame` will unregister the callback.
  55575. * @param handle Define the hanle of the request to cancel
  55576. */
  55577. cancelAnimationFrame(handle: number): void;
  55578. /**
  55579. * Stops presenting to the VRDisplay.
  55580. * @returns a promise to know when it stopped
  55581. */
  55582. exitPresent(): Promise<void>;
  55583. /**
  55584. * Return the current VREyeParameters for the given eye.
  55585. * @param whichEye Define the eye we want the parameter for
  55586. * @returns the eye parameters
  55587. */
  55588. getEyeParameters(whichEye: string): VREyeParameters;
  55589. /**
  55590. * Populates the passed VRFrameData with the information required to render
  55591. * the current frame.
  55592. * @param frameData Define the data structure to populate
  55593. * @returns true if ok otherwise false
  55594. */
  55595. getFrameData(frameData: VRFrameData): boolean;
  55596. /**
  55597. * Get the layers currently being presented.
  55598. * @returns the list of VR layers
  55599. */
  55600. getLayers(): VRLayer[];
  55601. /**
  55602. * Return a VRPose containing the future predicted pose of the VRDisplay
  55603. * when the current frame will be presented. The value returned will not
  55604. * change until JavaScript has returned control to the browser.
  55605. *
  55606. * The VRPose will contain the position, orientation, velocity,
  55607. * and acceleration of each of these properties.
  55608. * @returns the pose object
  55609. */
  55610. getPose(): VRPose;
  55611. /**
  55612. * Return the current instantaneous pose of the VRDisplay, with no
  55613. * prediction applied.
  55614. * @returns the current instantaneous pose
  55615. */
  55616. getImmediatePose(): VRPose;
  55617. /**
  55618. * The callback passed to `requestAnimationFrame` will be called
  55619. * any time a new frame should be rendered. When the VRDisplay is
  55620. * presenting the callback will be called at the native refresh
  55621. * rate of the HMD. When not presenting this function acts
  55622. * identically to how window.requestAnimationFrame acts. Content should
  55623. * make no assumptions of frame rate or vsync behavior as the HMD runs
  55624. * asynchronously from other displays and at differing refresh rates.
  55625. * @param callback Define the eaction to run next frame
  55626. * @returns the request handle it
  55627. */
  55628. requestAnimationFrame(callback: FrameRequestCallback): number;
  55629. /**
  55630. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  55631. * Repeat calls while already presenting will update the VRLayers being displayed.
  55632. * @param layers Define the list of layer to present
  55633. * @returns a promise to know when the request has been fulfilled
  55634. */
  55635. requestPresent(layers: VRLayer[]): Promise<void>;
  55636. /**
  55637. * Reset the pose for this display, treating its current position and
  55638. * orientation as the "origin/zero" values. VRPose.position,
  55639. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  55640. * updated when calling resetPose(). This should be called in only
  55641. * sitting-space experiences.
  55642. */
  55643. resetPose(): void;
  55644. /**
  55645. * The VRLayer provided to the VRDisplay will be captured and presented
  55646. * in the HMD. Calling this function has the same effect on the source
  55647. * canvas as any other operation that uses its source image, and canvases
  55648. * created without preserveDrawingBuffer set to true will be cleared.
  55649. * @param pose Define the pose to submit
  55650. */
  55651. submitFrame(pose?: VRPose): void;
  55652. }
  55653. declare var VRDisplay: {
  55654. prototype: VRDisplay;
  55655. new(): VRDisplay;
  55656. };
  55657. interface VRLayer {
  55658. leftBounds?: number[] | Float32Array | null;
  55659. rightBounds?: number[] | Float32Array | null;
  55660. source?: HTMLCanvasElement | null;
  55661. }
  55662. interface VRDisplayCapabilities {
  55663. readonly canPresent: boolean;
  55664. readonly hasExternalDisplay: boolean;
  55665. readonly hasOrientation: boolean;
  55666. readonly hasPosition: boolean;
  55667. readonly maxLayers: number;
  55668. }
  55669. interface VREyeParameters {
  55670. /** @deprecated */
  55671. readonly fieldOfView: VRFieldOfView;
  55672. readonly offset: Float32Array;
  55673. readonly renderHeight: number;
  55674. readonly renderWidth: number;
  55675. }
  55676. interface VRFieldOfView {
  55677. readonly downDegrees: number;
  55678. readonly leftDegrees: number;
  55679. readonly rightDegrees: number;
  55680. readonly upDegrees: number;
  55681. }
  55682. interface VRFrameData {
  55683. readonly leftProjectionMatrix: Float32Array;
  55684. readonly leftViewMatrix: Float32Array;
  55685. readonly pose: VRPose;
  55686. readonly rightProjectionMatrix: Float32Array;
  55687. readonly rightViewMatrix: Float32Array;
  55688. readonly timestamp: number;
  55689. }
  55690. interface VRPose {
  55691. readonly angularAcceleration: Float32Array | null;
  55692. readonly angularVelocity: Float32Array | null;
  55693. readonly linearAcceleration: Float32Array | null;
  55694. readonly linearVelocity: Float32Array | null;
  55695. readonly orientation: Float32Array | null;
  55696. readonly position: Float32Array | null;
  55697. readonly timestamp: number;
  55698. }
  55699. interface VRStageParameters {
  55700. sittingToStandingTransform?: Float32Array;
  55701. sizeX?: number;
  55702. sizeY?: number;
  55703. }
  55704. interface Navigator {
  55705. getVRDisplays(): Promise<VRDisplay[]>;
  55706. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  55707. }
  55708. interface Window {
  55709. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  55710. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  55711. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  55712. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55713. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55714. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  55715. }
  55716. interface Gamepad {
  55717. readonly displayId: number;
  55718. }
  55719. interface XRDevice {
  55720. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  55721. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  55722. }
  55723. interface XRSession {
  55724. getInputSources(): Array<any>;
  55725. baseLayer: XRWebGLLayer;
  55726. requestFrameOfReference(type: string): Promise<void>;
  55727. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  55728. end(): Promise<void>;
  55729. requestAnimationFrame: Function;
  55730. addEventListener: Function;
  55731. }
  55732. interface XRSessionCreationOptions {
  55733. outputContext?: WebGLRenderingContext | null;
  55734. immersive?: boolean;
  55735. environmentIntegration?: boolean;
  55736. }
  55737. interface XRLayer {
  55738. getViewport: Function;
  55739. framebufferWidth: number;
  55740. framebufferHeight: number;
  55741. }
  55742. interface XRView {
  55743. projectionMatrix: Float32Array;
  55744. }
  55745. interface XRFrame {
  55746. getDevicePose: Function;
  55747. getInputPose: Function;
  55748. views: Array<XRView>;
  55749. baseLayer: XRLayer;
  55750. }
  55751. interface XRFrameOfReference {
  55752. }
  55753. interface XRWebGLLayer extends XRLayer {
  55754. framebuffer: WebGLFramebuffer;
  55755. }
  55756. declare var XRWebGLLayer: {
  55757. prototype: XRWebGLLayer;
  55758. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  55759. };
  55760. declare module "babylonjs" {
  55761. export * from "babylonjs/Legacy/legacy";
  55762. }